Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: direktlänkning från knapparna i barnlistan #121

Merged
merged 2 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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