Skip to content
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

Improve StatusBar color handling #56

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
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', // If you don't specify, a 30% darker color will be inferred from your background color.
fontColor: '#fff',
level: 10,
}, {
Expand Down