Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13215 from dnlfrst/fix-theme-color-modal-backdrop
Adapt status bar color to modal backdrop
- Loading branch information
Showing
5 changed files
with
149 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import {StatusBar} from 'react-native'; | ||
import themeColors from '../../styles/themes/default'; | ||
|
||
export default class CustomStatusBar extends React.Component { | ||
componentDidMount() { | ||
StatusBar.setBarStyle('light-content', true); | ||
|
||
// For mobile web browsers, match the default status bar color to the app's background color | ||
document.querySelector('meta[name=theme-color]').content = themeColors.appBG; | ||
} | ||
|
||
render() { | ||
return <StatusBar />; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import withWindowDimensions from '../withWindowDimensions'; | ||
import BaseModal from './BaseModal'; | ||
import {propTypes, defaultProps} from './modalPropTypes'; | ||
import * as StyleUtils from '../../styles/StyleUtils'; | ||
import themeColors from '../../styles/themes/default'; | ||
|
||
const Modal = (props) => { | ||
const setStatusBarColor = (color = themeColors.appBG) => { | ||
if (!props.fullscreen) { | ||
return; | ||
} | ||
|
||
// Change the color of the status bar to align with the modal's backdrop (refer to https://github.com/Expensify/App/issues/12156). | ||
document.querySelector('meta[name=theme-color]').content = color; | ||
}; | ||
|
||
const hideModal = () => { | ||
setStatusBarColor(); | ||
props.onModalHide(); | ||
}; | ||
|
||
const showModal = () => { | ||
setStatusBarColor(StyleUtils.getThemeBackgroundColor()); | ||
props.onModalShow(); | ||
}; | ||
|
||
return ( | ||
<BaseModal | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
onModalHide={hideModal} | ||
onModalShow={showModal} | ||
> | ||
{props.children} | ||
</BaseModal> | ||
); | ||
}; | ||
|
||
Modal.propTypes = propTypes; | ||
Modal.defaultProps = defaultProps; | ||
Modal.displayName = 'Modal'; | ||
export default withWindowDimensions(Modal); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters