This commit is contained in:
2022-10-20 10:41:46 +02:00
parent 05f4a6c3ab
commit fd7b7de052
16 changed files with 681 additions and 62 deletions

View File

@@ -12,12 +12,13 @@ import { ColorSchemeName, Pressable } from 'react-native';
import Colors from '../constants/Colors';
import useColorScheme from '../hooks/useColorScheme';
import ModalScreen from '../screens/ModalScreen';
import NotFoundScreen from '../screens/NotFoundScreen';
import TabOneScreen from '../screens/TabOneScreen';
import TabTwoScreen from '../screens/TabTwoScreen';
import { RootStackParamList, RootTabParamList, RootTabScreenProps } from '../types';
import LinkingConfiguration from './LinkingConfiguration';
import {useState} from "react";
import AuthScreen from "../screens/AuthScreen";
export default function Navigation({ colorScheme }: { colorScheme: ColorSchemeName }) {
return (
@@ -36,15 +37,24 @@ export default function Navigation({ colorScheme }: { colorScheme: ColorSchemeNa
const Stack = createNativeStackNavigator<RootStackParamList>();
function RootNavigator() {
const [authentication, setAuthentication] = useState();
const updateAuthentication = (authentication: any) => {
setAuthentication(authentication);
}
return (
<Stack.Navigator>
<Stack.Navigator>
{ authentication == null ? (
<Stack.Screen name="Login" component={AuthScreen} authCallback={setAuthentication} options={{ headerShown: false }} />
) : (
<Stack.Navigator>
<Stack.Screen name="Root" component={BottomTabNavigator} options={{ headerShown: false }} />
<Stack.Screen name="NotFound" component={NotFoundScreen} options={{ title: 'Oops!' }} />
<Stack.Group screenOptions={{ presentation: 'modal' }}>
<Stack.Screen name="Modal" component={ModalScreen} />
</Stack.Group>
</Stack.Navigator>
);
</Stack.Navigator>
)}
</Stack.Navigator>
);
}
/**
@@ -68,20 +78,6 @@ function BottomTabNavigator() {
options={({ navigation }: RootTabScreenProps<'TabOne'>) => ({
title: 'Tab One',
tabBarIcon: ({ color }) => <TabBarIcon name="code" color={color} />,
headerRight: () => (
<Pressable
onPress={() => navigation.navigate('Modal')}
style={({ pressed }) => ({
opacity: pressed ? 0.5 : 1,
})}>
<FontAwesome
name="info-circle"
size={25}
color={Colors[colorScheme].text}
style={{ marginRight: 15 }}
/>
</Pressable>
),
})}
/>
<BottomTab.Screen