From 4cd1bced9850c2cccf3a83d19c1a9b232a09afda Mon Sep 17 00:00:00 2001 From: Artem Russkikh Date: Tue, 13 Mar 2018 12:23:41 +0500 Subject: [PATCH] Add option to remove and not manage status bar completely --- README.md | 2 +- index.js | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2bd4a1c..b915110 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ That's it, you're ready to go! - **style** - (Object, Array) - Style object or array of style objects - **containerStyle** - (Object) - Style object for styling navbar container - **tintColor** - (String) - NavigationBar's tint color -- **statusBar** - (Object): +- **statusBar** - (Object, null): - **style** - ('light-content' or 'default') - Style of statusBar - **hidden** - (Boolean) - **tintColor** - (String) - Status bar tint color diff --git a/index.js b/index.js index d132036..f9c2770 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,10 @@ export default class NavigationBar extends Component { static propTypes = { style: ViewPropTypes.style, tintColor: PropTypes.string, - statusBar: PropTypes.shape(StatusBarShape), + statusBar: PropTypes.oneOfType([ + PropTypes.shape(StatusBarShape), + PropTypes.oneOf([null, false]), + ]), leftButton: PropTypes.oneOfType([ PropTypes.shape(ButtonShape), PropTypes.element, @@ -114,7 +117,7 @@ export default class NavigationBar extends Component { customizeStatusBar() { const { statusBar } = this.props; - if (Platform.OS === 'ios') { + if (Platform.OS === 'ios' && statusBar) { if (statusBar.style) { StatusBar.setBarStyle(statusBar.style); } @@ -138,14 +141,14 @@ export default class NavigationBar extends Component { } = this.props; const customTintColor = tintColor ? { backgroundColor: tintColor } : null; - const customStatusBarTintColor = this.props.statusBar.tintColor ? - { backgroundColor: this.props.statusBar.tintColor } : null; - let statusBar = null; - if (Platform.OS === 'ios') { + if (Platform.OS === 'ios' && this.props.statusBar) { statusBar = !this.props.statusBar.hidden ? - : null; + : null; } return (