Browse Source

Fix startup crash

Arnaud Vergnet 2 years ago
parent
commit
7d0df0e7ce
2 changed files with 21 additions and 14 deletions
  1. 19
    12
      src/navigation/MainNavigator.tsx
  2. 2
    2
      src/navigation/TabNavigator.tsx

+ 19
- 12
src/navigation/MainNavigator.tsx View File

115
   );
115
   );
116
 }
116
 }
117
 
117
 
118
-function MainStackComponent(props: {
119
-  showIntro: boolean;
120
-  createTabNavigator: () => React.ReactElement;
121
-}) {
122
-  const { showIntro, createTabNavigator } = props;
123
-  if (showIntro) {
124
-    return getIntroScreens();
125
-  }
118
+function getRegularScreens(createTabNavigator: () => React.ReactElement) {
126
   return (
119
   return (
127
-    <MainStack.Navigator
128
-      initialRouteName={showIntro ? MainRoutes.Intro : MainRoutes.Main}
129
-      headerMode={'screen'}
130
-    >
120
+    <>
131
       <MainStack.Screen
121
       <MainStack.Screen
132
         name={MainRoutes.Main}
122
         name={MainRoutes.Main}
133
         component={createTabNavigator}
123
         component={createTabNavigator}
303
           title: i18n.t('screens.feedback.title'),
293
           title: i18n.t('screens.feedback.title'),
304
         }}
294
         }}
305
       />
295
       />
296
+    </>
297
+  );
298
+}
299
+
300
+function MainStackComponent(props: {
301
+  showIntro: boolean;
302
+  createTabNavigator: () => React.ReactElement;
303
+}) {
304
+  const { showIntro, createTabNavigator } = props;
305
+  return (
306
+    <MainStack.Navigator
307
+      initialRouteName={showIntro ? MainRoutes.Intro : MainRoutes.Main}
308
+      headerMode={'screen'}
309
+    >
310
+      {showIntro ? getIntroScreens() : getRegularScreens(createTabNavigator)}
306
     </MainStack.Navigator>
311
     </MainStack.Navigator>
307
   );
312
   );
308
 }
313
 }
315
 export default function MainNavigator(props: PropsType) {
320
 export default function MainNavigator(props: PropsType) {
316
   const { preferences } = usePreferences();
321
   const { preferences } = usePreferences();
317
   const showIntro = getPreferenceBool(PreferenceKeys.showIntro, preferences);
322
   const showIntro = getPreferenceBool(PreferenceKeys.showIntro, preferences);
323
+  console.log(preferences);
324
+
318
   return (
325
   return (
319
     <MainStackComponent
326
     <MainStackComponent
320
       showIntro={showIntro !== false}
327
       showIntro={showIntro !== false}

+ 2
- 2
src/navigation/TabNavigator.tsx View File

254
     normal: '',
254
     normal: '',
255
     focused: '',
255
     focused: '',
256
   },
256
   },
257
-  planning: {
257
+  events: {
258
     normal: 'calendar-range-outline',
258
     normal: 'calendar-range-outline',
259
     focused: 'calendar-range',
259
     focused: 'calendar-range',
260
   },
260
   },
285
     services: i18n.t('screens.services.title'),
285
     services: i18n.t('screens.services.title'),
286
     proxiwash: i18n.t('screens.proxiwash.title'),
286
     proxiwash: i18n.t('screens.proxiwash.title'),
287
     home: i18n.t('screens.home.title'),
287
     home: i18n.t('screens.home.title'),
288
-    planning: i18n.t('screens.planning.title'),
288
+    events: i18n.t('screens.planning.title'),
289
     planex: i18n.t('screens.planex.title'),
289
     planex: i18n.t('screens.planex.title'),
290
   };
290
   };
291
   return (
291
   return (

Loading…
Cancel
Save