Hide navbar

This commit is contained in:
Jake Howard 2016-05-07 20:32:37 +01:00
parent 35a552b048
commit 50fa5a4a03
4 changed files with 27 additions and 6 deletions

View File

@ -0,0 +1,14 @@
import { Navigator } from 'react-native';
import _ from 'underscore';
export default class NavigationBar extends Navigator.NavigationBar {
render () {
const routes = this.props.navState.routeStack;
if (routes.length && _.last(routes).hideNavbar) {
return null;
}
return super.render();
}
}

View File

@ -8,7 +8,8 @@ import ProjectDetails from './project-details';
export default Map({ export default Map({
'LOGIN': { 'LOGIN': {
id: 'login', id: 'login',
component: Login component: Login,
hideNavbar: true
}, },
'INFO': { 'INFO': {
id: 'info', id: 'info',

View File

@ -6,13 +6,13 @@ import GlobalStyles from './settings/styles';
import BusyIndicator from 'react-native-busy-indicator'; import BusyIndicator from 'react-native-busy-indicator';
import token from './api/token'; import token from './api/token';
import { checkToken } from './api/CircleCI'; import { checkToken } from './api/CircleCI';
import NavigationBar from './components/navigation/NavigationBar';
import 'moment-duration-format'; import 'moment-duration-format';
const { const {
Navigator, Navigator,
StyleSheet, StyleSheet,
Platform,
View, View,
Alert Alert
} = React; } = React;
@ -25,7 +25,7 @@ const styles = StyleSheet.create({
}, },
container: { container: {
flex: 1, flex: 1,
marginTop: (Platform.OS === 'ios' ? 64 : 56) marginTop: GlobalStyles.get('NAVBAR_HEIGHT')
} }
}); });
@ -44,8 +44,11 @@ export default class App extends React.Component {
renderScene(route, nav) { renderScene(route, nav) {
const Component = route.component; const Component = route.component;
const props = route.props || {}; const props = route.props || {};
const navbarStyles = {
marginTop: (route.hideNavbar ? GlobalStyles.get('BANNER_HEIGHT') : GlobalStyles.get('NAVBAR_HEIGHT'))
};
return ( return (
<View style={styles.container}> <View style={[styles.container, navbarStyles]}>
<Component <Component
nav={nav} nav={nav}
currentRoute={route} currentRoute={route}
@ -93,7 +96,7 @@ export default class App extends React.Component {
renderScene={this.renderScene} renderScene={this.renderScene}
initialRoute={this.state.initialRoute} initialRoute={this.state.initialRoute}
navigationBar={ navigationBar={
<Navigator.NavigationBar <NavigationBar
style={styles.navbar} style={styles.navbar}
routeMapper={RouteMapper} /> routeMapper={RouteMapper} />
} }

View File

@ -1,3 +1,4 @@
import { Platform } from 'react-native';
import { Map } from 'immutable'; import { Map } from 'immutable';
export default Map({ export default Map({
@ -17,5 +18,7 @@ export default Map({
RETRIED: '#898989' RETRIED: '#898989'
}), }),
TITLE_FONT_SIZE: 24 TITLE_FONT_SIZE: 24,
NAVBAR_HEIGHT: (Platform.OS === 'ios' ? 64 : 56),
BANNER_HEIGHT: (Platform.OS === 'ios' ? 20 : 0),
}); });