'use strict'
import React, { Component } from 'react'
import { Platform } from 'react-native'
import { createStackNavigator } from 'react-navigation'

import DesktopHome from './Home'
import setPower from './setPower'

const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;

const HomeStack = createStackNavigator({
    DesktopHome: {
        screen: DesktopHome,
        navigationOptions: {
            title: '电金睛'
        },
    },
    setPower: {
        screen: setPower,
        navigationOptions: {
            title: '设置'
        },
    },
},
{
    defaultNavigationOptions: {
        headerStyle: {
            backgroundColor: "#5394e4",
            borderBottomWidth: 0,
            borderColor: '#ccc',
            fontColor: '#fff',
            elevation: 0,
            height: 40
        },
        headerTintColor: '#ffffff',
        headerTitleStyle: {
            fontWeight: 'normal',
            fontSize: 18,
            color: '#ffffff',
            alignSelf:'center',
            textAlign: 'center',
            flex:1
        },
        headerTitleContainerStyle:{
            left: TITLE_OFFSET,
            right: TITLE_OFFSET,
        },
        headerBackTitle: null         // ~注意~ 这个地方是隐藏返回按钮文字的
    }
})

HomeStack.navigationOptions = ({ navigation }) => {  // ~注意~ 如果想实现隐藏Tabbar的功能要调用这个方法
    let tabBarVisible = true
    if (navigation.state.index > 0) {
        tabBarVisible = false
    }
    return {
        tabBarVisible
    }
}


module.exports = HomeStack
