Skip to content

Add support to iOSHeight and added iPhone X support and update README.md #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ That's it, you're ready to go!
- **tintColor** - (String) - Status bar tint color
- **hideAnimation** - ('fade', 'slide', 'none') - Type of statusBar hide animation
- **showAnimation** - ('fade', 'slide', 'none') - Type of statusBar show animation
- **iOSHeight** - (Boolean)
- **leftButton / rightButton** - (Object, React Element) - Either plain object with configuration, or React Element which will be used as a custom left/right button element. Configuration object has following keys:
- **title** - (String) - Button's title
- **tintColor** - (String) - Button's text color
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Text,
View,
Platform,
DeviceInfo,
} from 'react-native';
import PropTypes from 'prop-types';
import ViewPropTypes from './lib';
Expand Down Expand Up @@ -31,6 +32,7 @@ const StatusBarShape = {
tintColor: PropTypes.string,
hideAnimation: PropTypes.oneOf(['fade', 'slide', 'none']),
showAnimation: PropTypes.oneOf(['fade', 'slide', 'none']),
iOSHeight: PropTypes.bool,
};

function getButtonElement(data, style) {
Expand Down Expand Up @@ -59,7 +61,8 @@ function getTitleElement(data) {

return (
<View style={styles.navBarTitleContainer}>
<Text ellipsizeMode={data.ellipsizeMode} numberOfLines={data.numberOfLines} style={[styles.navBarTitleText, data.style, colorStyle]}>
<Text ellipsizeMode={data.ellipsizeMode} numberOfLines={data.numberOfLines}
style={[styles.navBarTitleText, data.style, colorStyle]}>
{data.title}
</Text>
</View>
Expand Down Expand Up @@ -100,6 +103,7 @@ export default class NavigationBar extends Component {
hidden: false,
hideAnimation: 'slide',
showAnimation: 'slide',
iOSHeight: true,
},
containerStyle: {},
};
Expand Down Expand Up @@ -138,14 +142,15 @@ 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') {
const customStatusBarTintColor = this.props.statusBar.tintColor ? { backgroundColor: this.props.statusBar.tintColor } : null;

const statusBarHeight = { height: this.props.statusBar.iOSHeight ? DeviceInfo.isIPhoneX_deprecated ? 44 : 20 : 0 };

statusBar = !this.props.statusBar.hidden ?
<View style={[styles.statusBar, customStatusBarTintColor]} /> : null;
<View style={[customStatusBarTintColor, statusBarHeight]}/> : null;
}

return (
Expand Down
4 changes: 0 additions & 4 deletions styles.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
const NAV_BAR_HEIGHT = 44;
const STATUS_BAR_HEIGHT = 20;

module.exports = {
navBarContainer: {
backgroundColor: 'white',
},
statusBar: {
height: STATUS_BAR_HEIGHT,
},
navBar: {
height: NAV_BAR_HEIGHT,
flexDirection: 'row',
Expand Down