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

Modal Status Bar Translucent #7157

Closed
Closed
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
12 changes: 8 additions & 4 deletions Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
const Platform = require('Platform');
const PropTypes = require('ReactPropTypes');
const React = require('React');
const StatusBar = require('StatusBar');
const StyleSheet = require('StyleSheet');
const View = require('View');
const deprecatedPropType = require('deprecatedPropType');

const requireNativeComponent = require('requireNativeComponent');
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);

const STATUS_BAR_HEIGHT = StatusBar.currentHeight;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-undef: 'StatusBar' is not defined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identifier StatusBar Could not resolve name

/**
* A Modal component covers the native view (e.g. UIViewController, Activity)
* that contains the React Native root.
Expand Down Expand Up @@ -56,9 +59,10 @@ class Modal extends React.Component {
return null;
}

const containerBackgroundColor = {
const containerStyles = {
backgroundColor: this.props.transparent ? 'transparent' : 'white',
};
top: Platform.OS === 'android' && Platform.Version >= 19 ? STATUS_BAR_HEIGHT : 0,
}

let animationType = this.props.animationType;
if (!animationType) {
Expand All @@ -78,7 +82,7 @@ class Modal extends React.Component {
style={styles.modal}
onStartShouldSetResponder={this._shouldSetResponder}
>
<View style={[styles.container, containerBackgroundColor]}>
<View style={[styles.container, containerStyles]}>
{this.props.children}
</View>
</RCTModalHostView>
Expand All @@ -102,4 +106,4 @@ const styles = StyleSheet.create({
}
});

module.exports = Modal;
module.exports = Modal;
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
private void updateProperties() {
Assertions.assertNotNull(mDialog, "mDialog must exist when we call updateProperties");

mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

if (mTransparent) {
mDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
} else {
Expand Down Expand Up @@ -279,3 +281,4 @@ private EventDispatcher getEventDispatcher() {
}
}
}