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: scroll i barnlistan och flytta frånvaroknapp #167

Merged
merged 1 commit into from
Feb 21, 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
146 changes: 72 additions & 74 deletions packages/app/components/childListItem.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,78 +74,68 @@ export const ChildListItem = ({ navigation, child, color }) => {
)

const Footer = () => (
<>
<View style={styles.itemFooter}>
<Button
style={[styles.item, styles[newsStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Nyheter',
})
}
accessoryLeft={NewsIcon}
>
{`${(news || []).length}`}
</Button>
<Button
style={[styles.item, styles[notificationsStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Notifieringar',
})
}
accessoryLeft={NotificationsIcon}
>
{`${(notifications || []).length}`}
</Button>
<Button
style={[styles.item, styles[calendarStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Kalender',
})
}
accessoryLeft={CalendarOutlineIcon}
>
{`${(notifications || []).length}`}
</Button>
<Button
style={[styles.item, styles[classmatesStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Klassen',
})
}
accessoryLeft={ClassIcon}
>
{`${(classmates || []).length}`}
</Button>
</View>
<View style={styles.itemFooterAbsence}>
<Button
size="small"
onPress={() => navigation.navigate('Absence', { child })}
>
Anmäl frånvaro
</Button>
</View>
</>
<View style={styles.itemFooter}>
<Button
style={[styles.item, styles[newsStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Nyheter',
})
}
accessoryLeft={NewsIcon}
>
{`${(news || []).length}`}
</Button>
<Button
style={[styles.item, styles[notificationsStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Notifieringar',
})
}
accessoryLeft={NotificationsIcon}
>
{`${(notifications || []).length}`}
</Button>
<Button
style={[styles.item, styles[calendarStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Kalender',
})
}
accessoryLeft={CalendarOutlineIcon}
>
{`${(notifications || []).length}`}
</Button>
<Button
style={[styles.item, styles[classmatesStatus]]}
status="control"
size="small"
onPress={() =>
navigation.navigate('Child', {
child,
color,
initialRouteName: 'Klassen',
})
}
accessoryLeft={ClassIcon}
>
{`${(classmates || []).length}`}
</Button>
</View>
)

return (
Expand Down Expand Up @@ -178,6 +168,14 @@ export const ChildListItem = ({ navigation, child, color }) => {
Inga nya inlägg denna vecka.
</Text>
)}
<View style={styles.itemFooterAbsence}>
<Button
size="small"
onPress={() => navigation.navigate('Absence', { child })}
>
Anmäl frånvaro
</Button>
</View>
</Card>
)
}
Expand All @@ -194,8 +192,8 @@ const styles = StyleSheet.create({
margin: 0,
},
itemFooterAbsence: {
alignItems: 'flex-end',
padding: 8,
alignItems: 'flex-start',
marginTop: 16,
},
item: {
paddingHorizontal: 0,
Expand Down
92 changes: 41 additions & 51 deletions packages/app/components/children.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,60 +34,52 @@ export const Children = ({ navigation }) => {
accessoryLeft={BackAction}
/>
<Divider />
<Layout style={styles.fullFlex}>
{status === 'loaded' ? (
<Layout style={styles.childListWrap}>
<List
contentContainerStyle={styles.childList}
data={childList}
ListEmptyComponent={
<View style={styles.emptyState}>
<Text category="h2">Inga barn</Text>
<Text style={styles.emptyStateDescription}>
Det finns inga barn registrerade för ditt personnummer i
Stockholms Stad
</Text>
<Image
source={require('../assets/children.png')}
style={styles.emptyStateImage}
/>
</View>
}
renderItem={({ item: child, index }) => {
return (
<ChildListItem
child={child}
color={colors[index % colors.length]}
key={child.id}
navigation={navigation}
/>
)
}}
/>
</Layout>
) : (
<Layout style={styles.loading}>
<Image
source={require('../assets/girls.png')}
style={styles.loadingImage}
/>
<View style={styles.loadingMessage}>
<Spinner size="large" status="warning" />
<Text category="h1" style={styles.loadingText}>
Laddar...
{status === 'loaded' ? (
<List
contentContainerStyle={styles.childListContainer}
data={childList}
style={styles.childList}
ListEmptyComponent={
<View style={styles.emptyState}>
<Text category="h2">Inga barn</Text>
<Text style={styles.emptyStateDescription}>
Det finns inga barn registrerade för ditt personnummer i
Stockholms Stad
</Text>
<Image
source={require('../assets/children.png')}
style={styles.emptyStateImage}
/>
</View>
</Layout>
)}
</Layout>
}
renderItem={({ item: child, index }) => (
<ChildListItem
child={child}
color={colors[index % colors.length]}
key={child.id}
navigation={navigation}
/>
)}
/>
) : (
<Layout style={styles.loading}>
<Image
source={require('../assets/girls.png')}
style={styles.loadingImage}
/>
<View style={styles.loadingMessage}>
<Spinner size="large" status="warning" />
<Text category="h1" style={styles.loadingText}>
Laddar...
</Text>
</View>
</Layout>
)}
</SafeAreaView>
)
}

const styles = StyleSheet.create({
fullFlex: {
flex: 1,
},
topContainer: {
flex: 1,
backgroundColor: '#fff',
Expand All @@ -109,12 +101,10 @@ const styles = StyleSheet.create({
loadingText: {
marginLeft: 20,
},
childListWrap: {
flex: 1,
justifyContent: 'flex-start',
},
childList: {
flex: 1,
},
childListContainer: {
padding: 20,
},
emptyState: {
Expand Down