1+ import { NativeHeaderToolbar } from "../../native/StackHeader" ;
12import { useAuth } from "@clerk/expo" ;
23import { 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" ;
56import { useSafeAreaInsets } from "react-native-safe-area-context" ;
67
78import { reportAtomCommandResult , settlePromise } from "@t3tools/client-runtime/state/runtime" ;
89import { AppText as Text } from "../../components/AppText" ;
910import { useRemoteConnections } from "../../state/use-remote-environment-registry" ;
1011import { CloudEnvironmentRows } from "../connection/CloudEnvironmentRows" ;
1112import { splitEnvironmentSections } from "../connection/environmentSections" ;
13+ import { useConnectionController } from "../connection/useConnectionController" ;
1214import { optOutOfConnectOnboarding } from "./connectOnboardingOptOut" ;
1315import { 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 ) ;
0 commit comments