-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
72 lines (67 loc) · 2.15 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
import { Ionicons } from '@expo/vector-icons';
import {
DarkTheme as NavigationDarkTheme,
DefaultTheme as NavigationDefaultTheme,
NavigationContainer,
} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import {
DarkTheme as PaperDarkTheme,
DefaultTheme as PaperDefaultTheme,
Provider as PaperProvider,
} from 'react-native-paper';
import { QueryClient, QueryClientProvider } from 'react-query';
import FlashMessage from 'react-native-flash-message';
import AppContextProvider, { useApp } from './src/context/AppContext';
import Home from './src/Home';
const Stack = createNativeStackNavigator();
const queryClient = new QueryClient();
const App = () => {
const app = useApp();
const { theme, toggleTheme, loaded } = app;
const isDarkTheme = theme === 'dark';
if (!loaded) {
return null;
}
return (
<NavigationContainer
theme={isDarkTheme ? NavigationDarkTheme : NavigationDefaultTheme}>
<QueryClientProvider client={queryClient}>
<PaperProvider
settings={{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
icon: (props) => <Ionicons {...props} />,
}}
theme={isDarkTheme ? PaperDarkTheme : PaperDefaultTheme}>
<StatusBar style={isDarkTheme ? 'light' : 'dark'} />
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Home}
options={{
title: 'Crypto Converter',
headerRight: () => (
<Ionicons
onPress={toggleTheme}
name={isDarkTheme ? 'sunny' : 'moon'}
size={24}
color={isDarkTheme ? 'white' : 'black'}
/>
),
}}
/>
</Stack.Navigator>
</PaperProvider>
</QueryClientProvider>
<FlashMessage position="bottom" />
</NavigationContainer>
);
};
export default () => (
<AppContextProvider>
<App />
</AppContextProvider>
);