Skip to content

Commit ed43589

Browse files
committed
fix(mobile): keep Android content rounded across routes and sheets
1 parent 5fe7568 commit ed43589

29 files changed

Lines changed: 1589 additions & 1457 deletions

‎apps/mobile/src/Stack.tsx‎

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { MaterialScreenContent } from "./components/MaterialScreenContent";
2+
import { ScreenHeader } from "./components/ScreenHeader";
13
import { PullRequestGuideStopScreen } from "./features/pull-requests/guide/PullRequestGuideScreen";
24
import { PullRequestInlineCommentScreen } from "./features/pull-requests/PullRequestInlineCommentScreen";
35
import { PullRequestDiscussionScreen } from "./features/pull-requests/PullRequestDiscussionScreen";
@@ -684,28 +686,39 @@ function NotFoundScreen() {
684686
]);
685687

686688
return (
687-
<ScrollView
688-
contentInsetAdjustmentBehavior="automatic"
689-
contentContainerStyle={{
690-
flexGrow: 1,
691-
alignItems: "center",
692-
justifyContent: "center",
693-
gap: 16,
694-
paddingHorizontal: 24,
695-
paddingVertical: 32,
696-
}}
697-
style={[{ flex: 1 }, screenBgStyle]}
698-
>
699-
<Text className="text-3xl font-t3-bold text-foreground" selectable>
700-
Route not found
701-
</Text>
702-
<Pressable
703-
style={returnHomeButtonStyle}
704-
onPress={() => navigation.dispatch(StackActions.replace("Home"))}
705-
>
706-
<Text className="text-base font-t3-bold text-primary-foreground">Return home</Text>
707-
</Pressable>
708-
</ScrollView>
689+
<>
690+
{Platform.OS === "android" ? (
691+
<ScreenHeader
692+
title="Route not found"
693+
sidebar={false}
694+
onBack={() => navigation.dispatch(StackActions.replace("Home"))}
695+
/>
696+
) : null}
697+
<MaterialScreenContent background="screen">
698+
<ScrollView
699+
contentInsetAdjustmentBehavior="automatic"
700+
contentContainerStyle={{
701+
flexGrow: 1,
702+
alignItems: "center",
703+
justifyContent: "center",
704+
gap: 16,
705+
paddingHorizontal: 24,
706+
paddingVertical: 32,
707+
}}
708+
style={[{ flex: 1 }, screenBgStyle]}
709+
>
710+
<Text className="text-3xl font-t3-bold text-foreground" selectable>
711+
Route not found
712+
</Text>
713+
<Pressable
714+
style={returnHomeButtonStyle}
715+
onPress={() => navigation.dispatch(StackActions.replace("Home"))}
716+
>
717+
<Text className="text-base font-t3-bold text-primary-foreground">Return home</Text>
718+
</Pressable>
719+
</ScrollView>
720+
</MaterialScreenContent>
721+
</>
709722
);
710723
}
711724

