-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
61 lines (52 loc) · 2.05 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
import React, { useEffect, useState } from 'react';
import { NativeBaseProvider, extendTheme } from 'native-base';
import { DarkTheme, NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import WeatherScreen from './src/Screens/WeatherScreen/WeatherScreen';
import PreferencesScreen from './src/Screens/PreferencesScreen';
import CreditScreen from './src/Screens/CreditScreen';
import { PreferenceContext } from './src/Contexts/PreferenceContext';
import { IData, IError, IPreferences } from './src/Interfaces';
import { WeatherDataContext } from './src/Contexts/WeatherDataContext';
const config = {
useSystemColorMode: false,
initialColorMode: 'dark',
}
const customTheme = extendTheme({ config })
const Stack = createNativeStackNavigator();
export default function App() {
const [isLoading, setIsLoading] = useState(true)
const [data, setData] = useState<IData>({city: "", dayInfos: [{date: "", temps: [0,0], rain: [0,0], snow: [0,0]}], currentTemp: 0, currentWeatherCode: 0, maxTemp: 0, minTemp: 0, sunrise: "", sunset: "", humidity: 0, windspeed: 0})
const [error, setError] = useState<IError | null>(null)
const [preferences, setPreferences] = useState<IPreferences>({
MeasuringSystem: "",
TemperatureScale: ""
})
return (
<NativeBaseProvider theme={customTheme}>
<NavigationContainer theme={DarkTheme}>
<WeatherDataContext.Provider value={{ data, setData, isLoading, setIsLoading, error, setError }}>
<PreferenceContext.Provider value={{preferences, setPreferences}}>
<Stack.Navigator>
<Stack.Screen
name="Weather"
component={WeatherScreen}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Preferences"
component={PreferencesScreen}
/>
<Stack.Screen
name="Credits"
component={CreditScreen}
/>
</Stack.Navigator>
</PreferenceContext.Provider>
</WeatherDataContext.Provider>
</NavigationContainer>
</NativeBaseProvider>
);
}