react-native-navigation的迁移库

NavigationScreen.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. const React = require('react');
  2. const Root = require('../components/Root');
  3. const Button = require('../components/Button')
  4. const Navigation = require('./../services/Navigation');
  5. const {
  6. NAVIGATION_TAB,
  7. MODAL_BTN,
  8. OVERLAY_BTN,
  9. EXTERNAL_COMP_BTN,
  10. SHOW_STATIC_EVENTS_SCREEN,
  11. SHOW_ORIENTATION_SCREEN
  12. } = require('../testIDs');
  13. const Screens = require('./Screens');
  14. class NavigationScreen extends React.Component {
  15. static options() {
  16. return {
  17. topBar: {
  18. title: {
  19. text: 'Navigation'
  20. }
  21. },
  22. bottomTab: {
  23. text: 'Navigation',
  24. icon: require('../../img/navigation.png'),
  25. testID: NAVIGATION_TAB
  26. }
  27. };
  28. }
  29. render() {
  30. return (
  31. <Root componentId={this.props.componentId}>
  32. <Button label='Modal' testID={MODAL_BTN} onPress={this.showModal} />
  33. <Button label='Overlay' testID={OVERLAY_BTN} onPress={this.showOverlay} />
  34. <Button label='External Component' testID={EXTERNAL_COMP_BTN} onPress={this.externalComponent} />
  35. <Button label='Static Events' testID={SHOW_STATIC_EVENTS_SCREEN} onPress={this.pushStaticEventsScreen} />
  36. <Button label='Orientation' testID={SHOW_ORIENTATION_SCREEN} onPress={this.orientation} />
  37. <Navigation.TouchablePreview
  38. touchableComponent={Button}
  39. onPressIn={this.preview}
  40. label='Preview' />
  41. </Root>
  42. );
  43. }
  44. showModal = () => Navigation.showModal(Screens.Modal);
  45. showOverlay = () => Navigation.showModal(Screens.Overlay);
  46. externalComponent = () => Navigation.showModal(Screens.ExternalComponent);
  47. pushStaticEventsScreen = () => Navigation.showModal(Screens.EventsScreen)
  48. orientation = () => Navigation.showModal(Screens.Orientation);
  49. preview = ({ reactTag }) => {
  50. Navigation.push(this.props.componentId, {
  51. component: {
  52. name: Screens.Pushed,
  53. options: {
  54. animations: {
  55. push: {
  56. enabled: false
  57. }
  58. },
  59. preview: {
  60. reactTag: reactTag,
  61. height: 300,
  62. actions: [{
  63. id: 'action-cancel',
  64. title: 'Cancel'
  65. }, {
  66. id: 'action-delete',
  67. title: 'Delete',
  68. actions: [{
  69. id: 'action-delete-sure',
  70. title: 'Are you sure?',
  71. style: 'destructive'
  72. }]
  73. }]
  74. }
  75. }
  76. }
  77. });
  78. }
  79. }
  80. module.exports = NavigationScreen;