Route Config
/**
* 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;
Adding screenshots for clarity:
How can I center the header content and get rid of the unnecessary space from the top?
P.S I have already tried setting the height to headerStyle
Try placing this code in your App.js file:
import { SafeAreaView } from "react-navigation";
if (Platform.OS === "android") {
// removes extra space at top of header on android
SafeAreaView.setStatusBarHeight(0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With