react-native-navigation的迁移库

LayoutsScreen.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. const React = require('react');
  2. const Root = require('../components/Root');
  3. const Button = require('../components/Button')
  4. const {
  5. WELCOME_SCREEN_HEADER,
  6. STACK_BTN,
  7. BOTTOM_TABS_BTN,
  8. BOTTOM_TABS,
  9. SIDE_MENU_BTN
  10. } = require('../testIDs');
  11. const Screens = require('./Screens');
  12. const Navigation = require('../services/Navigation');
  13. const {stack} = require('../commons/Layouts');
  14. class LayoutsScreen extends React.Component {
  15. static options() {
  16. return {
  17. topBar: {
  18. testID: WELCOME_SCREEN_HEADER,
  19. title: {
  20. text: 'React Native Navigation'
  21. }
  22. }
  23. };
  24. }
  25. render() {
  26. return (
  27. <Root componentId={this.props.componentId}>
  28. <Button label='Stack' testID={STACK_BTN} onPress={this.stack} />
  29. <Button label='BottomTabs' testID={BOTTOM_TABS_BTN} onPress={this.bottomTabs} />
  30. <Button label='SideMenu' testID={SIDE_MENU_BTN} onPress={this.sideMenu} />
  31. </Root>
  32. );
  33. }
  34. stack = () => Navigation.showModal(Screens.Stack);
  35. bottomTabs = () => Navigation.showModal({
  36. bottomTabs: {
  37. children: [
  38. stack(Screens.FirstBottomTabsScreen),
  39. stack({
  40. component: {
  41. name: Screens.SecondBottomTabsScreen
  42. }
  43. }, 'SecondTab'
  44. )
  45. ],
  46. options: {
  47. bottomTabs: {
  48. testID: BOTTOM_TABS
  49. }
  50. }
  51. }
  52. });
  53. sideMenu = () => Navigation.showModal({
  54. sideMenu: {
  55. left: {
  56. component: {
  57. id: 'left',
  58. name: Screens.SideMenuLeft
  59. }
  60. },
  61. center: stack({
  62. component: {
  63. id: 'SideMenuCenter',
  64. name: Screens.SideMenuCenter
  65. }
  66. }),
  67. right: {
  68. component: {
  69. id: 'right',
  70. name: Screens.SideMenuRight
  71. }
  72. }
  73. }
  74. });
  75. onClickSplitView = () => {
  76. Navigation.setRoot({
  77. root: {
  78. splitView: {
  79. id: 'SPLITVIEW_ID',
  80. master: {
  81. stack: {
  82. id: 'MASTER_ID',
  83. children: [
  84. {
  85. component: {
  86. name: 'navigation.playground.WelcomeScreen'
  87. },
  88. },
  89. ]
  90. },
  91. },
  92. detail: {
  93. stack: {
  94. id: 'DETAILS_ID',
  95. children: [
  96. {
  97. component: {
  98. name: 'navigation.playground.WelcomeScreen'
  99. },
  100. },
  101. ]
  102. }
  103. },
  104. options: {
  105. displayMode: 'auto',
  106. primaryEdge: 'leading',
  107. minWidth: 150,
  108. maxWidth: 300,
  109. },
  110. },
  111. },
  112. });
  113. }
  114. onClickSearchBar = () => {
  115. Navigation.push(this.props.componentId, {
  116. component: {
  117. name: 'navigation.playground.SearchControllerScreen'
  118. }
  119. });
  120. };
  121. }
  122. module.exports = LayoutsScreen;