@@ -1047,7 +1060,16 @@ function ScreenRenderFallback(props: RenderFailureProps & { readonly routeName:
10471060
? { label: "Open settings", onPress: () => navigation.navigate("SettingsSheet") }
10481061
: { label: "Return home", onPress: () => navigation.dispatch(StackActions.replace("Home")) };
10491062

1050-
return <RenderFailureView {...props} exit={exit} />;
1063+
return (
1064+
<>
1065+
{Platform.OS === "android" ? (
1066+
<ScreenHeader title="Something went wrong" sidebar={false} onBack={exit.onPress} />
1067+
) : null}
1068+
<MaterialScreenContent background="screen">
1069+
<RenderFailureView {...props} exit={exit} />
1070+
</MaterialScreenContent>
1071+
</>
1072+
);
10511073
}
10521074

10531075
export const RootStack = RootStackConfig.with(function AdaptiveRootStack({ Navigator }) {

‎apps/mobile/src/components/AndroidScreenHeader.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function AndroidScreenHeader(props: {
5656
className="border-b border-header-border bg-header px-2"
5757
style={{
5858
...headerPadding,
59-
borderBottomWidth: props.hideBottomBorder ? 0 : undefined,
59+
borderBottomWidth: props.hideBottomBorder === false ? undefined : 0,
6060
}}
6161
>
6262
<View style={{ minHeight: materialToolbarHeight }} className="flex-row items-center gap-1">

‎apps/mobile/src/components/AppSheet.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FormSheet, Screen, ScreenStack, ScreenStackHeaderConfig } from "react-n
44
import { useResolveClassNames, withUniwind } from "uniwind";
55

66
import { AndroidSheetHeader } from "./AndroidScreenHeader";
7+
import { MaterialScreenContent } from "./MaterialScreenContent";
78
import { nativeHeaderScrollEdgeEffects } from "../native/StackHeader";
89

910
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
@@ -70,8 +71,8 @@ export function AppSheet(props: {
7071
</ScreenStack>
7172
) : (
7273
<>
73-
<AndroidSheetHeader title={props.title} onBack={close} />
74-
{props.children}
74+
<AndroidSheetHeader title={props.title} onBack={close} hideBottomBorder />
75+
<MaterialScreenContent>{props.children}</MaterialScreenContent>
7576
</>
7677
)}
7778
</View>

‎apps/mobile/src/components/MaterialScreenContent.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import type { ReactNode } from "react";
22
import { Platform, View } from "react-native";
33

4+
const CONTENT_BACKGROUNDS = {
5+
sheet: "bg-sheet-solid",
6+
screen: "bg-screen",
7+
thread: "bg-thread-canvas",
8+
} as const;
9+
410
/** Keeps the header surface visible behind rounded Android content corners. */
511
export function MaterialScreenContent({
612
children,
713
insetHorizontal = false,
814
fitToContents = false,
15+
background = "sheet",
916
}: {
1017
readonly children: ReactNode;
18+
readonly background?: keyof typeof CONTENT_BACKGROUNDS;
1119
/** Match the master-list gutters for secondary panes, not full-width content. */
1220
readonly insetHorizontal?: boolean;
1321
/** Allow native form sheets to measure their content instead of filling a fixed detent. */
@@ -18,7 +26,7 @@ export function MaterialScreenContent({
1826
return (
1927
<View className={fitToContents ? "shrink bg-header" : "flex-1 bg-header"}>
2028
<View
21-
className="overflow-hidden rounded-t-[28px] bg-sheet-solid"
29+
className={`overflow-hidden rounded-t-[28px] ${CONTENT_BACKGROUNDS[background]}`}
2230
style={{
2331
flexShrink: 1,
2432
flexGrow: fitToContents ? 0 : 1,

‎apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx‎

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1+
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
12
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
23
import { createNativeStackNavigator } from "@react-navigation/native-stack";
3-
import {
4-
EnvironmentId,
5-
FILL_PREVIEW_VIEWPORT,
6-
ThreadId,
7-
type PreviewSessionSnapshot,
8-
} from "@t3tools/contracts";
4+
import { EnvironmentId, ThreadId, type PreviewSessionSnapshot } from "@t3tools/contracts";
95
import { normalizePreviewUrl } from "@t3tools/shared/preview";
106
import { useCallback, useEffect, useRef, useState } from "react";
117
import { ActivityIndicator, Alert, AppState, Platform, TextInput, View } from "react-native";
@@ -116,6 +112,7 @@ function BrowserPreviewScreen({
116112
return (
117113
<View className="flex-1 bg-sheet" style={{ paddingBottom: insets.bottom }}>
118114
<ScreenHeader
115+
hideBottomBorder
119116
title={tab ? browserTabTitle(tab) : "Browser"}
120117
sidebar={false}
121118
onBack={onClose}
@@ -166,40 +163,42 @@ function BrowserPreviewScreen({
166163
/>
167164
</NativeHeaderToolbar>
168165
) : null}
169-
{tab ? (
170-
<>
171-
<BrowserAddressBar
172-
key={tab.tabId}
173-
environmentId={environmentId}
174-
tab={tab}
175-
streaming={streaming}
176-
ready={streaming && canControl}
177-
onCommand={(input) => streamRef.current?.command(input)}
178-
/>
179-
{live ? (
180-
<PreviewStreamWebView
166+
<MaterialScreenContent>
167+
{tab ? (
168+
<>
169+
<BrowserAddressBar
181170
key={tab.tabId}
182171
environmentId={environmentId}
183-
threadId={threadId}
184-
tabId={tab.tabId}
185-
ref={streamRef}
186-
interactive
187-
background={themeVariables["--color-sheet-solid"]}
188-
onPictureInPicture={onPictureInPicture}
189-
onStreamingChange={setStreaming}
190-
onControl={(control) => setCanControl(control?.controller === "you")}
172+
tab={tab}
173+
streaming={streaming}
174+
ready={streaming && canControl}
175+
onCommand={(input) => streamRef.current?.command(input)}
191176
/>
192-
) : (
193-
<View className="flex-1" />
194-
)}
195-
</>
196-
) : (
197-
<View className="flex-1 items-center justify-center">
198-
{focused && foreground ? (
199-
<ActivityIndicator color={themeVariables["--color-icon"]} />
200-
) : null}
201-
</View>
202-
)}
177+
{live ? (
178+
<PreviewStreamWebView
179+
key={tab.tabId}
180+
environmentId={environmentId}
181+
threadId={threadId}
182+
tabId={tab.tabId}
183+
ref={streamRef}
184+
interactive
185+
background={themeVariables["--color-sheet-solid"]}
186+
onPictureInPicture={onPictureInPicture}
187+
onStreamingChange={setStreaming}
188+
onControl={(control) => setCanControl(control?.controller === "you")}
189+
/>
190+
) : (
191+
<View className="flex-1" />
192+
)}
193+
</>
194+
) : (
195+
<View className="flex-1 items-center justify-center">
196+
{focused && foreground ? (
197+
<ActivityIndicator color={themeVariables["--color-icon"]} />
198+
) : null}
199+
</View>
200+
)}
201+
</MaterialScreenContent>
203202
</View>
204203
);
205204
}
@@ -232,7 +231,7 @@ function BrowserAddressBar({
232231
}
233232
};
234233
return (
235-
<View className="flex-row items-center gap-1 px-2 pb-2">
234+
<View className="flex-row items-center gap-1 px-2 pb-2 android:pt-3">
236235
<ControlPill
237236
icon="chevron.left"
238237
accessibilityLabel="Back"

‎apps/mobile/src/features/cloud/ConnectOnboardingRouteScreen.tsx‎

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
88

99
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
1010
import { AndroidSheetHeader } from "../../components/AndroidScreenHeader";
11+
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
1112
import { AppText as Text } from "../../components/AppText";
1213
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
1314
import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
@@ -86,6 +87,7 @@ function ConfiguredConnectOnboardingRouteScreen() {
8687
<View collapsable={false} className="flex-1 bg-sheet">
8788
{Platform.OS === "android" ? (
8889
<AndroidSheetHeader
90+
hideBottomBorder
8991
title="Set up T3 Connect"
9092
actions={[
9193
{
@@ -103,50 +105,52 @@ function ConfiguredConnectOnboardingRouteScreen() {
103105
<NativeHeaderToolbar.Button icon="xmark" onPress={handleClose} separateBackground />
104106
</NativeHeaderToolbar>
105107
)}
106-
<ScrollView
107-
nestedScrollEnabled
108-
alwaysBounceVertical
109-
contentInsetAdjustmentBehavior="automatic"
110-
showsVerticalScrollIndicator={false}
111-
className="flex-1"
112-
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
113-
contentContainerStyle={{
114-
gap: 16,
115-
paddingHorizontal: 20,
116-
paddingTop: 16,
117-
}}
118-
refreshControl={
119-
Platform.OS === "ios" ? (
120-
<RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} />
121-
) : undefined
122-
}
123-
>
124-
{isSignedIn ? (
125-
<CloudEnvironmentRows
126-
connectedCloudEnvironments={connectedCloudEnvironments}
127-
onSetEnvironmentEnabled={onSetEnvironmentEnabled}
128-
onRemoveEnvironment={onRemoveEnvironmentPress}
129-
showHeader={false}
130-
/>
131-
) : (
132-
<View collapsable={false} className="rounded-[24px] bg-grouped-card p-5">
133-
<Text className="text-sm leading-normal text-foreground-muted">
134-
Sign in to your T3 account to set up T3 Connect.
135-
</Text>
136-
</View>
137-
)}
108+
<MaterialScreenContent>
109+
<ScrollView
110+
nestedScrollEnabled
111+
alwaysBounceVertical
112+
contentInsetAdjustmentBehavior="automatic"
113+
showsVerticalScrollIndicator={false}
114+
className="flex-1"
115+
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
116+
contentContainerStyle={{
117+
gap: 16,
118+
paddingHorizontal: 20,
119+
paddingTop: 16,
120+
}}
121+
refreshControl={
122+
Platform.OS === "ios" ? (
123+
<RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} />
124+
) : undefined
125+
}
126+
>
127+
{isSignedIn ? (
128+
<CloudEnvironmentRows
129+
connectedCloudEnvironments={connectedCloudEnvironments}
130+
onSetEnvironmentEnabled={onSetEnvironmentEnabled}
131+
onRemoveEnvironment={onRemoveEnvironmentPress}
132+
showHeader={false}
133+
/>
134+
) : (
135+
<View collapsable={false} className="rounded-[24px] bg-grouped-card p-5">
136+
<Text className="text-sm leading-normal text-foreground-muted">
137+
Sign in to your T3 account to set up T3 Connect.
138+
</Text>
139+
</View>
140+
)}
138141

139-
{userId ? (
140-
<Pressable
141-
accessibilityRole="button"
142-
hitSlop={8}
143-
onPress={handleDontShowAgain}
144-
className="items-center py-1 active:opacity-70"
145-
>
146-
<Text className="text-xs text-foreground-muted">{"Don't show this again"}</Text>
147-
</Pressable>
148-
) : null}
149-
</ScrollView>
142+
{userId ? (
143+
<Pressable
144+
accessibilityRole="button"
145+
hitSlop={8}
146+
onPress={handleDontShowAgain}
147+
className="items-center py-1 active:opacity-70"
148+
>
149+
<Text className="text-xs text-foreground-muted">{"Don't show this again"}</Text>
150+
</Pressable>
151+
) : null}
152+
</ScrollView>
153+
</MaterialScreenContent>
150154
</View>
151155
);
152156
}

‎apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
StackActions,
77
useIsFocused,
88
useNavigation,
9-
useRoute,
109
type StaticScreenProps,
1110
} from "@react-navigation/native";
1211
import type { EnvironmentId } from "@t3tools/contracts";
@@ -49,7 +48,6 @@ export function ConnectionsNewRouteScreen({
4948
pairingConnectionError,
5049
} = useRemoteConnections();
5150
const navigation = useNavigation();
52-
const routeName = useRoute().name;
5351
const params = route.params ?? {};
5452
// Deep-link prefill exists for development automation only. A production
5553
// link must not arrive with attacker-chosen host and token already filled.
@@ -196,7 +194,6 @@ export function ConnectionsNewRouteScreen({
196194

197195
return (
198196
<SettingsScreen
199-
formSheet={routeName === "ConnectionsNew"}
200197
title="Add environment"
201198
actions={[
202199
{

0 commit comments

Comments
 (0)