Skip to content

Commit

Permalink
chore: Refactored loading of data to an abstract component instead
Browse files Browse the repository at this point in the history
  • Loading branch information
irony committed Dec 31, 2020
1 parent fe836e1 commit f6b3946
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/app/components/childrenLoader.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
import moment from 'moment'
import { useAsyncStorage } from 'use-async-storage'
import { api, fillChild } from '../lib/backend'
import { ChildrenView } from './children.component'
import { ChildrenView } from './childrenView.component'

export const ChildrenLoader = ({ navigation }) => {
const [cache, setCache] = useAsyncStorage('@children', [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const PeopleIcon = (style) => (
<Icon {...style} name='people-outline' />
)

export const ChildrenView = ({ navigation, childList, eva }) => {
export const ChildrenView = ({ navigation, childList }) => {
const abbrevations = {
G: 'Gymnasiet', // ? i'm guessing here
GR: 'Grundskolan',
Expand Down Expand Up @@ -106,7 +106,7 @@ export const ChildrenView = ({ navigation, childList, eva }) => {
}

return (
<SafeAreaView style={{ flex: 1, backgroundColor: 'transparent' }}>
<SafeAreaView style={{ flex: 1, backgroundColor: '#fff' }}>
<TopNavigation title='Dina barn' alignment='center' accessoryLeft={BackAction} />
<Divider />
<Layout style={{ flex: 1 }} level='1'>
Expand Down
4 changes: 1 addition & 3 deletions packages/app/components/login.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { Platform, SafeAreaView, StyleSheet, Image, Linking, KeyboardAvoidingVie
import { Button, Icon, Modal, Card, Text, ImageBackground, Divider, Layout, TopNavigation, Input } from '@ui-kitten/components'
import Personnummer from 'personnummer'
import { useAsyncStorage } from 'use-async-storage'
import { ScrollView } from 'react-native-gesture-handler'
import { api } from '../lib/backend'

const baseUrl = 'https://api.skolplattformen.org'
const funArguments = ['öppna', 'roliga', 'fungerande', 'billiga', 'snabba', 'fria', 'efterlängtade', 'coolare', 'första', 'upplysta', 'hemmagjorda', 'bättre', 'rebelliska', 'enkla', 'operfekta', 'fantastiska', 'agila'] // TODO: add moare

export const Login = ({ navigation, route }) => {
Expand All @@ -19,7 +17,7 @@ export const Login = ({ navigation, route }) => {
const [hasBankId, setHasBankId] = React.useState(false)
const [socialSecurityNumber, setSocialSecurityNumber] = useAsyncStorage('@socialSecurityNumber')
const [cookie, setCookie] = useAsyncStorage('@cookie')
const [children, setChildren] = useAsyncStorage('@children', [])
const [_, setChildren] = useAsyncStorage('@children', [])

useEffect(() => {
setValid(Personnummer.valid(socialSecurityNumber))
Expand Down
17 changes: 9 additions & 8 deletions packages/app/components/navigation.component.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import { StatusBar} from 'react-native'
import { StatusBar } from 'react-native'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import { Login } from './login.component'
import { Children } from './children.component'
import { ChildrenLoader } from './childrenLoader.component'
import { Child } from './child.component'
import { NewsItem } from './newsItem.component'

Expand All @@ -12,16 +12,17 @@ const { Navigator, Screen } = createStackNavigator()
const HomeNavigator = () => (
<Navigator headerMode='none'>
<Screen name='Login' component={Login} />
<Screen name='Children' component={Children} />
<Screen name='Children' component={ChildrenLoader} />
<Screen name='Child' component={Child} />
<Screen name='NewsItem' component={NewsItem} />
</Navigator>
)

export const AppNavigator = () => {
return <NavigationContainer>
<StatusBar />

<HomeNavigator/>
</NavigationContainer>
return (
<NavigationContainer>
<StatusBar />
<HomeNavigator />
</NavigationContainer>
)
}

0 comments on commit f6b3946

Please sign in to comment.