Skip to content

Commit

Permalink
Improve statusbar color handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMachado committed Dec 23, 2016
1 parent c328e98 commit 0492021
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
15 changes: 11 additions & 4 deletions AppIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
StyleSheet,
Text,
View,
TouchableOpacity,
Animated,
Dimensions,
Image,
Expand Down Expand Up @@ -102,7 +101,7 @@ const defaulStyles = {
justifyContent: 'center',
alignItems: 'center',
},
}
};

export default class AppIntro extends Component {
constructor(props) {
Expand Down Expand Up @@ -333,7 +332,11 @@ export default class AppIntro extends Component {
}

if (this.isToTintStatusBar()) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[0].backgroundColor, -0.3), false);
const statusBarColor = this.props.pageArray[0].statusBarColor || this.props.pageArray[0].backgroundColor || undefined;

if (statusBarColor) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
}
}

return (
Expand All @@ -345,7 +348,11 @@ export default class AppIntro extends Component {
renderPagination={this.renderPagination}
onMomentumScrollEnd={(e, state) => {
if (this.isToTintStatusBar()) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[state.index].backgroundColor, -0.3), false);
const statusBarColor = this.props.pageArray[state.index].statusBarColor || this.props.pageArray[state.index].backgroundColor || undefined;

if (statusBarColor) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
}
}

this.props.onSlideChange(state.index, state.total);
Expand Down
15 changes: 11 additions & 4 deletions Example/AppIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
StyleSheet,
Text,
View,
TouchableOpacity,
Animated,
Dimensions,
Image,
Expand Down Expand Up @@ -102,7 +101,7 @@ const defaulStyles = {
justifyContent: 'center',
alignItems: 'center',
},
}
};

export default class AppIntro extends Component {
constructor(props) {
Expand Down Expand Up @@ -333,7 +332,11 @@ export default class AppIntro extends Component {
}

if (this.isToTintStatusBar()) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[0].backgroundColor, -0.3), false);
const statusBarColor = this.props.pageArray[0].statusBarColor || this.props.pageArray[0].backgroundColor || undefined;

if (statusBarColor) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
}
}

return (
Expand All @@ -345,7 +348,11 @@ export default class AppIntro extends Component {
renderPagination={this.renderPagination}
onMomentumScrollEnd={(e, state) => {
if (this.isToTintStatusBar()) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[state.index].backgroundColor, -0.3), false);
const statusBarColor = this.props.pageArray[state.index].statusBarColor || this.props.pageArray[state.index].backgroundColor || undefined;

if (statusBarColor) {
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
}
}

this.props.onSlideChange(state.index, state.total);
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Example extends Component {
width: 109 * 2.5,
},
backgroundColor: '#fa931d',
statusBarColor: '#fa931d', // Specify if you don't want to be inferred. If you don't specify a 30% darker color will be inferred from your background color.
fontColor: '#fff',
level: 10,
}, {
Expand Down

0 comments on commit 0492021

Please sign in to comment.