react-native-navigation的迁移库

app.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. bottomTab: {
  26. iconColor: '#1B4C77',
  27. selectedIconColor: '#0f0',
  28. textColor: '#1B4C77',
  29. selectedTextColor: '#0f0',
  30. fontFamily: 'HelveticaNeue-Italic',
  31. fontSize: 13
  32. },
  33. _animations: {
  34. push: {
  35. waitForRender: false,
  36. }
  37. },
  38. _animations: {
  39. startApp: {
  40. y: {
  41. from: 1000,
  42. to: 0,
  43. duration: 500,
  44. interpolation: 'accelerate',
  45. },
  46. alpha: {
  47. from: 0,
  48. to: 1,
  49. duration: 500,
  50. interpolation: 'accelerate'
  51. }
  52. },
  53. push: {
  54. topBar: {
  55. id: 'TEST',
  56. alpha: {
  57. from: 0,
  58. to: 1,
  59. duration: 500,
  60. interpolation: 'accelerate'
  61. }
  62. },
  63. bottomTabs: {
  64. y: {
  65. from: 1000,
  66. to: 0,
  67. duration: 500,
  68. interpolation: 'decelerate',
  69. },
  70. alpha: {
  71. from: 0,
  72. to: 1,
  73. duration: 500,
  74. interpolation: 'decelerate'
  75. }
  76. },
  77. content: {
  78. y: {
  79. from: 1000,
  80. to: 0,
  81. duration: 500,
  82. interpolation: 'accelerate',
  83. },
  84. alpha: {
  85. from: 0,
  86. to: 1,
  87. duration: 500,
  88. interpolation: 'accelerate'
  89. }
  90. }
  91. },
  92. pop: {
  93. topBar: {
  94. id: 'TEST',
  95. alpha: {
  96. from: 1,
  97. to: 0,
  98. duration: 500,
  99. interpolation: 'accelerate'
  100. }
  101. },
  102. bottomTabs: {
  103. y: {
  104. from: 0,
  105. to: 100,
  106. duration: 500,
  107. interpolation: 'accelerate',
  108. },
  109. alpha: {
  110. from: 1,
  111. to: 0,
  112. duration: 500,
  113. interpolation: 'accelerate'
  114. }
  115. },
  116. bottomTabs: {
  117. y: {
  118. from: 0,
  119. to: 100,
  120. duration: 500,
  121. interpolation: 'decelerate',
  122. },
  123. alpha: {
  124. from: 1,
  125. to: 0,
  126. duration: 500,
  127. interpolation: 'decelerate'
  128. }
  129. },
  130. content: {
  131. y: {
  132. from: 0,
  133. to: 1000,
  134. duration: 500,
  135. interpolation: 'decelerate',
  136. },
  137. alpha: {
  138. from: 1,
  139. to: 0,
  140. duration: 500,
  141. interpolation: 'decelerate'
  142. }
  143. }
  144. }
  145. }
  146. });
  147. // await Navigation.showModal({
  148. // stack: {
  149. // children: [
  150. // {
  151. // component: {
  152. // name: 'navigation.playground.ModalScreen'
  153. // }
  154. // }
  155. // ]
  156. // }
  157. // });
  158. Navigation.setRoot({
  159. root: {
  160. stack: {
  161. id: 'TEST',
  162. children: [
  163. {
  164. component: {
  165. name: 'navigation.playground.WelcomeScreen'
  166. // name: 'navigation.playground.CustomTransitionOrigin'
  167. }
  168. }
  169. ]
  170. }
  171. }
  172. });
  173. });
  174. }
  175. module.exports = {
  176. start
  177. };