Open History to see the last commit
1import { useAuth } from "@clerk/expo";
2import { AuthView, UserProfileView } from "@clerk/expo/native";
3import { StackActions, useNavigation } from "@react-navigation/native";
4import { NativeStackScreenOptions } from "../../native/StackHeader";
5import { useCallback, useEffect } from "react";
6import { View } from "react-native";
7
8import { hasCloudPublicConfig } from "../cloud/publicConfig";
9
10export function SettingsAuthRouteScreen() {
11 const navigation = useNavigation();
12
13 useEffect(() => {
14 if (!hasCloudPublicConfig()) {
15 navigation.dispatch(StackActions.replace("Settings"));
16 }
17 }, [navigation]);
18
19 return hasCloudPublicConfig() ? <ConfiguredSettingsAuthRouteScreen /> : null;
20}
21
22function ConfiguredSettingsAuthRouteScreen() {
23 const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
24 const navigation = useNavigation();
25 const handleHostBack = useCallback(() => navigation.goBack(), [navigation]);
26
27 return (
28 <>
29 <NativeStackScreenOptions options={{ headerShown: false }} />
30 <View collapsable={false} className="flex-1 overflow-hidden bg-sheet">
31 {isLoaded ? (
32 isSignedIn ? (
33 <UserProfileView isDismissible={false} onHostBack={handleHostBack} />
34 ) : (
35 <AuthView isDismissible={false} onHostBack={handleHostBack} />
36 )
37 ) : null}
38 </View>
39 </>
40 );
41}