Skip to content

Commit

Permalink
Merge pull request #121 from kolplattformen/fix/child-screen-links
Browse files Browse the repository at this point in the history
fix: direktlänkning från knapparna i barnlistan
  • Loading branch information
JohanObrink committed Feb 15, 2021
2 parents 7b60769 + da2892c commit a2700c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
12 changes: 7 additions & 5 deletions packages/app/components/child.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,19 @@ const TopTabBar = ({ navigation, state }) => (
</TabBar>
)

const TabNavigator = () => (
<Navigator tabBar={(props) => <TopTabBar {...props} />}>
const TabNavigator = ({initialRouteName = 'Nyheter'}) => (
<Navigator
initialRouteName={initialRouteName}
tabBar={(props) => <TopTabBar {...props} />}>
<Screen name="Nyheter" component={NewsScreen} />
<Screen name="Notifieringar" component={NotificationsScreen} />
<Screen name="Kalender" component={CalendarScreen} />
<Screen name="Klassen" component={ClassmatesScreen} />
</Navigator>
)

export const Child = ({ route, navigation }) => {
const { child, color } = route.params
export const Child = ({route, navigation}) => {
const {child, color, initialRouteName} = route.params

const BackIcon = (props) => <Icon {...props} name="arrow-back" />

Expand All @@ -148,7 +150,7 @@ export const Child = ({ route, navigation }) => {
accessoryLeft={BackAction}
style={styles.topBar}
/>
<TabNavigator />
<TabNavigator initialRouteName={initialRouteName} />
</ChildProvider>
</SafeAreaView>
)
Expand Down
24 changes: 20 additions & 4 deletions packages/app/components/childListItem.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ export const ChildListItem = ({ navigation, child, color }) => {
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', { child, color, selectedTab: 0 })
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Nyheter',
})
}
accessoryLeft={NewsIcon}>
{`${(news || []).length}`}
Expand All @@ -86,7 +90,11 @@ export const ChildListItem = ({ navigation, child, color }) => {
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', { child, color, selectedTab: 1 })
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Notifieringar',
})
}
accessoryLeft={NotificationsIcon}>
{`${(notifications || []).length}`}
Expand All @@ -96,7 +104,11 @@ export const ChildListItem = ({ navigation, child, color }) => {
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', { child, color, selectedTab: 2 })
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Kalender',
})
}
accessoryLeft={CalendarIcon}>
{`${(notifications || []).length}`}
Expand All @@ -106,7 +118,11 @@ export const ChildListItem = ({ navigation, child, color }) => {
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', { child, color, selectedTab: 3 })
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Klassen',
})
}
accessoryLeft={PeopleIcon}>
{`${(classmates || []).length}`}
Expand Down

0 comments on commit a2700c9

Please sign in to comment.