Fix startup crash

This commit is contained in:
Arnaud Vergnet 2021-05-18 18:31:18 +02:00
parent 00f9428972
commit 7d0df0e7ce
2 changed files with 21 additions and 14 deletions

View file

@ -115,19 +115,9 @@ function getIntroScreens() {
);
}
function MainStackComponent(props: {
showIntro: boolean;
createTabNavigator: () => React.ReactElement;
}) {
const { showIntro, createTabNavigator } = props;
if (showIntro) {
return getIntroScreens();
}
function getRegularScreens(createTabNavigator: () => React.ReactElement) {
return (
<MainStack.Navigator
initialRouteName={showIntro ? MainRoutes.Intro : MainRoutes.Main}
headerMode={'screen'}
>
<>
<MainStack.Screen
name={MainRoutes.Main}
component={createTabNavigator}
@ -303,6 +293,21 @@ function MainStackComponent(props: {
title: i18n.t('screens.feedback.title'),
}}
/>
</>
);
}
function MainStackComponent(props: {
showIntro: boolean;
createTabNavigator: () => React.ReactElement;
}) {
const { showIntro, createTabNavigator } = props;
return (
<MainStack.Navigator
initialRouteName={showIntro ? MainRoutes.Intro : MainRoutes.Main}
headerMode={'screen'}
>
{showIntro ? getIntroScreens() : getRegularScreens(createTabNavigator)}
</MainStack.Navigator>
);
}
@ -315,6 +320,8 @@ type PropsType = {
export default function MainNavigator(props: PropsType) {
const { preferences } = usePreferences();
const showIntro = getPreferenceBool(PreferenceKeys.showIntro, preferences);
console.log(preferences);
return (
<MainStackComponent
showIntro={showIntro !== false}

View file

@ -254,7 +254,7 @@ const ICONS: {
normal: '',
focused: '',
},
planning: {
events: {
normal: 'calendar-range-outline',
focused: 'calendar-range',
},
@ -285,7 +285,7 @@ export default function TabNavigator(props: PropsType) {
services: i18n.t('screens.services.title'),
proxiwash: i18n.t('screens.proxiwash.title'),
home: i18n.t('screens.home.title'),
planning: i18n.t('screens.planning.title'),
events: i18n.t('screens.planning.title'),
planex: i18n.t('screens.planex.title'),
};
return (