@native-base/react-native-template
Version:
The base template for react-native with NativeBase.
75 lines (72 loc) • 1.75 kB
JavaScript
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
Link,
Text,
HStack,
Center,
Heading,
Switch,
useColorMode,
NativeBaseProvider,
VStack,
Box,
} from 'native-base';
import NativeBaseIcon from './src/components/NativeBaseIcon';
// 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>
);
}
const 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
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>
);
};
export default App;