Skip to content

Commit

Permalink
feat: 🎸 Added food menu to features
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorlarsson committed Nov 22, 2021
1 parent ce05682 commit bec62fa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 28 deletions.
81 changes: 55 additions & 26 deletions apps/skolplattformen-sthlm/components/child.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'>
Expand All @@ -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}
Expand Down Expand Up @@ -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>
)

Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion apps/skolplattformen-sthlm/components/login.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const Login = () => {
return (
<>
<View style={styles.loginForm}>
{loginMethodIndex === 1 && (
{loginMethodIndex === 0 && (
<Input
accessible={true}
label={t('general.socialSecurityNumber')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion libs/api-hjarntorget/lib/features.ts
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions libs/api/lib/features.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface Features {
LOGIN_BANK_ID_SAME_DEVICE: boolean;
FOOD_MENU: boolean;
}

export type FeatureType = keyof Features;

0 comments on commit bec62fa

Please sign in to comment.