Skip to content

Commit

Permalink
feat: 🎸 Readable news and updated navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanObrink committed Jan 30, 2021
1 parent 1a80f89 commit 5835268
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 33 deletions.
15 changes: 8 additions & 7 deletions packages/app/components/calendar.component.js
Expand Up @@ -19,19 +19,20 @@ export const Calendar = ({ calendar }) => {
? <View style={{ flex: 1 }}>
<Image source={require('../assets/girls.png')} style={{ height: 200, width: '100%' }} />
<Text category='h5'>Det ser lite tomt ut i kalendern</Text>
</View>
</View>
: <List
style={styles.container}
data={calendar.sort((a, b) => b.startDate < a.startDate)}
ItemSeparatorComponent={Divider}
renderItem={renderItem}
/>
style={styles.container}
data={calendar.sort((a, b) => b.startDate < a.startDate)}
ItemSeparatorComponent={Divider}
renderItem={renderItem}
/>
)
}

const styles = StyleSheet.create({
container: {
width: '100%'
width: '100%',
paddingBottom: 330,
},
ongoing: {
color: 'red'
Expand Down
6 changes: 4 additions & 2 deletions packages/app/components/child.component.js
Expand Up @@ -98,7 +98,9 @@ export const Child = ({ route, navigation }) => {
accessoryLeft={BackAction}
accessoryRight={renderRightActions}
style={styles.topBar} />
<TabView selectedIndex={selectedIndex} onSelect={index => setSelectedIndex(index)}>
<TabView
selectedIndex={selectedIndex}
onSelect={index => setSelectedIndex(index)}>
<Tab title="Nyheter" icon={NewsIcon}>
<Layout style={styles.tabContainer}>
<NewsList news={news} />
Expand Down Expand Up @@ -134,11 +136,11 @@ const styles = StyleSheet.create({
backgroundColor: "#fff"
},
tabContainer: {
flexDirection: 'column',
alignItems: 'flex-start',
justifyContent: 'flex-start',
paddingTop: 10,
paddingLeft: 10,
flexDirection: 'column'
},
backdrop: {
backgroundColor: 'rgba(0, 0, 0, 0.5)',
Expand Down
48 changes: 31 additions & 17 deletions packages/app/components/childListItem.component.js
Expand Up @@ -4,16 +4,20 @@ import { DateTime } from 'luxon'
import { useNotifications, useNews, useClassmates, useCalendar, useSchedule } from '@skolplattformen/react-native-embedded-api'
import { Button, Icon, Text, Card, Avatar } from '@ui-kitten/components'

const NotificationIcon = (style) => (
<Icon {...style} name='activity-outline' />
const NotificationsIcon = (props) => (
<Icon {...props} name='alert-circle-outline' />
)

const CalendarIcon = (style) => (
<Icon {...style} name='calendar-outline' />
const NewsIcon = (props) => (
<Icon {...props} name='activity-outline' />
)

const PeopleIcon = (style) => (
<Icon {...style} name='people-outline' />
const CalendarIcon = (props) => (
<Icon {...props} name='calendar-outline' />
)

const PeopleIcon = (props) => (
<Icon {...props} name='people-outline' />
)

export const ChildListItem = ({ navigation, child, color }) => {
Expand Down Expand Up @@ -56,28 +60,36 @@ export const ChildListItem = ({ navigation, child, color }) => {
const Footer = (props, info) => (
<View style={styles.itemFooter}>
<Button
style={styles[notificationsStatus]}
style={[styles.item, styles[newsStatus]]}
status='control'
size='small'
accessoryLeft={NewsIcon}
>
{`${(news || []).length}`}
</Button>
<Button
style={[styles.item, styles[notificationsStatus]]}
status='control'
size='small'
accessoryLeft={NotificationIcon}
accessoryLeft={NotificationsIcon}
>
{`${(news || []).length}`} nyheter
{`${(notifications || []).length}`}
</Button>
<Button
style={styles[calendarStatus]}
style={[styles.item, styles[calendarStatus]]}
status='control'
size='small'
accessoryLeft={CalendarIcon}
>
{`${(notifications || []).length}`}
</Button>
<Button
style={styles[classmatesStatus]}
style={[styles.item, styles[classmatesStatus]]}
status='control'
size='small'
accessoryLeft={PeopleIcon}
>
{`${(classmates || []).length} elever`}
{`${(classmates || []).length}`}
</Button>
</View>
)
Expand Down Expand Up @@ -107,20 +119,22 @@ const styles = StyleSheet.create({
},
itemFooter: {
flexDirection: 'row',
paddingHorizontal: 10,
justifyContent: 'space-evenly',
paddingHorizontal: 5,
paddingVertical: 5,
borderRadius: 5,
margin: 0
},
loaded: {
item: {
paddingHorizontal: 0,
},
loaded: {
color: '#000'
},
loading: {
paddingHorizontal: 0,
color: '#555'
}, error: {
paddingHorizontal: 0,
},
error: {
color: '#500'
}
})
5 changes: 4 additions & 1 deletion packages/app/components/newsList.component.js
Expand Up @@ -18,8 +18,11 @@ export const NewsList = ({ news }) => {


const styles = StyleSheet.create({
container: {},
container: {
width: '100%',
},
contentContainer: {
alignItems: 'stretch',
paddingRight: 10,
paddingBottom: 330
}
Expand Down
16 changes: 11 additions & 5 deletions packages/app/components/notification.component.js
Expand Up @@ -2,26 +2,32 @@ import React, { useState } from 'react'
import { Card, Text } from '@ui-kitten/components'
import { StyleSheet, View } from 'react-native'
import { ModalWebView } from './modalWebView.component'
import { DateTime } from 'luxon'

export const Notification = ({ item }) => {
const [isOpen, setIsOpen] = useState(false)
const open = () => setIsOpen(true)
const close = () => setIsOpen(false)

const displayDate = DateTime
.fromISO(item.dateCreated)
.toRelative({ locale: 'sv' })

return (
<>
<Card
style={styles.card}
onPress={open}
header={(headerProps) => (
<View {...headerProps} >
<Text category='h6'>{item.sender}</Text>
{item.category && (
<Text category='s1'>{item.category}</Text>
)}
<Text>{item.message}</Text>
<Text category="h6">{item.sender}</Text>
<Text category="s1">
{item.category ? `${item.category} ` : ''}
({displayDate})
</Text>
</View>
)}>
<Text>{item.message}</Text>
</Card>
{isOpen && (
<ModalWebView url={item.url} onClose={close} />
Expand Down
5 changes: 4 additions & 1 deletion packages/app/components/notificationsList.component.js
Expand Up @@ -18,8 +18,11 @@ export const NotificationsList = ({ notifications, status }) => {


const styles = StyleSheet.create({
container: {},
container: {
width: '100%'
},
contentContainer: {
alignItems: 'stretch',
paddingRight: 10,
paddingBottom: 330
}
Expand Down
18 changes: 18 additions & 0 deletions packages/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/app/package.json
Expand Up @@ -45,6 +45,7 @@
"@babel/core": "^7.12.10",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"@types/luxon": "^1.25.1",
"@types/react": "^16.8.24",
"@types/react-native": "^0.63.43",
"@ui-kitten/metro-config": "5.0.0",
Expand Down

0 comments on commit 5835268

Please sign in to comment.