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/menu format #661

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions apps/skolplattformen-app/components/__tests__/Menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jest.mock('@skolplattformen/hooks')

const defaultItemList = [
{
title: 'Måndag vecka 10',
title: 'Måndag',
description: 'Krämiga köttbullar',
},
{
title: 'Tisdag vecka 10',
title: 'Tisdag',
description: 'Kryddig falukorv',
},
{
title: 'Onsdag vecka 10',
title: 'Onsdag',
description: 'Sushi',
},
]
Expand All @@ -32,15 +32,15 @@ const setup = (itemList = defaultItemList) => {
test('renders multiple days', () => {
const screen = setup()

expect(screen.getByText('Måndag vecka 10')).toBeTruthy()
expect(screen.getByText('Tisdag vecka 10')).toBeTruthy()
expect(screen.getByText('Onsdag vecka 10')).toBeTruthy()
expect(screen.getByText('Måndag')).toBeTruthy()
expect(screen.getByText('Tisdag')).toBeTruthy()
expect(screen.getByText('Onsdag')).toBeTruthy()
})

test('renders title and description', () => {
const screen = setup()

expect(screen.getByText('Måndag vecka 10')).toBeTruthy()
expect(screen.getByText('Måndag')).toBeTruthy()
expect(screen.getByText('Krämiga köttbullar')).toBeTruthy()
})

Expand Down
61 changes: 37 additions & 24 deletions apps/skolplattformen-app/components/menu.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,42 @@ export const Menu = () => {
const styles = useStyleSheet(themedStyles)
const child = useChild()
const { data, status, reload } = useMenu(child)
const weekNr = data[0]?.title.split('Vecka')[1] ?? ''

return (
<List
contentContainerStyle={styles.contentContainer}
data={data}
ItemSeparatorComponent={Divider}
ListEmptyComponent={
<View style={styles.emptyState}>
<Text category="h4">{translate('menu.emptyHeadline')}</Text>
<Text style={styles.emptyStateDescription}>
{translate('menu.emptyText')}
</Text>
<Image
accessibilityIgnoresInvertColors={false}
source={require('../assets/children.png')}
style={styles.emptyStateImage as ImageStyle}
<>
<Text category="h5" style={styles.listHeader}>
{`${translate('menu.week')} ${weekNr}`}
</Text>
<List
contentContainerStyle={styles.contentContainer}
data={data}
ItemSeparatorComponent={Divider}
ListEmptyComponent={
<View style={styles.emptyState}>
<Text category="h4">{translate('menu.emptyHeadline')}</Text>
<Text style={styles.emptyStateDescription}>
{translate('menu.emptyText')}
</Text>
<Image
accessibilityIgnoresInvertColors={false}
source={require('../assets/children.png')}
style={styles.emptyStateImage as ImageStyle}
/>
</View>
}
renderItem={({ item }: ListRenderItemInfo<MenuItem>) => (
<MenuListItem key={item.title} item={item} />
)}
style={styles.container}
refreshControl={
<RefreshControl
refreshing={status === 'loading'}
onRefresh={reload}
/>
</View>
}
renderItem={({ item }: ListRenderItemInfo<MenuItem>) => (
<MenuListItem key={item.title} item={item} />
)}
style={styles.container}
refreshControl={
<RefreshControl refreshing={status === 'loading'} onRefresh={reload} />
}
/>
}
/>
</>
)
}

Expand Down Expand Up @@ -81,4 +90,8 @@ const themedStyles = StyleService.create({
...Sizing.aspectRatio(0.8),
marginTop: 50,
},
listHeader: {
paddingTop: 10,
paddingLeft: 15,
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ import { StyleService, Text, useStyleSheet } from '@ui-kitten/components'
import React from 'react'
import { View } from 'react-native'
import { Sizing, Typography } from '../styles'
import { translate } from '../utils/translation'

interface MenuListItemProps {
item: MenuItem
}

export const MenuListItem = ({ item }: MenuListItemProps) => {
const styles = useStyleSheet(themedStyles)
const day = item.title.split(' ')[0]
return (
<View style={styles.container}>
<Text style={styles.title}>{item.title}</Text>
<Text style={styles.title}>{translate(`menu.${day}`)}</Text>
<Text category="p1">{item.description}</Text>
</View>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export const NavigationTitle = ({ title, subtitle }: NavigationTitleProps) => {
{title}
</Text>
)}
{subtitle && <Text style={styles.subtitle}>{subtitle}</Text>}
{subtitle && (
<Text style={styles.subtitle}>
{subtitle.substring(0, subtitle.indexOf(' '))}
</Text>
)}
</View>
)
}
Expand All @@ -32,5 +36,5 @@ const styles = StyleSheet.create({
...fontSize.sm,
fontWeight: '500',
},
subtitle: { ...fontSize.xxs },
subtitle: { ...fontSize.base },
})
6 changes: 6 additions & 0 deletions apps/skolplattformen-app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
"changeLanguageButton": "Save"
},
"menu": {
"Måndag":"Monday",
"Tisdag": "Tuesday",
"Onsdag": "Wednesday",
"Torsdag": "Thursday",
"Fredag": "Friday",
"week": "Week",
"emptyHeadline": "The lunch menu looks kinda empty",
"emptyText": "Couldn't find anything for this week"
},
Expand Down
6 changes: 6 additions & 0 deletions apps/skolplattformen-app/translations/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@
"changeLanguageButton": "Spara"
},
"menu": {
"Måndag":"Måndag",
"Tisdag": "Tisdag",
"Onsdag": "Onsdag",
"Torsdag": "Torsdag",
"Fredag": "Fredag",
"week": "Vecka",
"emptyHeadline": "Det ser lite tomt ut i matsedeln",
"emptyText": "Hittade ingenting att visa för den här veckan"
},
Expand Down
Loading