Index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict'
  2. import React, { Component } from 'react'
  3. import { Platform } from 'react-native'
  4. import { createStackNavigator } from 'react-navigation'
  5. import DesktopHome from './Home'
  6. import setPower from './setPower'
  7. const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;
  8. const HomeStack = createStackNavigator({
  9. DesktopHome: {
  10. screen: DesktopHome,
  11. navigationOptions: {
  12. title: '电金睛'
  13. },
  14. },
  15. setPower: {
  16. screen: setPower,
  17. navigationOptions: {
  18. title: '设置'
  19. },
  20. },
  21. },
  22. {
  23. defaultNavigationOptions: {
  24. headerStyle: {
  25. backgroundColor: "#5394e4",
  26. borderBottomWidth: 0,
  27. borderColor: '#ccc',
  28. fontColor: '#fff',
  29. elevation: 0,
  30. height: 40
  31. },
  32. headerTintColor: '#ffffff',
  33. headerTitleStyle: {
  34. fontWeight: 'normal',
  35. fontSize: 18,
  36. color: '#ffffff',
  37. alignSelf:'center',
  38. textAlign: 'center',
  39. flex:1
  40. },
  41. headerTitleContainerStyle:{
  42. left: TITLE_OFFSET,
  43. right: TITLE_OFFSET,
  44. },
  45. headerBackTitle: null // ~注意~ 这个地方是隐藏返回按钮文字的
  46. }
  47. })
  48. HomeStack.navigationOptions = ({ navigation }) => { // ~注意~ 如果想实现隐藏Tabbar的功能要调用这个方法
  49. let tabBarVisible = true
  50. if (navigation.state.index > 0) {
  51. tabBarVisible = false
  52. }
  53. return {
  54. tabBarVisible
  55. }
  56. }
  57. module.exports = HomeStack