Skip to content

Commit

Permalink
Always update background color and bar style on Android status bar
Browse files Browse the repository at this point in the history
Summary: Changelog: [Fix] Fix status bar color not updating when navigating between two screens with the same status bar color.

Reviewed By: RSNara

Differential Revision: D19439424

fbshipit-source-id: 44388f1f94c87c12102471d72183bb6c152a46b6
  • Loading branch information
Rajat Gupta authored and facebook-github-bot committed Jan 18, 2020
1 parent 44678bb commit 9457efa
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions Libraries/Components/StatusBar/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,31 +455,21 @@ class StatusBar extends React.Component<Props> {
);
}
} else if (Platform.OS === 'android') {
if (
!oldProps ||
oldProps.barStyle.value !== mergedProps.barStyle.value
) {
NativeStatusBarManagerAndroid.setStyle(mergedProps.barStyle.value);
}
if (
!oldProps ||
oldProps.backgroundColor.value !== mergedProps.backgroundColor.value
) {
const processedColor = processColor(
mergedProps.backgroundColor.value,
//todo(T60684787): Add back optimization to only update bar style and
//background color if the new value is different from the old value.
NativeStatusBarManagerAndroid.setStyle(mergedProps.barStyle.value);
const processedColor = processColor(mergedProps.backgroundColor.value);
if (processedColor == null) {
console.warn(
`\`StatusBar._updatePropsStack\`: Color ${
mergedProps.backgroundColor.value
} parsed to null or undefined`,
);
} else {
NativeStatusBarManagerAndroid.setColor(
processedColor,
mergedProps.backgroundColor.animated,
);
if (processedColor == null) {
console.warn(
`\`StatusBar._updatePropsStack\`: Color ${
mergedProps.backgroundColor.value
} parsed to null or undefined`,
);
} else {
NativeStatusBarManagerAndroid.setColor(
processedColor,
mergedProps.backgroundColor.animated,
);
}
}
if (!oldProps || oldProps.hidden.value !== mergedProps.hidden.value) {
NativeStatusBarManagerAndroid.setHidden(mergedProps.hidden.value);
Expand Down

0 comments on commit 9457efa

Please sign in to comment.