Add mock API and reorg code for clarity

This commit is contained in:
Paul Frazee 2022-07-18 15:24:37 -05:00
parent de87ec17d1
commit 1d00f3b984
29 changed files with 356 additions and 168 deletions

View file

@ -1,21 +0,0 @@
import React from 'react'
import {Text, Button, View} from 'react-native'
import {Shell} from '../platform/shell'
import type {RootTabsScreenProps} from '../routes/types'
import {useStores} from '../state'
export function Home({navigation}: RootTabsScreenProps<'Home'>) {
const store = useStores()
return (
<Shell>
<View style={{alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Home</Text>
<Button
title="Go to Jane's profile"
onPress={() => navigation.navigate('Profile', {name: 'Jane'})}
/>
<Button title="Logout" onPress={() => store.session.logout()} />
</View>
</Shell>
)
}

View file

@ -1,29 +0,0 @@
import React from 'react'
import {Text, Button, View, ActivityIndicator} from 'react-native'
import {observer} from 'mobx-react-lite'
import {Shell} from '../platform/shell'
import type {RootTabsScreenProps} from '../routes/types'
import {useStores} from '../state'
export const Login = observer(({navigation}: RootTabsScreenProps<'Login'>) => {
const store = useStores()
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Sign In</Text>
{store.session.uiError ?? <Text>{store.session.uiError}</Text>}
{!store.session.uiIsProcessing ? (
<>
<Button title="Login" onPress={() => store.session.login()} />
<Button
title="Sign Up"
onPress={() => navigation.navigate('Signup')}
/>
</>
) : (
<ActivityIndicator />
)}
</View>
</Shell>
)
})

View file

@ -1,16 +0,0 @@
import React from 'react'
import {Shell} from '../platform/shell'
import {ScrollView, Text, View} from 'react-native'
import type {RootTabsScreenProps} from '../routes/types'
export const Menu = (_props: RootTabsScreenProps<'Menu'>) => {
return (
<Shell>
<ScrollView contentInsetAdjustmentBehavior="automatic">
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Menu</Text>
</View>
</ScrollView>
</Shell>
)
}

View file

@ -1,15 +0,0 @@
import React from 'react'
import {Shell} from '../platform/shell'
import {Text, Button, View} from 'react-native'
import type {RootTabsScreenProps} from '../routes/types'
export const NotFound = ({navigation}: RootTabsScreenProps<'NotFound'>) => {
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Page not found</Text>
<Button title="Home" onPress={() => navigation.navigate('Home')} />
</View>
</Shell>
)
}

View file

@ -1,14 +0,0 @@
import React from 'react'
import {Shell} from '../platform/shell'
import {Text, View} from 'react-native'
import type {RootTabsScreenProps} from '../routes/types'
export const Notifications = (_props: RootTabsScreenProps<'Notifications'>) => {
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Notifications</Text>
</View>
</Shell>
)
}

View file

@ -1,16 +0,0 @@
import React from 'react'
import {Shell} from '../platform/shell'
import {View, Text} from 'react-native'
import type {RootTabsScreenProps} from '../routes/types'
export const Profile = ({route}: RootTabsScreenProps<'Profile'>) => {
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>
{route.params?.name}'s profile
</Text>
</View>
</Shell>
)
}

View file

@ -1,14 +0,0 @@
import React from 'react'
import {Shell} from '../platform/shell'
import {Text, View} from 'react-native'
import type {RootTabsScreenProps} from '../routes/types'
export const Search = (_props: RootTabsScreenProps<'Search'>) => {
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Search</Text>
</View>
</Shell>
)
}

View file

@ -1,34 +0,0 @@
import React from 'react'
import {Text, Button, View, ActivityIndicator} from 'react-native'
import {observer} from 'mobx-react-lite'
import {Shell} from '../platform/shell'
import type {RootTabsScreenProps} from '../routes/types'
import {useStores} from '../state'
export const Signup = observer(
({navigation}: RootTabsScreenProps<'Signup'>) => {
const store = useStores()
return (
<Shell>
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>Create Account</Text>
{store.session.uiError ?? <Text>{store.session.uiError}</Text>}
{!store.session.uiIsProcessing ? (
<>
<Button
title="Create new account"
onPress={() => store.session.login()}
/>
<Button
title="Log in to an existing account"
onPress={() => navigation.navigate('Login')}
/>
</>
) : (
<ActivityIndicator />
)}
</View>
</Shell>
)
},
)