-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathApp.tsx
52 lines (46 loc) · 1.46 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
import "./global.css";
import React from "react";
import HomestayPage from "./kitchensink-components/HomestayPage";
import { SafeAreaView, GluestackUIProvider } from "./components/ui";
import * as Linking from "expo-linking";
let defaultTheme: "dark" | "light" = "light";
Linking.getInitialURL().then((url: any) => {
let { queryParams } = Linking.parse(url) as any;
defaultTheme = queryParams?.iframeMode ?? defaultTheme;
});
type ThemeContextType = {
colorMode?: "dark" | "light";
toggleColorMode?: () => void;
};
export const ThemeContext = React.createContext<ThemeContextType>({
colorMode: "light",
toggleColorMode: () => {},
});
export default function App() {
const [colorMode, setColorMode] = React.useState<"dark" | "light">(
defaultTheme
);
const toggleColorMode = async () => {
setColorMode((prev) => (prev === "light" ? "dark" : "light"));
};
return (
<>
{/* top SafeAreaView */}
<SafeAreaView
className={`${colorMode === "light" ? "bg-[#E5E5E5]" : "bg-[#262626]"}`}
/>
<ThemeContext.Provider value={{ colorMode, toggleColorMode }}>
<GluestackUIProvider mode={colorMode}>
{/* bottom SafeAreaView */}
<SafeAreaView
className={`${
colorMode === "light" ? "bg-white" : "bg-[#171717]"
} flex-1 overflow-hidden`}
>
<HomestayPage />
</SafeAreaView>
</GluestackUIProvider>
</ThemeContext.Provider>
</>
);
}