-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
67 lines (61 loc) · 2.08 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React, {useEffect} from 'react';
import {StyleSheet, StatusBar} from 'react-native';
import {Surface, useTheme} from 'react-native-paper';
import Authentication from './src/screens/Authentication/index.screen';
import {Main} from './src/screens/Main.screen';
import {createNativeStackNavigator as createStackNavigator} from '@react-navigation/native-stack';
import {NavigationContainer} from '@react-navigation/native';
import {Header as MainHeader} from './src/components/Header/Header.component';
// import {Schema} from './src/database/schema/index.schema';
import {useAppSelector} from './src/store/hooks/store.hook';
import './src/database/schema/index.schema';
const Stack = createStackNavigator();
const App: React.FC = (): React.JSX.Element => {
const [route, setRoute] = React.useState<number | undefined>(0);
const session = useAppSelector(state => state.usuario.sessao);
const isLoggedIn = !!useAppSelector(state => state.usuario.sessao);
const theme = useTheme();
// const isDark = use
useEffect(() => {
if (isLoggedIn) {
}
}, [route]);
return (
<Surface style={styles.appStyle}>
<StatusBar backgroundColor={theme.colors.inversePrimary} />
<NavigationContainer
onStateChange={prop => {
setRoute(prop?.index);
}}>
<Stack.Navigator
initialRouteName={isLoggedIn ? 'Main' : 'Authentication'}
screenOptions={{
header: ({navigation, back, options}) => (
<MainHeader
back={back}
options={options}
navigation={navigation}
/>
),
}}>
<Stack.Screen
name="Authentication"
options={{headerShown: false}}
component={Authentication}
/>
<Stack.Screen name="Main" component={Main} />
</Stack.Navigator>
</NavigationContainer>
</Surface>
);
};
const styles = StyleSheet.create({
appStyle: {
flex: 1,
margin: 'auto',
justifyContent: 'center',
textAlign: 'center',
alignContent: 'center',
},
});
export default App;