react-native-navigation的迁移库

app.js 3.8KB

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