路由配置
/**
* Author: Rahul
* Date: 25 Feb 2018
*
* Routes
* @flow
*/
import React from 'react';
import { View, Text } from 'react-native';
import { StackNavigator } from 'react-navigation';
import LoginScreen from 'src/containers/login';
import HomeScreen from 'src/containers/home';
import FeedsScreen from 'src/containers/feeds';
import { AppLogo } from 'src/components';
import { background } from 'src/styles/';
import { SIGNED_IN, SIGNED_OUT, HOME, LOGIN, FEEDS } from './constants';
const navigationOptions = {
navigationOptions: {
headerLeft: (
<View>
<Text>Hamburger</Text>
</View>
),
headerRight: (
<AppLogo />
),
headerStyle: {
paddingHorizontal: 16,
backgroundColor: background.color2,
},
gesturesEnabled: false,
},
};
const SignedOutRouteConfig = {
[LOGIN]: { screen: LoginScreen },
};
const SignedInRouteConfig = {
[HOME]: { screen: HomeScreen },
[FEEDS]: { screen: FeedsScreen },
};
const SignedOut = StackNavigator(SignedOutRouteConfig, navigationOptions);
const SignedIn = StackNavigator(SignedInRouteConfig, navigationOptions);
const createRootNavigator = (signedIn: boolean = false) => StackNavigator(
{
[SIGNED_IN]: {
screen: SignedIn,
navigationOptions: {
gesturesEnabled: false,
header: null,
},
},
[SIGNED_OUT]: {
screen: SignedOut,
navigationOptions: {
gesturesEnabled: false,
header: null,
},
},
},
{
initialRouteName: signedIn ? SIGNED_IN : SIGNED_OUT,
}
);
export default createRootNavigator;
如何将标题内容居中并从顶部去除不必要的空间?
PS我已经尝试将高度设置为headerStyle