Skip to content

Commit 0492021

Browse files
committed
Improve statusbar color handling
1 parent c328e98 commit 0492021

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

AppIntro.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
StyleSheet,
66
Text,
77
View,
8-
TouchableOpacity,
98
Animated,
109
Dimensions,
1110
Image,
@@ -102,7 +101,7 @@ const defaulStyles = {
102101
justifyContent: 'center',
103102
alignItems: 'center',
104103
},
105-
}
104+
};
106105

107106
export default class AppIntro extends Component {
108107
constructor(props) {
@@ -333,7 +332,11 @@ export default class AppIntro extends Component {
333332
}
334333

335334
if (this.isToTintStatusBar()) {
336-
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[0].backgroundColor, -0.3), false);
335+
const statusBarColor = this.props.pageArray[0].statusBarColor || this.props.pageArray[0].backgroundColor || undefined;
336+
337+
if (statusBarColor) {
338+
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
339+
}
337340
}
338341

339342
return (
@@ -345,7 +348,11 @@ export default class AppIntro extends Component {
345348
renderPagination={this.renderPagination}
346349
onMomentumScrollEnd={(e, state) => {
347350
if (this.isToTintStatusBar()) {
348-
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[state.index].backgroundColor, -0.3), false);
351+
const statusBarColor = this.props.pageArray[state.index].statusBarColor || this.props.pageArray[state.index].backgroundColor || undefined;
352+
353+
if (statusBarColor) {
354+
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
355+
}
349356
}
350357

351358
this.props.onSlideChange(state.index, state.total);

Example/AppIntro.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
StyleSheet,
66
Text,
77
View,
8-
TouchableOpacity,
98
Animated,
109
Dimensions,
1110
Image,
@@ -102,7 +101,7 @@ const defaulStyles = {
102101
justifyContent: 'center',
103102
alignItems: 'center',
104103
},
105-
}
104+
};
106105

107106
export default class AppIntro extends Component {
108107
constructor(props) {
@@ -333,7 +332,11 @@ export default class AppIntro extends Component {
333332
}
334333

335334
if (this.isToTintStatusBar()) {
336-
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[0].backgroundColor, -0.3), false);
335+
const statusBarColor = this.props.pageArray[0].statusBarColor || this.props.pageArray[0].backgroundColor || undefined;
336+
337+
if (statusBarColor) {
338+
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
339+
}
337340
}
338341

339342
return (
@@ -345,7 +348,11 @@ export default class AppIntro extends Component {
345348
renderPagination={this.renderPagination}
346349
onMomentumScrollEnd={(e, state) => {
347350
if (this.isToTintStatusBar()) {
348-
StatusBar.setBackgroundColor(this.shadeStatusBarColor(this.props.pageArray[state.index].backgroundColor, -0.3), false);
351+
const statusBarColor = this.props.pageArray[state.index].statusBarColor || this.props.pageArray[state.index].backgroundColor || undefined;
352+
353+
if (statusBarColor) {
354+
StatusBar.setBackgroundColor(this.shadeStatusBarColor(statusBarColor, -0.3), false);
355+
}
349356
}
350357

351358
this.props.onSlideChange(state.index, state.total);

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Example extends Component {
5454
width: 109 * 2.5,
5555
},
5656
backgroundColor: '#fa931d',
57+
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.
5758
fontColor: '#fff',
5859
level: 10,
5960
}, {

0 commit comments

Comments
 (0)