-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
47 lines (44 loc) · 1.5 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
import { useDeviceContext, useAppColorScheme } from 'twrnc';
import tw from 'twrnc';
import { Text, TouchableOpacity } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import About from './screens/About';
import Home from './screens/Home';
import Layout from './components/Layout';
const Stack = createNativeStackNavigator();
export default function App() {
useDeviceContext(tw, { withDeviceColorScheme: false });
const [, toggleColorScheme] = useAppColorScheme(tw);
return (
<Layout>
<TouchableOpacity onPress={toggleColorScheme}>
<Text
style={tw`bg-gray-200 dark:bg-gray-900 text-black dark:text-white
capitalize p-2 mt-24 text-center`}
>
toggle theme
</Text>
</TouchableOpacity>
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerRight: () => (
<TouchableOpacity onPress={toggleColorScheme}>
<Text
style={tw`bg-gray-200 dark:bg-gray-900 text-black dark:text-white
capitalize p-2 rounded`}
>
toggle theme
</Text>
</TouchableOpacity>
),
}}
>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="About" component={About} />
</Stack.Navigator>
</NavigationContainer>
</Layout>
);
}