react-native-navigation的迁移库

app.js 2.3KB

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