root.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import React from 'react';
  2. import {
  3. View,
  4. Text,
  5. StyleSheet,
  6. DeviceEventEmitter
  7. } from 'react-native';
  8. import {
  9. createAppContainer,
  10. createSwitchNavigator
  11. } from 'react-navigation';
  12. import {createMaterialBottomTabNavigator} from 'react-navigation-material-bottom-tabs';
  13. import Welcome from './pages/Welcome'
  14. import SalesHome from './pages/Sales/Index'
  15. import MineHome from './pages/Mine/Index'
  16. import Outside from './pages/Outside/Index';
  17. const styles = StyleSheet.create({
  18. iconFont: {
  19. fontFamily:'iconfont',
  20. fontSize: 24,
  21. color: '#757575'
  22. },
  23. iconFontFocused: {
  24. fontFamily:'iconfont',
  25. fontSize: 24,
  26. color: '#2b90ea'
  27. }
  28. })
  29. const TabStack = createMaterialBottomTabNavigator({
  30. SalesHome: {
  31. screen: SalesHome,
  32. navigationOptions: {
  33. tabBarLabel: '工作台',
  34. tabBarIcon: ({ focused, horizontal, tintColor }) => (
  35. <Text style={focused ? styles.iconFontFocused : styles.iconFont}>{'\ue607'}</Text>
  36. ),
  37. tabBarOnPress: ({navigation, defaultHandler}) => {
  38. DeviceEventEmitter.emit("ShowWhiteStatusBar", {});
  39. defaultHandler();
  40. },
  41. }
  42. },
  43. MIne: {
  44. screen: MineHome,
  45. navigationOptions: {
  46. tabBarLabel: '我的',
  47. tabBarIcon: ({ focused, horizontal, tintColor }) => (
  48. <Text style={focused ? styles.iconFontFocused : styles.iconFont}>{'\ue619'}</Text>
  49. ),
  50. tabBarOnPress: ({navigation, defaultHandler}) => {
  51. DeviceEventEmitter.emit("ShowWhiteStatusBar", {});
  52. defaultHandler();
  53. },
  54. }
  55. },
  56. },
  57. {
  58. shifting: false,
  59. labeled: true,
  60. initialRouteName: 'SalesHome',
  61. activeColor: '#2b90ea',
  62. activeTintColor: '#cd040d',
  63. inactiveTintColor: '#2312cd',
  64. inactiveColor: '#550a05',
  65. barStyle: { backgroundColor: '#fff' },
  66. },
  67. // {
  68. // defaultNavigationOptions: ({ navigation }) => ({
  69. // tabBarIcon: ({ focused }) => {
  70. // const { routeName } = navigation.state
  71. // return tabarIcons[routeName].render(focused)
  72. // }
  73. // }),
  74. // tabBarOptions: {
  75. // activeTintColor: '#03C762',
  76. // inactiveTintColor: '#333'
  77. // },
  78. // }
  79. )
  80. // const MainRoot=createStackNavigator({
  81. // Main: {
  82. // screen: TabStack,
  83. // },
  84. // // Detail: {
  85. // // screen: Detail,
  86. // // navigationOptions: {
  87. // // headerTitle: '详情页'
  88. // // }
  89. // // }
  90. // }, {
  91. // initialRouteName: 'Main',
  92. // })
  93. const RootStack = createAppContainer(createSwitchNavigator({
  94. Main: {
  95. screen: TabStack,
  96. },
  97. Welcome:{
  98. screen:Welcome,
  99. },
  100. Login: { screen: Outside },
  101. },{
  102. initialRouteName:'Welcome'
  103. }))
  104. export default RootStack;