-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
215 lines (197 loc) · 5.49 KB
/
App.js
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, TouchableOpacity, Pressable, Button } from 'react-native';
import { DarkTheme, DefaultTheme, NavigationContainer } from '@react-navigation/native';
import React, { useEffect, useState, useContext } from 'react'
import Ionicons from '@expo/vector-icons/Ionicons';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import HomeScreen from './pages/HomeScreen';
import CalendarScreen from './pages/CalendarScreen';
import UploadScreen from './pages/UploadScreen';
import AlbumsScreen from './pages/AlbumsScreen';
import ProfileScreen from './pages/ProfileScreen';
import AppNavigator from './pages/AppNavigator';
import { EventRegister } from 'react-native-event-listeners'
import theme from './theme/theme';
import themeContext from './theme/themeContext';
import { background } from '@cloudinary/url-gen/qualifiers/focusOn';
const Tab = createBottomTabNavigator();
// function for button to change when being pressed
const ColorChangingButton = ({ defaultIconName, pressedIconName, iconSize = 40, onPress }) => {
const [iconName, setIconName] = useState(defaultIconName);
const theme = useContext(themeContext);
const pressed = () => {
setIconName(pressedIconName);
};
const unPressed = () => {
setIconName(defaultIconName);
};
return (
<Pressable
onPressIn={pressed}
onPressOut={unPressed}
onPress={onPress}
>
<Ionicons name={iconName} size={iconSize} color={theme.color} />
</Pressable>
);
};
function CustomHeader({ navigation }) {
const theme = useContext(themeContext);
return (
<View style={[styles.header, {backgroundColor: theme}]}>
<Text style={[styles.title, {color: theme.color}]}>Fitted.</Text>
<ColorChangingButton
defaultIconName="dice-outline"
pressedIconName="dice"
onPress={() => console.log('Shuffle button pressed')}
/>
</View>
);
}
export default function App() {
const [darkMode, setDarkMode] = useState(false)
useEffect(() => {
const listener = EventRegister.addEventListener('ChangeTheme', (data) => {
setDarkMode(data)
})
return () => {
EventRegister.removeAllListeners(listener)
}
}, [darkMode])
return (
<themeContext.Provider value={darkMode === true ? theme.dark : theme.light}>
<NavigationContainer theme={darkMode === true ? DarkTheme : DefaultTheme}>
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Home') {
iconName = focused
? "shirt"
: "shirt-outline";
}
if (route.name === 'Calendar') {
iconName = focused
? "calendar-clear"
: "calendar-clear-outline";
}
if (route.name === 'Upload') {
iconName = focused
? "add-circle"
: "add-circle-outline";
}
if (route.name === 'Albums') {
iconName = focused
? "albums"
: "albums-outline";
}
if (route.name === 'Profile') {
iconName = focused
? "person"
: "person-outline";
}
return <Ionicons name={iconName} size={size} color={color} />;
},
tabBarActiveTintColor: "#800f2f",
tabBarInactiveTintColor: "#6c757d",
})}
>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
header: () => <CustomHeader />,
headerStyle: {
backgroundColor: 'white',
elevation: 0,
shadowOpacity: 0,
},
}}
/>
<Tab.Screen name="Calendar" component={CalendarScreen} />
<Tab.Screen name="Upload" component={UploadScreen} />
<Tab.Screen name="Albums" component={AppNavigator} />
<Tab.Screen name="Profile" component={ProfileScreen} />
</Tab.Navigator>
</NavigationContainer>
</themeContext.Provider>
);
}
const styles = StyleSheet.create({
header: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'flex-end',
height: 98,
paddingHorizontal: 15,
elevation: 1,
borderBottomWidth: 0.3,
borderBottomColor: '#ccc',
},
title: {
fontSize: 40,
},
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
text: {
position: 'absolute',
top: 50,
left: 20,
fontSize: 45,
},
horizontalLine: {
position: 'absolute',
bottom: 90,
left: 0,
right: 0,
height: 1,
backgroundColor: 'black',
},
topLine: {
position: 'absolute',
top: 105,
left: 0,
right: 0,
height: 1,
backgroundColor: 'black',
},
home: {
position: 'absolute',
left: 30,
right: 0,
bottom: 35,
},
calendar: {
position: 'absolute',
left: 105,
right: 0,
bottom: 35,
},
plus: {
position: 'absolute',
left: 180,
right: 0,
bottom: 35,
},
album: {
position: 'absolute',
left: 255,
right: 0,
bottom: 35,
},
profile: {
position: 'absolute',
left: 330,
right: 0,
bottom: 35,
},
dice: {
position: 'absolute',
left: 330,
top: 60,
},
});