-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working base navigation system for login (#498)
This gets the project to the 0.2 milestone. The app is working on iOS and Android. There are light and dark mode splash screens. There is a simple native navigation system to help the user login. Add gesture handler and navigation/stack. Working Auth navigation.
- Loading branch information
1 parent
3189930
commit 6ecebb6
Showing
7 changed files
with
165 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { NavigationProp, useNavigation } from "@react-navigation/native"; | ||
import { createStackNavigator } from "@react-navigation/stack"; | ||
import { Button, Text, View } from "react-native"; | ||
import { useGlobalStateContext } from "./state/GlobalState"; | ||
import Login from "./screens/Login"; | ||
import { useEffect } from "react"; | ||
import AuthService from "./authentication/AuthService"; | ||
|
||
function HomeScreen({ navigation }: { navigation: NavigationProp<ReactNavigation.RootParamList> }) { | ||
return ( | ||
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}> | ||
<Text style={{ fontSize: 30 }}>This is the home screen!</Text> | ||
<Button title="Logout" onPress={() => AuthService.logoutCurrentUser()} /> | ||
</View> | ||
); | ||
} | ||
|
||
const RootStack = createStackNavigator(); | ||
|
||
export default function RootScreen() { | ||
const globalState = useGlobalStateContext(); | ||
const navigation = useNavigation(); | ||
|
||
useEffect(() => { | ||
if (globalState.appReady && !globalState.authenticated) { | ||
console.log("not authenticated so opening login"); | ||
navigation.navigate("Login" as never); | ||
} | ||
}, [globalState.authenticated, globalState.appReady, navigation]); | ||
|
||
return ( | ||
<RootStack.Navigator> | ||
<RootStack.Group> | ||
<RootStack.Screen name="Home" component={HomeScreen} /> | ||
</RootStack.Group> | ||
<RootStack.Group screenOptions={{ presentation: "modal", gestureEnabled: false, headerShown: false }}> | ||
<RootStack.Screen name="Login" component={Login} /> | ||
</RootStack.Group> | ||
</RootStack.Navigator> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.