Browse Source

Updated react navigation to v5

keplyx 4 years ago
parent
commit
7e48300fa0
6 changed files with 323 additions and 260 deletions
  1. 29
    25
      App.js
  2. 2
    63
      components/BaseContainer.js
  3. 0
    14
      navigation/AppNavigator.js
  4. 136
    55
      navigation/DrawerNavigator.js
  5. 149
    97
      navigation/MainTabNavigator.js
  6. 7
    6
      package.json

+ 29
- 25
App.js View File

@@ -3,15 +3,17 @@
3 3
 import * as React from 'react';
4 4
 import {Platform, StatusBar} from 'react-native';
5 5
 import {Root, StyleProvider} from 'native-base';
6
-import {createAppContainerWithInitialRoute} from './navigation/AppNavigator';
7 6
 import LocaleManager from './utils/LocaleManager';
8 7
 import * as Font from 'expo-font';
9 8
 import {clearThemeCache} from 'native-base-shoutem-theme';
10 9
 import AsyncStorageManager from "./utils/AsyncStorageManager";
11 10
 import CustomIntroSlider from "./components/CustomIntroSlider";
12
-import {AppLoading} from 'expo';
11
+import {SplashScreen} from 'expo';
13 12
 import NotificationsManager from "./utils/NotificationsManager";
14 13
 import ThemeManager from './utils/ThemeManager';
14
+import { NavigationContainer } from '@react-navigation/native';
15
+import { createStackNavigator } from '@react-navigation/stack';
16
+import DrawerNavigator from './navigation/DrawerNavigator';
15 17
 
16 18
 type Props = {};
17 19
 
@@ -22,6 +24,8 @@ type State = {
22 24
     currentTheme: ?Object,
23 25
 };
24 26
 
