react-native-navigation的迁移库

app.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. const { Navigation } = require('react-native-navigation');
  2. const { registerScreens } = require('./screens');
  3. const { Platform } = require('react-native');
  4. if (Platform.OS === 'android') {
  5. alert = (title) => {
  6. Navigation.showOverlay({
  7. component: {
  8. name: 'navigation.playground.alert',
  9. passProps: {
  10. title
  11. },
  12. options: {
  13. overlay: {
  14. interceptTouchOutside: true
  15. }
  16. }
  17. }
  18. });
  19. };
  20. }
  21. function start() {
  22. registerScreens();
  23. Navigation.events().registerAppLaunchedListener(async () => {
  24. Navigation.setDefaultOptions({
  25. layout: {
  26. componentBackgroundColor: '#e8e8e8',
  27. orientation: ['portrait']
  28. },
  29. bottomTab: {
  30. iconColor: '#1B4C77',
  31. selectedIconColor: '#0f0',
  32. textColor: '#1B4C77',
  33. selectedTextColor: '#0f0',
  34. fontFamily: 'HelveticaNeue-Italic',
  35. fontSize: 13
  36. },
  37. _animations: {
  38. push: {
  39. waitForRender: false,
  40. }
  41. },
  42. animations: {
  43. setRoot: {
  44. alpha: {
  45. from: 0,
  46. to: 1,
  47. duration: 300
  48. }
  49. },
  50. _push: {
  51. topBar: {
  52. id: 'TEST',
  53. alpha: {
  54. from: 0,
  55. to: 1,
  56. duration: 500,
  57. interpolation: 'accelerate'
  58. }
  59. },
  60. bottomTabs: {
  61. y: {
  62. from: 1000,
  63. to: 0,
  64. duration: 500,
  65. interpolation: 'decelerate',
  66. },
  67. alpha: {
  68. from: 0,
  69. to: 1,
  70. duration: 500,
  71. interpolation: 'decelerate'
  72. }
  73. },
  74. content: {
  75. y: {
  76. from: 1000,
  77. to: 0,
  78. duration: 500,
  79. interpolation: 'accelerate',
  80. },
  81. alpha: {
  82. from: 0,
  83. to: 1,
  84. duration: 500,
  85. interpolation: 'accelerate'
  86. }
  87. }
  88. },
  89. _pop: {
  90. topBar: {
  91. id: 'TEST',
  92. alpha: {
  93. from: 1,
  94. to: 0,
  95. duration: 500,
  96. interpolation: 'accelerate'
  97. }
  98. },
  99. bottomTabs: {
  100. y: {
  101. from: 0,
  102. to: 100,
  103. duration: 500,
  104. interpolation: 'accelerate',
  105. },
  106. alpha: {
  107. from: 1,
  108. to: 0,
  109. duration: 500,
  110. interpolation: 'accelerate'
  111. }
  112. },
  113. bottomTabs: {
  114. y: {
  115. from: 0,
  116. to: 100,
  117. duration: 500,
  118. interpolation: 'decelerate',
  119. },
  120. alpha: {
  121. from: 1,
  122. to: 0,
  123. duration: 500,
  124. interpolation: 'decelerate'
  125. }
  126. },
  127. content: {
  128. y: {
  129. from: 0,
  130. to: 1000,
  131. duration: 500,
  132. interpolation: 'decelerate',
  133. },
  134. alpha: {
  135. from: 1,
  136. to: 0,
  137. duration: 500,
  138. interpolation: 'decelerate'
  139. }
  140. }
  141. }
  142. }
  143. });
  144. // await Navigation.showModal({
  145. // stack: {
  146. // children: [
  147. // {
  148. // component: {
  149. // name: 'navigation.playground.ModalScreen'
  150. // }
  151. // }
  152. // ]
  153. // }
  154. // });
  155. Navigation.setRoot({
  156. root: {
  157. stack: {
  158. id: 'TEST',
  159. children: [
  160. {
  161. component: {
  162. name: 'navigation.playground.WelcomeScreen'
  163. // name: 'navigation.playground.CustomTransitionOrigin'
  164. }
  165. }
  166. ]
  167. }
  168. }
  169. });
  170. });
  171. }
  172. module.exports = {
  173. start
  174. };