Skip to content

Commit 593aa69

Browse files
Polish connect onboarding sheet
- Restore native sheet header and close affordance - Add pull-to-refresh and simplify onboarding actions - Reuse cloud rows without the section header in onboarding
1 parent 4f648f1 commit 593aa69

3 files changed

Lines changed: 71 additions & 56 deletions

File tree

‎apps/mobile/src/Stack.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ export const RootStack = createNativeStackNavigator({
421421
screen: ConnectOnboardingRouteScreen,
422422
linking: "connect-onboarding",
423423
options: {
424+
// Root screenOptions hide headers; formSheets that want the native
425+
// title bar opt back in with the sheet header preset.
426+
...SHEET_SOLID_HEADER_OPTIONS,
427+
title: "Set up T3 Connect",
424428
gestureEnabled: true,
425429
presentation: "formSheet",
426430
sheetAllowedDetents: [0.6, 0.95],

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

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { NativeHeaderToolbar } from "../../native/StackHeader";
12
import { useAuth } from "@clerk/expo";
23
import { useNavigation } from "@react-navigation/native";
3-
import { useCallback } from "react";
4-
import { Pressable, ScrollView, View } from "react-native";
4+
import { useCallback, useState } from "react";
5+
import { Pressable, RefreshControl, ScrollView, View } from "react-native";
56
import { useSafeAreaInsets } from "react-native-safe-area-context";
67

78
import { reportAtomCommandResult, settlePromise } from "@t3tools/client-runtime/state/runtime";
89
import { AppText as Text } from "../../components/AppText";
910
import { useRemoteConnections } from "../../state/use-remote-environment-registry";
1011
import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows";
1112
import { splitEnvironmentSections } from "../connection/environmentSections";
13+
import { useConnectionController } from "../connection/useConnectionController";
1214
import { optOutOfConnectOnboarding } from "./connectOnboardingOptOut";
1315
import { hasCloudPublicConfig } from "./publicConfig";
1416

@@ -28,12 +30,25 @@ function ConfiguredConnectOnboardingRouteScreen() {
2830
const insets = useSafeAreaInsets();
2931
const { isSignedIn, userId } = useAuth({ treatPendingAsSignedOut: false });
3032
const { connectedEnvironments, onReconnectEnvironment } = useRemoteConnections();
33+
const { refreshRelayEnvironments } = useConnectionController();
3134
const { connectedCloudEnvironments } = splitEnvironmentSections({
3235
connectedEnvironments,
3336
cloudEnvironments: null,
3437
});
3538

36-
const handleDone = useCallback(() => {
39+
// Pull-to-refresh tracks its own spinner instead of discovery's refreshing
40+
// flag, so background refreshes (e.g. the sign-in one) don't yank the
41+
// content down.
42+
const [isPullRefreshing, setIsPullRefreshing] = useState(false);
43+
const handlePullRefresh = useCallback(() => {
44+
void (async () => {
45+
setIsPullRefreshing(true);
46+
await refreshRelayEnvironments();
47+
setIsPullRefreshing(false);
48+
})();
49+
}, [refreshRelayEnvironments]);
50+
51+
const handleClose = useCallback(() => {
3752
navigation.goBack();
3853
}, [navigation]);
3954

@@ -49,38 +64,28 @@ function ConfiguredConnectOnboardingRouteScreen() {
4964

5065
return (
5166
<View collapsable={false} className="flex-1 bg-sheet">
67+
<NativeHeaderToolbar placement="right">
68+
<NativeHeaderToolbar.Button icon="xmark" onPress={handleClose} separateBackground />
69+
</NativeHeaderToolbar>
5270
<ScrollView
5371
contentInsetAdjustmentBehavior="automatic"
5472
showsVerticalScrollIndicator={false}
5573
style={{ flex: 1 }}
74+
contentInset={{ bottom: Math.max(insets.bottom, 18) + 18 }}
5675
contentContainerStyle={{
57-
gap: 24,
58-
paddingBottom: Math.max(insets.bottom, 18) + 18,
76+
gap: 16,
5977
paddingHorizontal: 20,
60-
paddingTop: 24,
78+
paddingTop: 16,
6179
}}
80+
refreshControl={
81+
<RefreshControl refreshing={isPullRefreshing} onRefresh={handlePullRefresh} />
82+
}
6283
>
63-
<View className="gap-1.5">
64-
<View className="flex-row items-start justify-between gap-3">
65-
<Text className="flex-1 text-2xl font-t3-bold text-foreground">Set up T3 Connect</Text>
66-
<Pressable
67-
accessibilityRole="button"
68-
hitSlop={8}
69-
onPress={handleDone}
70-
className="rounded-full bg-subtle px-3.5 py-2 active:opacity-70"
71-
>
72-
<Text className="text-xs font-t3-bold uppercase text-foreground-muted">Skip</Text>
73-
</Pressable>
74-
</View>
75-
<Text className="text-sm leading-normal text-foreground-muted">
76-
Environments published from your other devices are ready to connect here.
77-
</Text>
78-
</View>
79-
8084
{isSignedIn ? (
8185
<CloudEnvironmentRows
8286
connectedCloudEnvironments={connectedCloudEnvironments}
8387
onReconnectEnvironment={onReconnectEnvironment}
88+
showHeader={false}
8489
/>
8590
) : (
8691
<View collapsable={false} className="rounded-[24px] bg-card p-5">
@@ -90,25 +95,16 @@ function ConfiguredConnectOnboardingRouteScreen() {
9095
</View>
9196
)}
9297

93-
<View className="gap-3">
98+
{userId ? (
9499
<Pressable
95100
accessibilityRole="button"
96-
onPress={handleDone}
97-
className="min-h-[48px] items-center justify-center rounded-[18px] bg-card active:opacity-70"
101+
hitSlop={8}
102+
onPress={handleDontShowAgain}
103+
className="items-center py-1 active:opacity-70"
98104
>
99-
<Text className="text-base font-t3-bold text-foreground">Done</Text>
105+
<Text className="text-xs text-foreground-muted">{"Don't show this again"}</Text>
100106
</Pressable>
101-
{userId ? (
102-
<Pressable
103-
accessibilityRole="button"
104-
hitSlop={8}
105-
onPress={handleDontShowAgain}
106-
className="items-center py-1 active:opacity-70"
107-
>
108-
<Text className="text-xs text-foreground-muted">{"Don't show this again"}</Text>
109-
</Pressable>
110-
) : null}
111-
</View>
107+
) : null}
112108
</ScrollView>
113109
</View>
114110
);

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

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ import { type RelayEnvironmentView, useConnectionController } from "./useConnect
3333
export function CloudEnvironmentRows(props: {
3434
readonly connectedCloudEnvironments: ReadonlyArray<ConnectedEnvironmentSummary>;
3535
readonly onReconnectEnvironment: (environmentId: EnvironmentId) => void;
36+
/**
37+
* Hide the "T3 Connect" section title + refresh button for hosts that
38+
* provide their own chrome (the onboarding sheet's native header and
39+
* pull-to-refresh).
40+
*/
41+
readonly showHeader?: boolean;
3642
}) {
3743
const { isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
3844
const controller = useConnectionController();
@@ -56,27 +62,36 @@ export function CloudEnvironmentRows(props: {
5662
setExpandedErrorId((current) => (current === environmentId ? null : environmentId));
5763
}, []);
5864

65+
const showHeader = props.showHeader ?? true;
66+
5967
if (!isSignedIn) return null;
6068

6169
return (
62-
<View collapsable={false} className="mt-5 gap-3">
63-
<View className="flex-row items-center justify-between px-1">
64-
<Text className="text-sm font-t3-bold uppercase text-foreground-muted">T3 Connect</Text>
65-
<Pressable
66-
accessibilityRole="button"
67-
disabled={controller.relayDiscovery.isRefreshing}
68-
onPress={() => {
69-
void controller.refreshRelayEnvironments();
70-
}}
71-
className="h-9 w-9 items-center justify-center rounded-full bg-subtle active:opacity-70 disabled:opacity-50"
72-
>
73-
{controller.relayDiscovery.isRefreshing ? (
74-
<ActivityIndicator color={iconColor} size="small" />
75-
) : (
76-
<SymbolView name="arrow.clockwise" size={14} tintColor={iconColor} type="monochrome" />
77-
)}
78-
</Pressable>
79-
</View>
70+
<View collapsable={false} className={cn("gap-3", showHeader && "mt-5")}>
71+
{showHeader ? (
72+
<View className="flex-row items-center justify-between px-1">
73+
<Text className="text-sm font-t3-bold uppercase text-foreground-muted">T3 Connect</Text>
74+
<Pressable
75+
accessibilityRole="button"
76+
disabled={controller.relayDiscovery.isRefreshing}
77+
onPress={() => {
78+
void controller.refreshRelayEnvironments();
79+
}}
80+
className="h-9 w-9 items-center justify-center rounded-full bg-subtle active:opacity-70 disabled:opacity-50"
81+
>
82+
{controller.relayDiscovery.isRefreshing ? (
83+
<ActivityIndicator color={iconColor} size="small" />
84+
) : (
85+
<SymbolView
86+
name="arrow.clockwise"
87+
size={14}
88+
tintColor={iconColor}
89+
type="monochrome"
90+
/>
91+
)}
92+
</Pressable>
93+
</View>
94+
) : null}
8095

8196
{hasCloudRows ? (
8297
<View collapsable={false} className="overflow-hidden rounded-[24px] bg-card">

0 commit comments

Comments
 (0)