27
+const Stack = createStackNavigator();
28
+
25 29
 export default class App extends React.Component<Props, State> {
26 30
 
27 31
     state = {
@@ -31,16 +35,9 @@ export default class App extends React.Component<Props, State> {
31 35
         currentTheme: null,
32 36
     };
33 37
 
34
-    onIntroDone: Function;
35
-    loadAssetsAsync: Function;
36
-    onLoadFinished: Function;
37
-
38 38
     constructor(props: Object) {
39 39
         super(props);
40 40
         LocaleManager.initTranslations();
41
-        this.onIntroDone = this.onIntroDone.bind(this);
42
-        this.loadAssetsAsync = this.loadAssetsAsync.bind(this);
43
-        this.onLoadFinished = this.onLoadFinished.bind(this);
44 41
     }
45 42
 
46 43
     /**
@@ -76,19 +73,29 @@ export default class App extends React.Component<Props, State> {
76 73
         AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate5.key, '0');
77 74
     }
78 75
 
76
+    async componentDidMount() {
77
+        await this.loadAssetsAsync();
78
+    }
79
+
79 80
     async loadAssetsAsync() {
80 81
         // Wait for custom fonts to be loaded before showing the app
82
+        console.log("loading Fonts");
83
+        SplashScreen.preventAutoHide();
81 84
         await Font.loadAsync({
82
-            'Roboto': require('native-base/Fonts/Roboto.ttf'),
83 85
             'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
84
-            'material-community': require('native-base/Fonts/MaterialCommunityIcons.ttf'),
85 86
         });
87
+        console.log("loading preferences");
86 88
         await AsyncStorageManager.getInstance().loadPreferences();
87 89
         ThemeManager.getInstance().setUpdateThemeCallback(() => this.updateTheme());
90
+        console.log("loading Expo token");
88 91
         await NotificationsManager.initExpoToken();
92
+        console.log("loaded");
93
+        this.onLoadFinished();
89 94
     }
90 95
 
91 96
     onLoadFinished() {
97
+
98
+        console.log("finished");
92 99
         // Only show intro if this is the first time starting the app
93 100
         this.setState({
94 101
             isLoading: false,
@@ -97,33 +104,30 @@ export default class App extends React.Component<Props, State> {
97 104
             showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1'
98 105
         });
99 106
         // Status bar goes dark if set too fast
100
-        setTimeout(this.setupStatusBar,
101
-            1000
102
-        )
107
+        setTimeout(this.setupStatusBar, 1000);
108
+        SplashScreen.hide();
103 109
     }
104 110
 
105 111
     /**
106 112
      * Renders the app based on loading state
107 113
      */
108 114
     render() {
115
+        console.log("render");
109 116
         if (this.state.isLoading) {
110
-            return (
111
-                <AppLoading
112
-                    startAsync={this.loadAssetsAsync}
113
-                    onFinish={this.onLoadFinished}
114
-                    onError={console.warn}
115
-                />
116
-            );
117
-        }
118
-        if (this.state.showIntro || this.state.showUpdate) {
117
+            return null;
118
+        } else if (this.state.showIntro || this.state.showUpdate) {
119 119
             return <CustomIntroSlider onDone={this.onIntroDone}
120 120
                                       isUpdate={this.state.showUpdate && !this.state.showIntro}/>;
121 121
         } else {
122
-            const AppNavigator = createAppContainerWithInitialRoute(AsyncStorageManager.getInstance().preferences.defaultStartScreen.current);
122
+
123 123
             return (
124 124
                 <Root>
125 125
                     <StyleProvider style={this.state.currentTheme}>
126
-                        <AppNavigator/>
126
+                        <NavigationContainer>
127
+                            <Stack.Navigator headerMode="none">
128
+                                <Stack.Screen name="Root" component={DrawerNavigator} />
129
+                            </Stack.Navigator>
130
+                        </NavigationContainer>
127 131
                     </StyleProvider>
128 132
                 </Root>
129 133
             );

+ 2
- 63
components/BaseContainer.js View File

@@ -4,11 +4,9 @@ import * as React from 'react';
4 4
 import {Container} from "native-base";
5 5
 import CustomHeader from "./CustomHeader";
6 6
 import CustomMaterialIcon from "./CustomMaterialIcon";
7
-import {Platform, StatusBar, View} from "react-native";
7
+import {Platform, View} from "react-native";
8 8
 import ThemeManager from "../utils/ThemeManager";
9 9
 import Touchable from "react-native-platform-touchable";
10
-import {ScreenOrientation} from "expo";
11
-import {NavigationActions} from "react-navigation";
12 10
 
13 11
 
14 12
 type Props = {
@@ -39,81 +37,22 @@ export default class BaseContainer extends React.Component<Props, State> {
39 37
         hideHeaderOnLandscape: false,
40 38
         headerSubtitle: '',
41 39
     };
42
-    willBlurSubscription: function;
43
-    willFocusSubscription: function;
40
+
44 41
     state = {
45 42
         isHeaderVisible: true,
46 43
     };
47 44
 
48 45
     onDrawerPress: Function;
49
-    onWillFocus: Function;
50
-    onWillBlur: Function;
51
-    onChangeOrientation: Function;
52 46
 
53 47
     constructor() {
54 48
         super();
55 49
         this.onDrawerPress = this.onDrawerPress.bind(this);
56
-        this.onWillFocus = this.onWillFocus.bind(this);
57
-        this.onWillBlur = this.onWillBlur.bind(this);
58
-        this.onChangeOrientation = this.onChangeOrientation.bind(this);
59 50
     }
60 51
 
61 52
     onDrawerPress() {
62 53
         this.props.navigation.toggleDrawer();
63 54
     }
64 55
 
65
-    onWillFocus() {
66
-        if (this.props.enableRotation) {
67
-            ScreenOrientation.unlockAsync();
68
-            ScreenOrientation.addOrientationChangeListener(this.onChangeOrientation);
69
-        }
70
-    }
71
-
72
-    onWillBlur() {
73
-        if (this.props.enableRotation)
74
-            ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT);
75
-    }
76
-
77
-    onChangeOrientation(OrientationChangeEvent) {
78
-        if (this.props.hideHeaderOnLandscape) {
79
-            let isLandscape = OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE ||
80
-                OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE_LEFT ||
81
-                OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE_RIGHT;
82
-            this.setState({isHeaderVisible: !isLandscape});
83
-            const setParamsAction = NavigationActions.setParams({
84
-                params: {showTabBar: !isLandscape},
85
-                key: this.props.navigation.state.key,
86
-            });
87
-            this.props.navigation.dispatch(setParamsAction);
88
-            StatusBar.setHidden(isLandscape);
89
-        }
90
-    }
91
-
92
-    /**
93
-     * Register for blur event to close side menu on screen change
94
-     */
95
-    componentDidMount() {
96
-        this.willFocusSubscription = this.props.navigation.addListener(
97
-            'willFocus',
98
-            this.onWillFocus
99
-        );
100
-        this.willBlurSubscription = this.props.navigation.addListener(
101
-            'willBlur',
102
-            this.onWillBlur
103
-        );
104
-    }
105
-
106
-    /**
107
-     * Unregister from event when un-mounting components
108
-     */
109
-    componentWillUnmount() {
110
-        if (this.willBlurSubscription !== undefined)
111
-            this.willBlurSubscription.remove();
112
-        if (this.willFocusSubscription !== undefined)
113
-            this.willFocusSubscription.remove();
114
-    }
115
-
116
-
117 56
     render() {
118 57
         // console.log("rendering BaseContainer");
119 58
         return (

+ 0
- 14
navigation/AppNavigator.js View File

@@ -1,14 +0,0 @@
1
-// @flow
2
-
3
-import {createAppContainer} from 'react-navigation';
4
-import {createDrawerNavigatorWithInitialRoute} from './DrawerNavigator';
5
-
6
-
7
-/**
8
- * Create a stack navigator using the drawer to handle navigation between screens
9
- */
10
-function createAppContainerWithInitialRoute(initialRoute: string) {
11
-    return createAppContainer(createDrawerNavigatorWithInitialRoute(initialRoute));
12
-}
13
-
14
-export {createAppContainerWithInitialRoute};

+ 136
- 55
navigation/DrawerNavigator.js View File

@@ -1,7 +1,8 @@
1 1
 // @flow
2 2
 
3
-import { createDrawerNavigator } from 'react-navigation-drawer';
4
-import {createMaterialBottomTabNavigatorWithInitialRoute} from './MainTabNavigator';
3
+import * as React from 'react';
4
+import {createDrawerNavigator} from '@react-navigation/drawer';
5
+import TabNavigator from './MainTabNavigator';
5 6
 import SettingsScreen from '../screens/SettingsScreen';
6 7
 import AboutScreen from '../screens/About/AboutScreen';
7 8
 import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen';
@@ -15,65 +16,145 @@ import EntScreen from "../screens/Websites/EntScreen";
15 16
 import AvailableRoomScreen from "../screens/Websites/AvailableRoomScreen";
16 17
 import DebugScreen from '../screens/DebugScreen';
17 18
 import Sidebar from "../components/Sidebar";
18
-import {createStackNavigator, TransitionPresets} from "react-navigation-stack";
19
+import {createStackNavigator, TransitionPresets} from "@react-navigation/stack";
19 20
 
20
-const AboutStack = createStackNavigator({
21
-        AboutScreen: {screen: AboutScreen},
22
-        AboutDependenciesScreen: {screen: AboutDependenciesScreen},
23
-        DebugScreen: {screen: DebugScreen},
24
-    },
25
-    {
26
-        initialRouteName: "AboutScreen",
27
-        mode: 'card',
28
-        headerMode: "none",
29
-        defaultNavigationOptions: {
30
-            gestureEnabled: true,
31
-            cardOverlayEnabled: true,
32
-            ...TransitionPresets.SlideFromRightIOS,
33
-        },
34
-    });
21
+const AboutStack = createStackNavigator();
35 22
 
36
-
37
-// Create a stack to use animations
38
-function createDrawerStackWithInitialRoute(initialRoute: string) {
39
-    return createStackNavigator({
40
-            Main: createMaterialBottomTabNavigatorWithInitialRoute(initialRoute),
41
-            SettingsScreen: {screen: SettingsScreen},
42
-            AboutScreen: AboutStack,
43
-            SelfMenuScreen: {screen: SelfMenuScreen},
44
-            TutorInsaScreen: {screen: TutorInsaScreen},
45
-            AmicaleScreen: {screen: AmicaleScreen},
46
-            WiketudScreen: {screen: WiketudScreen},
47
-            ElusEtudScreen: {screen: ElusEtudScreen},
48
-            BlueMindScreen: {screen: BlueMindScreen},
49
-            EntScreen: {screen: EntScreen},
50
-            AvailableRoomScreen: {screen: AvailableRoomScreen},
51
-        },
52
-        {
53
-            initialRouteName: "Main",
54
-            mode: 'card',
55
-            headerMode: "none",
56
-            defaultNavigationOptions: {
23
+function AboutStackComponent() {
24
+    return (
25
+        <AboutStack.Navigator
26
+            initialRouteName="AboutScreen"
27
+            mode='card'
28
+            headerMode="none"
29
+            screenOptions={{
57 30
                 gestureEnabled: true,
58 31
                 cardOverlayEnabled: true,
59 32
                 ...TransitionPresets.SlideFromRightIOS,
60
-            },
61
-        });
33
+            }}
34
+        >
35
+            <AboutStack.Screen
36
+                name="AboutScreen"
37
+                component={AboutScreen}
38
+            />
39
+            <AboutStack.Screen
40
+                name="AboutDependenciesScreen"
41
+                component={AboutDependenciesScreen}
42
+            />
43
+            <AboutStack.Screen
44
+                name="DebugScreen"
45
+                component={DebugScreen}
46
+            />
47
+        </AboutStack.Navigator>
48
+    );
49
+}
50
+
51
+const Drawer = createDrawerNavigator();
52
+
53
+function getDrawerContent(nav) {
54
+    return <Sidebar navigation={nav}/>
62 55
 }
63 56
 
64
-/**
65
- * Creates the drawer navigation stack
66
- */
67
-function createDrawerNavigatorWithInitialRoute(initialRoute: string) {
68
-    return createDrawerNavigator({
69
-        Main: createDrawerStackWithInitialRoute(initialRoute),
70
-    }, {
71
-        contentComponent: Sidebar,
72
-        initialRouteName: 'Main',
73
-        backBehavior: 'initialRoute',
74
-        drawerType: 'front',
75
-        useNativeAnimations: true,
76
-    });
57
+export default function DrawerNavigator() {
58
+    return (
59
+        <Drawer.Navigator
60
+            initialRouteName={'Main'}
61
+            mode='card'
62
+            drawerContent={props => getDrawerContent(props.navigation)}
63
+            screenOptions={{
64
+                gestureEnabled: true,
65
+                cardOverlayEnabled: true,
66
+                ...TransitionPresets.SlideFromRightIOS,
67
+            }}
68
+        >
69
+            <Drawer.Screen
70
+                name="Main"
71
+                component={TabNavigator}
72
+            >
73
+            </Drawer.Screen>
74
+            <Drawer.Screen
75
+                name="SettingsScreen"
76
+                component={SettingsScreen}
77
+            />
78
+            <Drawer.Screen
79
+                name="AboutScreen"
80
+                component={AboutStackComponent}
81
+            />
82
+            <Drawer.Screen
83
+                name="SelfMenuScreen"
84
+                component={SelfMenuScreen}
85
+            />
86
+            <Drawer.Screen
87
+                name="TutorInsaScreen"
88
+                component={TutorInsaScreen}
89
+            />
90
+            <Drawer.Screen
91
+                name="AmicaleScreen"
92
+                component={AmicaleScreen}
93
+            />
94
+            <Drawer.Screen
95
+                name="WiketudScreen"
96
+                component={WiketudScreen}
97
+            />
98
+            <Drawer.Screen
99
+                name="ElusEtudScreen"
100
+                component={ElusEtudScreen}
101
+            />
102
+            <Drawer.Screen
103
+                name="BlueMindScreen"
104
+                component={BlueMindScreen}
105
+            />
106
+            <Drawer.Screen
107
+                name="EntScreen"
108
+                component={EntScreen}
109
+            />
110
+            <Drawer.Screen
111
+                name="AvailableRoomScreen"
112
+                component={AvailableRoomScreen}
113
+            />
114
+        </Drawer.Navigator>
115
+    );
77 116
 }
117
+//
118
+// // Create a stack to use animations
119
+// function createDrawerStackWithInitialRoute(initialRoute: string) {
120
+//     return createStackNavigator({
121
+//             Main: createMaterialBottomTabNavigatorWithInitialRoute(initialRoute),
122
+//             SettingsScreen: {screen: SettingsScreen},
123
+//             AboutScreen: AboutStack,
124
+//             SelfMenuScreen: {screen: SelfMenuScreen},
125
+//             TutorInsaScreen: {screen: TutorInsaScreen},
126
+//             AmicaleScreen: {screen: AmicaleScreen},
127
+//             WiketudScreen: {screen: WiketudScreen},
128
+//             ElusEtudScreen: {screen: ElusEtudScreen},
129
+//             BlueMindScreen: {screen: BlueMindScreen},
130
+//             EntScreen: {screen: EntScreen},
131
+//             AvailableRoomScreen: {screen: AvailableRoomScreen},
132
+//         },
133
+//         {
134
+//             initialRouteName: "Main",
135
+//             mode: 'card',
136
+//             headerMode: "none",
137
+//             defaultNavigationOptions: {
138
+//                 gestureEnabled: true,
139
+//                 cardOverlayEnabled: true,
140
+//                 ...TransitionPresets.SlideFromRightIOS,
141
+//             },
142
+//         });
143
+// }
78 144
 
79
-export {createDrawerNavigatorWithInitialRoute};
145
+// /**
146
+//  * Creates the drawer navigation stack
147
+//  */
148
+// function createDrawerNavigatorWithInitialRoute(initialRoute: string) {
149
+//     return createDrawerNavigator({
150
+//         Main: createDrawerStackWithInitialRoute(initialRoute),
151
+//     }, {
152
+//         contentComponent: Sidebar,
153
+//         initialRouteName: 'Main',
154
+//         backBehavior: 'initialRoute',
155
+//         drawerType: 'front',
156
+//         useNativeAnimations: true,
157
+//     });
158
+// }
159
+//
160
+// export {createDrawerNavigatorWithInitialRoute};

+ 149
- 97
navigation/MainTabNavigator.js View File

@@ -1,6 +1,6 @@
1 1
 import * as React from 'react';
2
-import {createStackNavigator, TransitionPresets} from 'react-navigation-stack';
3
-import {createMaterialBottomTabNavigator} from "react-navigation-material-bottom-tabs";
2
+import {createStackNavigator, TransitionPresets} from '@react-navigation/stack';
3
+import {createMaterialBottomTabNavigator} from "@react-navigation/material-bottom-tabs";
4 4
 
5 5
 import HomeScreen from '../screens/HomeScreen';
6 6
 import PlanningScreen from '../screens/PlanningScreen';
@@ -13,6 +13,11 @@ import ProximoAboutScreen from "../screens/Proximo/ProximoAboutScreen";
13 13
 import PlanexScreen from '../screens/Websites/PlanexScreen';
14 14
 import CustomMaterialIcon from "../components/CustomMaterialIcon";
15 15
 import ThemeManager from "../utils/ThemeManager";
16
+import AboutScreen from "../screens/About/AboutScreen";
17
+import AboutDependenciesScreen from "../screens/About/AboutDependenciesScreen";
18
+import DebugScreen from "../screens/DebugScreen";
19
+import SettingsScreen from "../screens/SettingsScreen";
20
+import AsyncStorageManager from "../utils/AsyncStorageManager";
16 21
 
17 22
 const TAB_ICONS = {
18 23
     Home: 'triangle',
@@ -22,106 +27,153 @@ const TAB_ICONS = {
22 27
     Planex: 'timetable',
23 28
 };
24 29
 
25
-const ProximoStack = createStackNavigator({
26
-        ProximoMainScreen: {screen: ProximoMainScreen},
27
-        ProximoListScreen: {screen: ProximoListScreen},
28
-        ProximoAboutScreen: {
29
-            screen: ProximoAboutScreen,
30
-            navigationOptions: () => ({
31
-                ...TransitionPresets.ModalSlideFromBottomIOS,
32
-            }),
33
-        },
34
-    },
35
-    {
36
-        initialRouteName: "ProximoMainScreen",
37
-        mode: 'card',
38
-        headerMode: "none",
39
-        defaultNavigationOptions: {
40
-            gestureEnabled: true,
41
-            cardOverlayEnabled: true,
42
-            ...TransitionPresets.SlideFromRightIOS,
43
-        },
44
-    });
30
+const ProximoStack = createStackNavigator();
31
+
32
+function ProximoStackComponent() {
33
+    return (
34
+        <ProximoStack.Navigator
35
+            initialRouteName="ProximoMainScreen"
36
+            mode='card'
37
+            headerMode="none"
38
+            screenOptions={{
39
+                gestureEnabled: true,
40
+                cardOverlayEnabled: true,
41
+                ...TransitionPresets.SlideFromRightIOS,
42
+            }}
43
+        >
44
+            <ProximoStack.Screen
45
+                name="ProximoMainScreen"
46
+                component={ProximoMainScreen}
47
+            />
48
+            <ProximoStack.Screen
49
+                name="ProximoListScreen"
50
+                component={ProximoListScreen}
51
+            />
52
+            <ProximoStack.Screen
53
+                name="ProximoAboutScreen"
54
+                component={ProximoAboutScreen}
55
+                options={{
56
+                    ...TransitionPresets.ModalSlideFromBottomIOS,
57
+                }}
58
+            />
59
+        </ProximoStack.Navigator>
60
+    );
61
+}
45 62
 
46
-const ProxiwashStack = createStackNavigator({
47
-        ProxiwashScreen: {screen: ProxiwashScreen},
48
-        ProxiwashAboutScreen: {screen: ProxiwashAboutScreen},
49
-    },
50
-    {
51
-        initialRouteName: "ProxiwashScreen",
52
-        mode: 'card',
53
-        headerMode: "none",
54
-        defaultNavigationOptions: {
55
-            gestureEnabled: true,
56
-            cardOverlayEnabled: true,
57
-            ...TransitionPresets.ModalSlideFromBottomIOS,
58
-        },
59
-    });
63
+const ProxiwashStack = createStackNavigator();
60 64
 
61
-const PlanningStack = createStackNavigator({
62
-        PlanningScreen: {screen: PlanningScreen},
63
-        PlanningDisplayScreen: {screen: PlanningDisplayScreen},
64
-    },
65
-    {
66
-        initialRouteName: "PlanningScreen",
67
-        mode: 'card',
68
-        headerMode: "none",
69
-        defaultNavigationOptions: {
70
-            gestureEnabled: true,
71
-            cardOverlayEnabled: true,
72
-            ...TransitionPresets.ModalSlideFromBottomIOS,
73
-        },
74
-    });
65
+function ProxiwashStackComponent() {
66
+    return (
67
+        <ProxiwashStack.Navigator
68
+            initialRouteName="ProxiwashScreen"
69
+            mode='card'
70
+            headerMode="none"
71
+            screenOptions={{
72
+                gestureEnabled: true,
73
+                cardOverlayEnabled: true,
74
+                ...TransitionPresets.ModalSlideFromBottomIOS,
75
+            }}
76
+        >
77
+            <ProxiwashStack.Screen
78
+                name="ProxiwashScreen"
79
+                component={ProxiwashScreen}
80
+            />
81
+            <ProxiwashStack.Screen
82
+                name="ProxiwashAboutScreen"
83
+                component={ProxiwashAboutScreen}
84
+            />
85
+        </ProxiwashStack.Navigator>
86
+    );
87
+}
75 88
 
76
-const HomeStack = createStackNavigator({
77
-        HomeScreen: {screen: HomeScreen},
78
-        PlanningDisplayScreen: {screen: PlanningDisplayScreen},
79
-    },
80
-    {
81
-        initialRouteName: "HomeScreen",
82
-        mode: 'card',
83
-        headerMode: "none",
84
-        defaultNavigationOptions: {
85
-            gestureEnabled: true,
86
-            cardOverlayEnabled: true,
87
-            ...TransitionPresets.ModalSlideFromBottomIOS,
88
-        },
89
-    });
89
+const PlanningStack = createStackNavigator();
90 90
 
91
-function createMaterialBottomTabNavigatorWithInitialRoute(initialRoute: string) {
92
-    return createMaterialBottomTabNavigator({
93
-        Home: HomeStack,
94
-        Planning: PlanningStack,
95
-        Proxiwash: ProxiwashStack,
96
-        Proximo: ProximoStack,
97
-        Planex: {
98
-            screen: PlanexScreen,
99
-            navigationOptions: ({navigation}) => {
100
-                const showTabBar = navigation.state && navigation.state.params ? navigation.state.params.showTabBar : true;
101
-                return {
102
-                    tabBarVisible: showTabBar,
103
-                };
104
-            },
105
-        },
106
-    }, {
107
-        defaultNavigationOptions: ({navigation}) => ({
108
-            tabBarIcon: ({focused, tintColor}) => {
109
-                let icon = TAB_ICONS[navigation.state.routeName];
110
-                // tintColor is ignoring activeColor et inactiveColor for some reason
111
-                let color = focused ? "#f0edf6" : "#4e1108";
112
-                return <CustomMaterialIcon icon={icon} color={color}/>;
113
-            },
114
-            tabBarVisible: true,
115
-        }),
116
-        order: ['Proximo', 'Planning', 'Home', 'Proxiwash', 'Planex'],
117
-        initialRouteName: initialRoute,
118
-        activeColor: '#f0edf6',
119
-        inactiveColor: '#4e1108',
120
-        backBehavior: 'initialRoute',
121
-        barStyle: {backgroundColor: ThemeManager.getCurrentThemeVariables().brandPrimary},
122
-    });
91
+function PlanningStackComponent() {
92
+    return (
93
+        <PlanningStack.Navigator
94
+            initialRouteName="PlanningScreen"
95
+            mode='card'
96
+            headerMode="none"
97
+            screenOptions={{
98
+                gestureEnabled: true,
99
+                cardOverlayEnabled: true,
100
+                ...TransitionPresets.ModalSlideFromBottomIOS,
101
+            }}
102
+        >
103
+            <PlanningStack.Screen
104
+                name="PlanningScreen"
105
+                component={PlanningScreen}
106
+            />
107
+            <PlanningStack.Screen
108
+                name="PlanningDisplayScreen"
109
+                component={PlanningDisplayScreen}
110
+            />
111
+        </PlanningStack.Navigator>
112
+    );
123 113
 }
124 114
 
115
+const HomeStack = createStackNavigator();
125 116
 
126
-export {createMaterialBottomTabNavigatorWithInitialRoute};
117
+function HomeStackComponent() {
118
+    return (
119
+        <HomeStack.Navigator
120
+            initialRouteName="HomeScreen"
121
+            mode='card'
122
+            headerMode="none"
123
+            screenOptions={{
124
+                gestureEnabled: true,
125
+                cardOverlayEnabled: true,
126
+                ...TransitionPresets.ModalSlideFromBottomIOS,
127
+            }}
128
+        >
129
+            <HomeStack.Screen
130
+                name="HomeScreen"
131
+                component={HomeScreen}
132
+            />
133
+            <HomeStack.Screen
134
+                name="PlanningDisplayScreen"
135
+                component={PlanningDisplayScreen}
136
+            />
137
+        </HomeStack.Navigator>
138
+    );
139
+}
127 140
 
141
+const Tab = createMaterialBottomTabNavigator();
142
+
143
+export default function TabNavigator() {
144
+    return (
145
+        <Tab.Navigator
146
+            initialRouteName={AsyncStorageManager.getInstance().preferences.defaultStartScreen}
147
+            barStyle={{backgroundColor: ThemeManager.getCurrentThemeVariables().brandPrimary}}
148
+            screenOptions={({ route }) => ({
149
+                tabBarIcon: ({ focused, color, size }) => {
150
+                    let icon = TAB_ICONS[route.name];
151
+                    // tintColor is ignoring activeColor and inactiveColor for some reason
152
+                    color = focused ? "#f0edf6" : "#4e1108";
153
+                    return <CustomMaterialIcon icon={icon} color={color}/>;
154
+                },
155
+            })}
156
+        >
157
+            <Tab.Screen
158
+                name="Proximo"
159
+                component={ProximoStackComponent}
160
+            />
161
+            <Tab.Screen
162
+                name="Planning"
163
+                component={PlanningStackComponent}
164
+            />
165
+            <Tab.Screen
166
+                name="Home"
167
+                component={HomeStackComponent}
168
+            />
169
+            <Tab.Screen
170
+                name="Proxiwash"
171
+                component={ProxiwashStackComponent}
172
+            />
173
+            <Tab.Screen
174
+                name="Planex"
175
+                component={PlanexScreen}
176
+            />
177
+        </Tab.Navigator>
178
+    );
179
+}

+ 7
- 6
package.json View File

@@ -9,11 +9,17 @@
9 9
   },
10 10
   "dependencies": {
11 11
     "@react-native-community/masked-view": "0.1.5",
12
+    "@react-navigation/bottom-tabs": "^5.1.1",
13
+    "@react-navigation/drawer": "^5.1.1",
14
+    "@react-navigation/material-bottom-tabs": "^5.1.1",
15
+    "@react-navigation/native": "^5.0.9",
16
+    "@react-navigation/stack": "^5.1.1",
12 17
     "expo": "^36.0.0",
13 18
     "expo-font": "~8.0.0",
14 19
     "expo-linear-gradient": "~8.0.0",
15 20
     "expo-localization": "~8.0.0",
16 21
     "expo-permissions": "~8.0.0",
22
+    "expo-web-browser": "~8.0.0",
17 23
     "i18n-js": "^3.3.0",
18 24
     "native-base": "^2.12.1",
19 25
     "native-base-shoutem-theme": "^0.3.1",
@@ -33,12 +39,7 @@
33 39
     "react-native-safe-area-context": "0.6.0",
34 40
     "react-native-screens": "2.0.0-alpha.12",
35 41
     "react-native-status-bar-height": "^2.3.1",
36
-    "react-native-webview": "7.4.3",
37
-    "react-navigation": "^4.1.0",
38
-    "react-navigation-drawer": "^2.3.3",
39
-    "react-navigation-material-bottom-tabs": "^2.1.5",
40
-    "react-navigation-stack": "^2.1.0",
41
-    "react-navigation-transitions": "^1.0.12"
42
+    "react-native-webview": "7.4.3"
42 43
   },
43 44
   "devDependencies": {
44 45
     "babel-preset-expo": "^8.0.0"

Loading…
Cancel
Save