react-native-navigation的迁移库

app.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // @ts-check
  2. const { Navigation } = require('react-native-navigation');
  3. const { registerScreens } = require('./screens');
  4. const { Platform } = require('react-native');
  5. const { setDefaultOptions } = require('./commons/Options')
  6. const testIDs = require('./testIDs');
  7. const Screens = require('./screens/Screens');
  8. if (Platform.OS === 'android') {
  9. alert = (title) => {
  10. Navigation.showOverlay({
  11. component: {
  12. name: Screens.Alert,
  13. passProps: {
  14. title
  15. },
  16. options: {
  17. layout: {
  18. componentBackgroundColor: 'transparent'
  19. },
  20. overlay: {
  21. interceptTouchOutside: true
  22. }
  23. }
  24. }
  25. });
  26. };
  27. }
  28. function start() {
  29. registerScreens();
  30. Navigation.events().registerAppLaunchedListener(async () => {
  31. setDefaultOptions();
  32. Navigation.setRoot({
  33. root: {
  34. bottomTabs: {
  35. children: [
  36. {
  37. stack: {
  38. children: [
  39. {
  40. component: {
  41. name: 'Layouts'
  42. }
  43. }
  44. ],
  45. options: {
  46. bottomTab: {
  47. text: 'Layouts',
  48. icon: require('../img/layouts.png'),
  49. selectedIcon: require('../img/layouts_selected.png'),
  50. testID: testIDs.LAYOUTS_TAB
  51. }
  52. }
  53. }
  54. },
  55. {
  56. stack: {
  57. children: [
  58. {
  59. component: {
  60. name: 'Options'
  61. }
  62. }
  63. ],
  64. options: {
  65. topBar: {
  66. title: {
  67. text: 'Default Title'
  68. }
  69. },
  70. bottomTab: {
  71. text: 'Options',
  72. icon: require('../img/options.png'),
  73. selectedIcon: require('../img/options_selected.png'),
  74. testID: testIDs.OPTIONS_TAB
  75. }
  76. }
  77. }
  78. },
  79. {
  80. stack: {
  81. children: [
  82. {
  83. component: {
  84. name: 'Navigation'
  85. }
  86. }
  87. ]
  88. }
  89. }
  90. ]
  91. }
  92. }
  93. });
  94. });
  95. }
  96. module.exports = {
  97. start
  98. };