mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
Add onShow callback for RCTModalHostView
Summary: Added ability to include a callback to the modal. The callback is invoked when the modal is shown. Reviewed By: javache Differential Revision: D3005212 fb-gh-sync-id: 12648e17bd1cf831daf65529b87ae8cfdb901c65 shipit-source-id: 12648e17bd1cf831daf65529b87ae8cfdb901c65
This commit is contained in:
parent
44997b47e2
commit
8c25181c44
@ -49,6 +49,7 @@ class Modal extends React.Component {
|
||||
animated={this.props.animated}
|
||||
transparent={this.props.transparent}
|
||||
onDismiss={this.props.onDismiss}
|
||||
onShow={this.props.onShow}
|
||||
style={styles.modal}>
|
||||
<View style={[styles.container, containerBackgroundColor]}>
|
||||
{this.props.children}
|
||||
@ -63,6 +64,7 @@ Modal.propTypes = {
|
||||
transparent: PropTypes.bool,
|
||||
visible: PropTypes.bool,
|
||||
onDismiss: PropTypes.func,
|
||||
onShow: PropTypes.func,
|
||||
};
|
||||
|
||||
Modal.defaultProps = {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "RCTInvalidating.h"
|
||||
#import "RCTView.h"
|
||||
|
||||
@class RCTBridge;
|
||||
|
||||
@ -18,6 +19,8 @@
|
||||
@property (nonatomic, assign, getter=isAnimated) BOOL animated;
|
||||
@property (nonatomic, assign, getter=isTransparent) BOOL transparent;
|
||||
|
||||
@property (nonatomic, copy) RCTDirectEventBlock onShow;
|
||||
|
||||
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
@ -86,7 +86,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
||||
|
||||
if (!_isPresented && self.window) {
|
||||
RCTAssert(self.reactViewController, @"Can't present modal view controller without a presenting view controller");
|
||||
[self.reactViewController presentViewController:_modalViewController animated:self.animated completion:nil];
|
||||
[self.reactViewController presentViewController:_modalViewController animated:self.animated completion:^{
|
||||
if (_onShow) {
|
||||
_onShow(nil);
|
||||
}
|
||||
}];
|
||||
_isPresented = YES;
|
||||
}
|
||||
}
|
||||
|
@ -40,5 +40,6 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(animated, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(transparent, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(onShow, RCTDirectEventBlock)
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user