-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
87 lines (84 loc) · 2.06 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import React from "react";
import {
Text,
Link,
HStack,
Center,
Heading,
Switch,
useColorMode,
NativeBaseProvider,
extendTheme,
VStack,
Box,
} from "native-base";
import NativeBaseIcon from "./components/NativeBaseIcon";
// Define the config
const config = {
useSystemColorMode: false,
initialColorMode: "dark",
};
// extend the theme
export const theme = extendTheme({ config });
type MyThemeType = typeof theme;
declare module "native-base" {
interface ICustomTheme extends MyThemeType {}
}
export default function App() {
return (
<NativeBaseProvider>
<Center
_dark={{ bg: "blueGray.900" }}
_light={{ bg: "blueGray.50" }}
px={4}
flex={1}
>
<VStack space={5} alignItems="center">
<NativeBaseIcon />
<Heading size="lg">Welcome to NativeBase</Heading>
<HStack space={2} alignItems="center">
<Text>Edit</Text>
<Box
_web={{
_text: {
fontFamily: "monospace",
fontSize: "sm",
},
}}
px={2}
py={1}
_dark={{ bg: "blueGray.800" }}
_light={{ bg: "blueGray.200" }}
>
App.js
</Box>
<Text>and save to reload.</Text>
</HStack>
<Link href="https://docs.nativebase.io" isExternal>
<Text color="primary.500" underline fontSize={"xl"}>
Learn NativeBase
</Text>
</Link>
<ToggleDarkMode />
</VStack>
</Center>
</NativeBaseProvider>
);
}
// Color Switch Component
function ToggleDarkMode() {
const { colorMode, toggleColorMode } = useColorMode();
return (
<HStack space={2} alignItems="center">
<Text>Dark</Text>
<Switch
isChecked={colorMode === "light"}
onToggle={toggleColorMode}
aria-label={
colorMode === "light" ? "switch to dark mode" : "switch to light mode"
}
/>
<Text>Light</Text>
</HStack>
);
}