react-native-navigation的迁移库

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