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

View file

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