react-native-navigation的迁移库

OrientationSelectScreen.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const React = require('react');
  2. const { Component } = require('react');
  3. const { View, Text, Button } = require('react-native');
  4. const { Navigation } = require('react-native-navigation');
  5. const testIDs = require('../testIDs');
  6. class OrientationSelectScreen extends Component {
  7. render() {
  8. return (
  9. <View style={styles.root}>
  10. <Text style={styles.h1}>{`Orientation Menu`}</Text>
  11. <Button title='default' testID={testIDs.DEFAULT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen('default')} />
  12. <Button title='landscape and portrait' testID={testIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen(['landscape', 'portrait'])} />
  13. <Button title='portrait only' testID={testIDs.PORTRAIT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen('portrait')} />
  14. <Button title='landscape only' testID={testIDs.LANDSCAPE_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen(['landscape'])} />
  15. </View>
  16. );
  17. }
  18. onClickOrientationScreen(orientation) {
  19. Navigation.showModal({
  20. component: {
  21. name: 'navigation.playground.OrientationDetectScreen',
  22. passProps: {
  23. orientation
  24. }
  25. }
  26. });
  27. }
  28. }
  29. module.exports = OrientationSelectScreen;
  30. const styles = {
  31. root: {
  32. flexGrow: 1,
  33. justifyContent: 'center',
  34. alignItems: 'center',
  35. backgroundColor: '#f5fcff'
  36. },
  37. h1: {
  38. fontSize: 24,
  39. textAlign: 'center',
  40. margin: 10
  41. }
  42. };