-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavShell.tsx
106 lines (81 loc) · 2.82 KB
/
NavShell.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import React, { useState, useMemo, useEffect, Suspense } from "react";
import PropTypes from "prop-types";
import { Text, Provider } from "react-native-paper";
import {View} from 'react-native'
import SplashLoading from "./SplashLoading";
import SignIn from "./SignIn";
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { useTranslation } from "react-i18next";
import { useTypedSelector } from "./infrastructure/AppReducers";
import NavMenu from "./NavMenu";
import CalendarListScreen from './CalendarListScreen';
import CheckInScreen from "./CheckInScreen";
export default function NavShell(props) {
const { t, i18n } = useTranslation();
const isLoggedIn = useTypedSelector(state => state.context.status.loggedIn);
const loggingIn = useTypedSelector(state => state.context.status.loggingIn);
const Stack = createNativeStackNavigator();
const endpointsLoaded = useTypedSelector(
state => state.context.status.endpointsLoaded
);
// Update this.
const LoggedInMessage = ({ route, navigation })=>{
const {title, text} = route.params;
return(
<View>
<Text variant='displayLarge'>{title}</Text>
<Text variant='displaySmall'>{text}</Text>
</View>
);
}
const mainStack = useMemo( ()=>{
if( isLoggedIn ){
return (<>
<Stack.Screen
name='Logged In'
// Dennis import your screen and replace 'LoggedInMessage' here with yours.
component={CalendarListScreen}
initialParams={
{
title: 'Logged In',
text: 'I love you!'
}
}
options={({navigationBarColor, route }) =>({
headerTitle: 'CoLab',
headerRight: () => (
<NavMenu />
)
})}
/>
<Stack.Screen
name='Check In'
component={CheckInScreen}
options={({navigationBarColor, route }) =>({
headerTitle: 'CoLab',
headerRight: () => (
<NavMenu />
)
})}
/>
</>
);
} else if( !loggingIn ){
return (<Stack.Screen name='Log In' component={SignIn} />);
} else {
return (<Stack.Screen name='Splash' component={SplashLoading}/>);
};
}, [isLoggedIn, loggingIn]);
return (
<Provider>
<NavigationContainer>
<Stack.Navigator>
{ mainStack }
</Stack.Navigator>
</NavigationContainer>
</Provider>
);
}
NavShell.propTypes = {
};