react-native-navigation的迁移库

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. testID: testIDs.LAYOUTS_TAB
  50. }
  51. }
  52. }
  53. },
  54. {
  55. stack: {
  56. children: [
  57. {
  58. component: {
  59. name: 'Options'
  60. }
  61. }
  62. ],
  63. options: {
  64. topBar: {
  65. title: {
  66. text: 'Default Title'
  67. }
  68. },
  69. bottomTab: {
  70. text: 'Options',
  71. icon: require('../img/options.png'),
  72. testID: testIDs.OPTIONS_TAB
  73. }
  74. }
  75. }
  76. },
  77. {
  78. stack: {
  79. children: [
  80. {
  81. component: {
  82. name: 'Navigation'
  83. }
  84. }
  85. ]
  86. }
  87. }
  88. ]
  89. }
  90. }
  91. });
  92. });
  93. }
  94. module.exports = {
  95. start
  96. };