feat: 🎸 Added food menu to features

This commit is contained in:
Viktor Sarström 2021-11-22 13:00:32 +01:00
parent ce056821a1
commit bec62fa21b
5 changed files with 60 additions and 28 deletions

View File

@ -22,6 +22,7 @@ import { NewsList } from './newsList.component'
import { NotificationsList } from './notificationsList.component'
import { Classmates } from './classmates.component'
import { TabBarLabel } from './tabBarLabel.component'
import { useFeature } from '../hooks/useFeature'
type ChildNavigationProp = StackNavigationProp<RootStackParamList, 'Child'>
type ChildRouteProps = RouteProp<RootStackParamList, 'Child'>
@ -47,10 +48,20 @@ const CalendarScreen = () => <Calendar />
const MenuScreen = () => <Menu />
const ClassmatesScreen = () => <Classmates />
interface ScreenSettings {
NEWS_SCREEN: boolean
NOTIFICATIONS_SCREEN: boolean
CALENDER_SCREEN: boolean
MENU_SCREEN: boolean
CLASSMATES_SCREEN: boolean
}
const TabNavigator = ({
initialRouteName = 'News',
screenSettings,
}: {
initialRouteName?: keyof ChildTabParamList
screenSettings: ScreenSettings
}) => (
<Navigator
initialRouteName={initialRouteName}
@ -80,31 +91,41 @@ const TabNavigator = ({
}
}}
>
<Screen
name="News"
component={NewsScreen}
options={{ title: translate('navigation.news') }}
/>
<Screen
name="Notifications"
component={NotificationsScreen}
options={{ title: translate('navigation.notifications') }}
/>
<Screen
name="Calendar"
component={CalendarScreen}
options={{ title: translate('navigation.calender') }}
/>
<Screen
name="Menu"
component={MenuScreen}
options={{ title: translate('navigation.menu') }}
/>
<Screen
name="Classmates"
component={ClassmatesScreen}
options={{ title: translate('navigation.classmates') }}
/>
{screenSettings.NEWS_SCREEN && (
<Screen
name="News"
component={NewsScreen}
options={{ title: translate('navigation.news') }}
/>
)}
{screenSettings.NOTIFICATIONS_SCREEN && (
<Screen
name="Notifications"
component={NotificationsScreen}
options={{ title: translate('navigation.notifications') }}
/>
)}
{screenSettings.CALENDER_SCREEN && (
<Screen
name="Calendar"
component={CalendarScreen}
options={{ title: translate('navigation.calender') }}
/>
)}
{screenSettings.MENU_SCREEN && (
<Screen
name="Menu"
component={MenuScreen}
options={{ title: translate('navigation.menu') }}
/>
)}
{screenSettings.CLASSMATES_SCREEN && (
<Screen
name="Classmates"
component={ClassmatesScreen}
options={{ title: translate('navigation.classmates') }}
/>
)}
</Navigator>
)
@ -151,16 +172,24 @@ export const childRouteOptions =
export const Child = () => {
const route = useRoute<ChildRouteProps>()
const { child, initialRouteName } = route.params
const useFoodMenu = useFeature('FOOD_MENU')
const navigation = useNavigation()
useEffect(() => {
navigation.setOptions({ title: getHeaderTitle(route) })
}, [navigation, route])
const screenSettings: ScreenSettings = {
NEWS_SCREEN: true,
NOTIFICATIONS_SCREEN: true,
CALENDER_SCREEN: true,
MENU_SCREEN: useFoodMenu,
CLASSMATES_SCREEN: true,
}
return (
<ChildProvider child={child}>
<TabNavigator
screenSettings={screenSettings}
initialRouteName={initialRouteName as keyof ChildTabParamList}
/>
</ChildProvider>

View File

@ -157,7 +157,7 @@ export const Login = () => {
return (
<>
<View style={styles.loginForm}>
{loginMethodIndex === 1 && (
{loginMethodIndex === 0 && (
<Input
accessible={true}
label={t('general.socialSecurityNumber')}

View File

@ -3,6 +3,7 @@ import React from 'react'
export const FeatureFlagsContext = React.createContext<Features>({
LOGIN_BANK_ID_SAME_DEVICE: false,
FOOD_MENU: false,
})
interface Props {

View File

@ -1,5 +1,6 @@
import { Features } from '@skolplattformen/api'
export const features: Features = {
LOGIN_BANK_ID_SAME_DEVICE: false
LOGIN_BANK_ID_SAME_DEVICE: false,
FOOD_MENU: false
}

View File

@ -1,5 +1,6 @@
export interface Features {
LOGIN_BANK_ID_SAME_DEVICE: boolean;
FOOD_MENU: boolean;
}
export type FeatureType = keyof Features;