/**
|
|
* Sample React Native App
|
|
* https://github.com/facebook/react-native
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import type {PropsWithChildren} from 'react';
|
|
import React, {useState} from 'react';
|
|
import {
|
|
Button,
|
|
SafeAreaView,
|
|
ScrollView,
|
|
StatusBar,
|
|
StyleSheet,
|
|
Text,
|
|
useColorScheme,
|
|
View,
|
|
} from 'react-native';
|
|
|
|
import DatePicker from 'react-native-date-picker';
|
|
import {
|
|
Colors,
|
|
Header,
|
|
LearnMoreLinks,
|
|
} from 'react-native/Libraries/NewAppScreen';
|
|
|
|
type SectionProps = PropsWithChildren<{
|
|
title: string;
|
|
}>;
|
|
|
|
function Section({children, title}: SectionProps): JSX.Element {
|
|
const isDarkMode = useColorScheme() === 'dark';
|
|
const [date, setDate] = useState(new Date());
|
|
const [open, setOpen] = useState(false);
|
|
return (
|
|
<View style={styles.sectionContainer} key={title}>
|
|
<Button title="open" onPress={() => setOpen(true)} />
|
|
<DatePicker
|
|
date={new Date('2021-01-01T2:00:00Z')}
|
|
modal
|
|
mode="date"
|
|
onConfirm={date => {
|
|
setDate(date);
|
|
setOpen(false);
|
|
}}
|
|
onCancel={() => {
|
|
setOpen(false);
|
|
}}
|
|
open={open}
|
|
/>
|
|
<DatePicker
|
|
date={date}
|
|
maximumDate={new Date('2000-02-01')}
|
|
minimumDate={new Date('2000-01-01')}
|
|
onDateChange={setDate}
|
|
androidVariant="nativeAndroid"
|
|
/>
|
|
<Text
|
|
style={[
|
|
styles.sectionTitle,
|
|
{
|
|
color: isDarkMode ? Colors.white : Colors.black,
|
|
},
|
|
]}>
|
|
{date.toISOString()}
|
|
</Text>
|
|
<Text
|
|
style={[
|
|
styles.sectionDescription,
|
|
{
|
|
color: isDarkMode ? Colors.light : Colors.dark,
|
|
},
|
|
]}>
|
|
{children}
|
|
</Text>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
function App(): JSX.Element {
|
|
const isDarkMode = useColorScheme() === 'dark';
|
|
|
|
const backgroundStyle = {
|
|
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
|
|
};
|
|
|
|
return (
|
|
<SafeAreaView style={backgroundStyle}>
|
|
<StatusBar
|
|
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
|
|
backgroundColor={backgroundStyle.backgroundColor}
|
|
/>
|
|
<ScrollView
|
|
contentInsetAdjustmentBehavior="automatic"
|
|
style={backgroundStyle}>
|
|
<Header />
|
|
<View
|
|
style={{
|
|
backgroundColor: isDarkMode ? Colors.black : Colors.white,
|
|
}}>
|
|
<Section title="Learn More">
|
|
Read the docs to discover what to do next:
|
|
</Section>
|
|
<LearnMoreLinks />
|
|
</View>
|
|
</ScrollView>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
sectionContainer: {
|
|
marginTop: 32,
|
|
paddingHorizontal: 24,
|
|
},
|
|
sectionTitle: {
|
|
fontSize: 24,
|
|
fontWeight: '600',
|
|
},
|
|
sectionDescription: {
|
|
marginTop: 8,
|
|
fontSize: 18,
|
|
fontWeight: '400',
|
|
},
|
|
highlight: {
|
|
fontWeight: '700',
|
|
},
|
|
});
|
|
|
|
export default App;
|