-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
115 lines (107 loc) · 3.27 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React, { useContext } from 'react'
import { createStackNavigator } from '@react-navigation/stack'
import { DefaultTheme, NavigationContainer } from '@react-navigation/native'
import MakeTemplate from './src/screens/maketemplate'
import Templates from './src/screens/templates'
import { StorageProvider } from './src/storage/provider'
import Checklists from './src/screens/checklists'
import {
CHECKLISTS_STORAGE_KEY,
TEMPLATES_STORAGE_KEY,
} from './src/storage/storage'
import { icons } from './src/ux/icons'
import { ds } from './src/ux/design'
import Settings from './src/screens/settings'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import Icon from 'react-native-vector-icons/FontAwesome'
import { StorageContext } from './src/storage/context'
const MyTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
dark: ds.colors.primary,
light: ds.colors.primary,
background: ds.colors.primary,
},
}
// const Drawer = createDrawerNavigator()
const Stack = createStackNavigator()
const Tab = createBottomTabNavigator()
function TemplateNavigation() {
return (
<Stack.Navigator>
<Tab.Screen
name="List templates"
component={Templates}
options={{
headerShown: false,
}}></Tab.Screen>
<Tab.Screen
name="Edit template"
initialParams={{ templateId: null, isNew: false }}
component={MakeTemplate}></Tab.Screen>
</Stack.Navigator>
)
}
function Navigation() {
const { checklists } = useContext(StorageContext)
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused }) => {
let iconName = icons.eye
if (route.name === 'Templates') {
iconName = icons.paste
} else if (route.name === 'Checklists') {
iconName = icons.check
} else if (route.name === 'Settings') {
iconName = icons.gear
} else if (route.name === 'Edit template') {
iconName = icons.plus
}
return (
<Icon
name={iconName}
color={focused ? 'black' : 'gray'}
size={ds.icons.medium}></Icon>
)
},
tabBarActiveTintColor: 'black',
tabBarInactiveTintColor: 'gray',
tabBarLabelStyle: {
paddingBottom: ds.sizes.xs,
},
})}>
<Tab.Screen
name="Templates"
component={TemplateNavigation}
options={{ headerShown: false }}></Tab.Screen>
<Tab.Screen
name="Checklists"
component={Checklists}
options={{
headerShown: false,
tabBarBadge: checklists.length > 0 ? checklists.length : undefined,
tabBarBadgeStyle: {
backgroundColor: ds.colors.highlight1,
},
}}></Tab.Screen>
<Tab.Screen
name="Settings"
component={Settings}
options={{ headerShown: false }}></Tab.Screen>
</Tab.Navigator>
)
}
function App(): JSX.Element {
return (
<StorageProvider
templates_storage_key={TEMPLATES_STORAGE_KEY}
checklists_storage_key={CHECKLISTS_STORAGE_KEY}>
<NavigationContainer theme={MyTheme}>
<Navigation></Navigation>
</NavigationContainer>
</StorageProvider>
)
}
export default App