-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
190 lines (183 loc) · 5.45 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
import 'react-native-gesture-handler';
import {withAuthenticator} from '@aws-amplify/ui-react-native';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import React from 'react';
import {NavigationContainer, DefaultTheme} from '@react-navigation/native';
import RecipesScreen from './src/components/RecipesScreen';
import SettingsScreen from './src/components/SettingsScreen';
import AddScreen from './src/components/AddScreen';
import {createStackNavigator} from '@react-navigation/stack';
import DetailsScreen from './src/components/DetailsScreen';
import DiscoverScreen from './src/components/DiscoverScreen';
import TabBarIcon from './src/components/TabBarIcon';
import SettingsIcon from './src/components/SettingsIcon';
import BackIcon from './src/components/BackIcon';
import CloseIcon from './src/components/CloseIcon';
import DetailsMenu from './src/components/DetailsMenu';
import AddFromUrlScreen from './src/components/AddFromUrlScreen';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
const LightTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: '#D95931',
background: '#EBE9E5',
card: '#EBE9E5',
text: '#323232',
border: '#D4D4D4',
opaque: 'rgba(0, 0, 0, 0.3)',
},
fonts: {
regular: {
fontFamily: 'Poppins-Regular',
fontWeight: 'normal',
},
medium: {
fontFamily: 'Poppins-Medium',
fontWeight: 'medium',
},
light: {
fontFamily: 'Poppins-Light',
fontWeight: 'light',
},
thin: {
fontFamily: 'Poppins-Thin',
fontWeight: 'thin',
},
},
};
function AddComponent() {
return null;
}
function AddStackNavigator() {
return (
<Stack.Navigator>
<Stack.Screen
name="AddScreen"
component={AddScreen}
options={({navigation}) => ({
headerLeft: () => null,
headerRight: () => CloseIcon(navigation, 'Recipes'),
headerTitle: 'Add recipe',
presentation: 'modal',
headerShadowVisible: false,
headerRightContainerStyle: {paddingRight: 10},
})}
/>
<Stack.Screen
name="AddFromUrl"
component={AddFromUrlScreen}
options={({navigation}) => ({
headerTitle: 'Add from URL',
headerLeft: () => BackIcon(navigation),
headerLeftContainerStyle: {paddingLeft: 10},
headerRight: () => CloseIcon(navigation, 'Recipes'),
headerShadowVisible: false,
headerRightContainerStyle: {paddingRight: 10},
})}
/>
</Stack.Navigator>
);
}
function TabNavigator({navigation}: {navigation: any}) {
return (
<Tab.Navigator
screenOptions={({route}) => ({
// eslint-disable-next-line react/no-unstable-nested-components
tabBarIcon: ({color, size}) => {
return (
<TabBarIcon
name={route.name}
color={color}
size={size}
onPressFunction={() => navigation.navigate(route.name)}
/>
);
},
tabBarActiveTintColor: '#323232',
tabBarInactiveTintColor: 'gray',
tabBarShowLabel: false,
})}>
<Tab.Screen
name="Recipes"
component={RecipesScreen}
options={{
headerTitleAlign: 'left',
headerRight: () => SettingsIcon(navigation),
headerRightContainerStyle: {paddingRight: 10},
headerShadowVisible: false,
}}
/>
<Tab.Screen
name="Add"
component={AddComponent}
listeners={() => ({
tabPress: e => {
e.preventDefault();
navigation.navigate('Add');
navigation.removeListener('tabPress');
},
})}
/>
<Tab.Screen
name="Discover"
component={DiscoverScreen}
options={{
headerTitleAlign: 'left',
headerRight: () => SettingsIcon(navigation),
headerRightContainerStyle: {paddingRight: 10},
headerShadowVisible: false,
}}
/>
</Tab.Navigator>
);
}
export function App(): React.JSX.Element {
return (
<NavigationContainer theme={LightTheme}>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={TabNavigator}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="DetailsScreen"
component={DetailsScreen}
options={({navigation}) => ({
headerTransparent: true,
headerShadowVisible: false,
headerTitle: '',
headerLeft: () => BackIcon(navigation, 'Details'),
headerLeftContainerStyle: {paddingLeft: 10},
headerRight: () => DetailsMenu(),
headerRightContainerStyle: {paddingRight: 10},
})}
/>
<Stack.Screen
name="Add"
component={AddStackNavigator}
options={{
headerShown: false,
presentation: 'modal',
}}
/>
<Stack.Screen
name="Settings"
component={SettingsScreen}
options={({navigation}) => ({
headerLeft: () => null,
headerRight: () => CloseIcon(navigation, 'Recipes'),
presentation: 'modal',
headerShadowVisible: false,
headerRightContainerStyle: {paddingRight: 10},
})}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
export default withAuthenticator(App);