-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
154 lines (141 loc) · 3.98 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
import { StatusBar } from "expo-status-bar";
import { useRef, useState } from "react";
import {
Animated,
Image,
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from "react-native";
import Home from "./app/screens/Home";
import DarkMode from "./app/assets/icons/dark-mode.png";
import colors from "./app/config/colors";
import Screen from "./app/components/shared/Screen";
export default function App() {
const [showMenu, setShowMenu] = useState(false);
const [darkMode, setDarkMode] = useState(false);
// Animated Properties...
const offsetValue = useRef(new Animated.Value(0)).current;
const scaleValue = useRef(new Animated.Value(1)).current;
const closeButtonOffset = useRef(new Animated.Value(0)).current;
return (
<Screen
style={{
// ...styles.menuContainer,
backgroundColor: darkMode ? colors.white : colors.dark,
}}
>
<StatusBar style={darkMode ? "dark" : "light"} />
{/* ------- DRAWER OVERLAY ------- */}
<View style={{ flex: 1, justifyContent: "center" }}>
<View>
<TouchableOpacity
style={{ flexDirection: "row", alignItems: "center" }}
onPress={() => {
// Do Actions Here....
// Scaling the view...
Animated.timing(scaleValue, {
toValue: showMenu ? 1 : 0.78,
duration: 300,
useNativeDriver: true,
}).start();
Animated.timing(offsetValue, {
// Random Value...
toValue: showMenu ? 0 : 230,
duration: 300,
useNativeDriver: true,
}).start();
Animated.timing(closeButtonOffset, {
// Random Value...
toValue: !showMenu ? -30 : 0,
duration: 300,
useNativeDriver: true,
}).start();
setShowMenu(true);
setDarkMode(!darkMode);
// setShowMenu(!showMenu)
}}
>
<Image
source={DarkMode}
style={{
...styles.modeImg,
tintColor: darkMode ? colors.dark : colors.white,
}}
/>
{darkMode ? (
<Text
style={{
...styles.modeText,
color: darkMode ? colors.dark : colors.white,
}}
>
Dark
</Text>
) : (
<Text
style={{
...styles.modeText,
color: darkMode ? colors.dark : colors.white,
}}
>
Light
</Text>
)}
</TouchableOpacity>
</View>
</View>
{/* ------- HOME SCREEN ------- */}
<Animated.View
style={{
...styles.animatedScreen,
backgroundColor: darkMode ? colors.white : colors.dark,
shadowColor: darkMode ? colors.lightGray : colors.darkGray,
transform: [{ scale: scaleValue }, { translateX: offsetValue }],
}}
>
<ScrollView showsVerticalScrollIndicator={false}>
<Home
scaleValue={scaleValue}
offsetValue={offsetValue}
closeButtonOffset={closeButtonOffset}
showMenu={showMenu}
setShowMenu={setShowMenu}
darkMode={darkMode}
></Home>
</ScrollView>
</Animated.View>
</Screen>
);
}
const styles = StyleSheet.create({
menuContainer: {
flex: 1,
},
animatedScreen: {
flex: 1,
position: "absolute",
top: 0,
bottom: 0,
left: 0,
right: 0,
paddingHorizontal: 15,
// paddingTop: 20,
borderRadius: 10,
shadowOffset: { width: -10, height: 15 },
shadowOpacity: 0.2,
shadowRadius: 10,
},
modeImg: {
width: 28,
height: 28,
marginLeft: 10,
},
modeText: {
marginLeft: 10,
fontSize: 16,
fontWeight: "500",
},
});