-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppManual.tsx
47 lines (42 loc) · 1.5 KB
/
AppManual.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
// Change file app name to "App.tsx" to try manual color scheme
import { StatusBar } from "expo-status-bar";
import { Text, View, Button } from "react-native";
import { TailwindProvider, useColorScheme } from "tailwindcss-react-native";
import { useColorScheme as useColorSchemeRN } from "react-native";
import { useEffect } from "react";
export default function App() {
const colorSchemeRN = useColorSchemeRN();
useEffect(() => {
console.log("Apperance change at device level");
}, [colorSchemeRN]);
return (
<TailwindProvider initialColorScheme={colorSchemeRN}>
<MainApp deviceLevelCS={colorSchemeRN} />
</TailwindProvider>
);
}
function MainApp({ deviceLevelCS }: any) {
const { colorScheme, setColorScheme } = useColorScheme();
useEffect(() => {
console.log("Apperance change at app level");
}, [colorScheme]);
return (
<View className="items-center justify-center flex-1 bg-white dark:bg-black">
<Text className="text-center text-black dark:text-white">
Tailwindcss react native is working...Attempting dark mode...
</Text>
<Text className="py-6 text-black dark:text-white">
{`The device color scheme is ${deviceLevelCS}`}
</Text>
<View className="text-black dark:text-white">
<Button
title={`The app color scheme is ${colorScheme}`}
onPress={() =>
setColorScheme(colorScheme === "light" ? "dark" : "light")
}
/>
</View>
<StatusBar style="auto" />
</View>
);
}