react-native-navigation的迁移库

ComplexLayout.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 ComplexLayout extends Component {
  7. constructor(props) {
  8. super(props);
  9. }
  10. render() {
  11. return (
  12. <View style={styles.root}>
  13. <Text style={styles.h1} testID={testIDs.CENTERED_TEXT_HEADER}>{this.props.text || 'Complex layout screen'}</Text>
  14. <Button title={'External component in stack'} testID={testIDs.EXTERNAL_COMPONENT_IN_STACK} onPress={() => this.onExternalComponentInStackPressed()} />
  15. <Button title={'External component in deep stack'} testID={testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK} onPress={() => this.onExternalComponentInDeepStackPressed()} />
  16. </View>
  17. );
  18. }
  19. onExternalComponentInStackPressed() {
  20. Navigation.showModal({
  21. stack: {
  22. children: [{
  23. externalComponent: {
  24. name: 'RNNCustomComponent',
  25. passProps: {
  26. text: 'External component in stack'
  27. }
  28. }
  29. }]
  30. }
  31. });
  32. }
  33. onExternalComponentInDeepStackPressed() {
  34. Navigation.showModal({
  35. stack: {
  36. children: [{
  37. component: {
  38. name: 'navigation.playground.TextScreen'
  39. }
  40. },
  41. {
  42. externalComponent: {
  43. name: 'RNNCustomComponent',
  44. passProps: {
  45. text: 'External component in deep stack'
  46. }
  47. }
  48. }]
  49. }
  50. });
  51. }
  52. }
  53. module.exports = ComplexLayout;
  54. const styles = {
  55. root: {
  56. flexGrow: 1,
  57. justifyContent: 'center',
  58. alignItems: 'center',
  59. backgroundColor: '#f5fcff'
  60. },
  61. h1: {
  62. fontSize: 24,
  63. textAlign: 'center',
  64. margin: 10
  65. },
  66. h2: {
  67. fontSize: 12,
  68. textAlign: 'center',
  69. margin: 10
  70. },
  71. footer: {
  72. fontSize: 10,
  73. color: '#888',
  74. marginTop: 10
  75. }
  76. };