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

isModalInPresentation prop for iOS >= 13 #29249

Closed
wants to merge 7 commits into from
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
7 changes: 7 additions & 0 deletions Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export type Props = $ReadOnly<{|
* See https://reactnative.dev/docs/modal.html#transparent
*/
transparent?: ?boolean,

/**
* The `isModalInPresentation` prop determines whether whether the view controller
* enforces a modal behavior.
*/
isModalInPresentation?: ?boolean,

/**
* The `statusBarTranslucent` prop determines whether your modal should go under
Expand Down Expand Up @@ -212,6 +218,7 @@ class Modal extends React.Component<Props> {
animationType={animationType}
presentationStyle={presentationStyle}
transparent={this.props.transparent}
isModalInPresentation={this.props.isModalInPresentation}
hardwareAccelerated={this.props.hardwareAccelerated}
onRequestClose={this.props.onRequestClose}
onShow={this.props.onShow}
Expand Down
6 changes: 6 additions & 0 deletions Libraries/Modal/RCTModalHostViewNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ type NativeProps = $ReadOnly<{|
* See https://reactnative.dev/docs/modal.html#transparent
*/
transparent?: WithDefault<boolean, false>,

/**
* The `isModalInPresentation` callback is used to indicate whether the view controller enforces a modal behavior.
*
*/
isModalInPresentation?: WithDefault<boolean, false>,

/**
* The `statusBarTranslucent` prop determines whether your modal should go under
Expand Down
2 changes: 1 addition & 1 deletion React/Views/RCTModalHostView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@property (nonatomic, copy) NSString *animationType;
@property (nonatomic, assign) UIModalPresentationStyle presentationStyle;
@property (nonatomic, assign, getter=isTransparent) BOOL transparent;

@property(nonatomic, getter=isModalInPresentation) BOOL modalInPresentation;
@property (nonatomic, copy) RCTDirectEventBlock onShow;

@property (nonatomic, copy) NSNumber *identifier;
Expand Down
12 changes: 12 additions & 0 deletions React/Views/RCTModalHostView.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ - (void)setTransparent:(BOOL)transparent
transparent ? UIModalPresentationOverFullScreen : UIModalPresentationFullScreen;
}

- (BOOL)isModalInPresentation
{
return _modalViewController.modalInPresentation;
}

- (void)setIsModalInPresentation:(BOOL)isInPresentation
{
if (@available(iOS 13.0, *)) {
_modalViewController.modalInPresentation = isInPresentation;
}
}

#if !TARGET_OS_TV
- (UIInterfaceOrientationMask)supportedOrientationsMask
{
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTModalHostViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ - (void)invalidate

RCT_EXPORT_VIEW_PROPERTY(animationType, NSString)
RCT_EXPORT_VIEW_PROPERTY(presentationStyle, UIModalPresentationStyle)
RCT_EXPORT_VIEW_PROPERTY(isModalInPresentation, BOOL)
RCT_EXPORT_VIEW_PROPERTY(transparent, BOOL)
RCT_EXPORT_VIEW_PROPERTY(onShow, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(identifier, NSNumber)
Expand Down