-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
83 lines (71 loc) · 2.12 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
import "react-native-gesture-handler";
import "react-native-reanimated";
import { useCallback, useEffect } from "react";
import { StatusBar } from "expo-status-bar";
import { NavigationContainer } from "@react-navigation/native";
import {
createStackNavigator,
CardStyleInterpolators,
} from "@react-navigation/stack";
import { Home } from "./src/pages/Home";
import { Customize } from "./src/pages/Customize";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useColorScheme } from "nativewind";
import {
useFonts,
Rajdhani_400Regular,
Rajdhani_600SemiBold,
Rajdhani_700Bold,
} from "@expo-google-fonts/rajdhani";
import { Inter_400Regular } from "@expo-google-fonts/inter";
export type RootStackParamList = {
Home: {};
Customize: {};
};
const Stack = createStackNavigator();
export default function App() {
const { setColorScheme, colorScheme } = useColorScheme();
// Getting stored theme from AsyncStorage
const handleGetTheme = useCallback(async () => {
try {
const jsonValue = await AsyncStorage.getItem("@pomodoro:theme");
if (jsonValue != null) {
const storedTheme = await JSON.parse(jsonValue);
setColorScheme(storedTheme);
}
} catch (e) {
console.log("Error while trying to rescue the stored theme");
}
}, []);
useEffect(() => {
handleGetTheme();
});
let [fontsLoaded] = useFonts({
Rajdhani_400Regular,
Rajdhani_600SemiBold,
Rajdhani_700Bold,
Inter_400Regular,
});
if (!fontsLoaded) {
return null;
}
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
gestureEnabled: false,
}}
initialRouteName="Home"
>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Customize" component={Customize} />
</Stack.Navigator>
<StatusBar
style={colorScheme === "dark" ? "light" : "dark"}
backgroundColor={colorScheme === "light" ? "#fff" : "#202124"}
/>
</NavigationContainer>
);
}