From 50fa5a4a03e27427effa13fc6b1c703fa07c54d6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 7 May 2016 20:32:37 +0100 Subject: [PATCH] Hide navbar --- app/components/navigation/NavigationBar.js | 14 ++++++++++++++ app/components/routes/RouteMaster.js | 3 ++- app/index.js | 11 +++++++---- app/settings/styles.js | 5 ++++- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 app/components/navigation/NavigationBar.js diff --git a/app/components/navigation/NavigationBar.js b/app/components/navigation/NavigationBar.js new file mode 100644 index 0000000..84a6411 --- /dev/null +++ b/app/components/navigation/NavigationBar.js @@ -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(); + } +} diff --git a/app/components/routes/RouteMaster.js b/app/components/routes/RouteMaster.js index 28257d6..5707583 100644 --- a/app/components/routes/RouteMaster.js +++ b/app/components/routes/RouteMaster.js @@ -8,7 +8,8 @@ import ProjectDetails from './project-details'; export default Map({ 'LOGIN': { id: 'login', - component: Login + component: Login, + hideNavbar: true }, 'INFO': { id: 'info', diff --git a/app/index.js b/app/index.js index 61140c6..f470b83 100644 --- a/app/index.js +++ b/app/index.js @@ -6,13 +6,13 @@ import GlobalStyles from './settings/styles'; import BusyIndicator from 'react-native-busy-indicator'; import token from './api/token'; import { checkToken } from './api/CircleCI'; +import NavigationBar from './components/navigation/NavigationBar'; import 'moment-duration-format'; const { Navigator, StyleSheet, - Platform, View, Alert } = React; @@ -25,7 +25,7 @@ const styles = StyleSheet.create({ }, container: { 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) { const Component = route.component; const props = route.props || {}; + const navbarStyles = { + marginTop: (route.hideNavbar ? GlobalStyles.get('BANNER_HEIGHT') : GlobalStyles.get('NAVBAR_HEIGHT')) + }; return ( - + } diff --git a/app/settings/styles.js b/app/settings/styles.js index 43507c7..408e130 100644 --- a/app/settings/styles.js +++ b/app/settings/styles.js @@ -1,3 +1,4 @@ +import { Platform } from 'react-native'; import { Map } from 'immutable'; export default Map({ @@ -17,5 +18,7 @@ export default Map({ RETRIED: '#898989' }), - TITLE_FONT_SIZE: 24 + TITLE_FONT_SIZE: 24, + NAVBAR_HEIGHT: (Platform.OS === 'ios' ? 64 : 56), + BANNER_HEIGHT: (Platform.OS === 'ios' ? 20 : 0), });