Created
January 28, 2017 21:59
-
-
Save MrToph/52b17a75a35e9a66551da50d00c47e50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Button, | |
DatePickerAndroid | |
} from 'react-native'; | |
export default class test extends Component { | |
show = async () => { | |
try { | |
const {action, year, month, day} = await DatePickerAndroid.open({ | |
// Use `new Date()` for current date. | |
// May 25 2020. Month 0 is January. | |
date: new Date(2020, 4, 25) | |
}); | |
if (action !== DatePickerAndroid.dismissedAction) { | |
// Selected year, month (0-11), day | |
} | |
} catch ({code, message}) { | |
console.warn('Cannot open date picker', message); | |
} | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.welcome}> | |
Welcome to React Native! | |
</Text> | |
<Button title="DatePicker" onPress={this.show}>Date Picker Open | |
</Button> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF', | |
}, | |
welcome: { | |
fontSize: 20, | |
textAlign: 'center', | |
margin: 10, | |
}, | |
instructions: { | |
textAlign: 'center', | |
color: '#333333', | |
marginBottom: 5, | |
}, | |
}); | |
AppRegistry.registerComponent('test', () => test); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment