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}
|
animated={this.props.animated}
|
||||||
transparent={this.props.transparent}
|
transparent={this.props.transparent}
|
||||||
onDismiss={this.props.onDismiss}
|
onDismiss={this.props.onDismiss}
|
||||||
|
onShow={this.props.onShow}
|
||||||
style={styles.modal}>
|
style={styles.modal}>
|
||||||
<View style={[styles.container, containerBackgroundColor]}>
|
<View style={[styles.container, containerBackgroundColor]}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
@ -63,6 +64,7 @@ Modal.propTypes = {
|
|||||||
transparent: PropTypes.bool,
|
transparent: PropTypes.bool,
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
onDismiss: PropTypes.func,
|
onDismiss: PropTypes.func,
|
||||||
|
onShow: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
Modal.defaultProps = {
|
Modal.defaultProps = {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import "RCTInvalidating.h"
|
#import "RCTInvalidating.h"
|
||||||
|
#import "RCTView.h"
|
||||||
|
|
||||||
@class RCTBridge;
|
@class RCTBridge;
|
||||||
|
|
||||||
@ -18,6 +19,8 @@
|
|||||||
@property (nonatomic, assign, getter=isAnimated) BOOL animated;
|
@property (nonatomic, assign, getter=isAnimated) BOOL animated;
|
||||||
@property (nonatomic, assign, getter=isTransparent) BOOL transparent;
|
@property (nonatomic, assign, getter=isTransparent) BOOL transparent;
|
||||||
|
|
||||||
|
@property (nonatomic, copy) RCTDirectEventBlock onShow;
|
||||||
|
|
||||||
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -86,7 +86,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
|
|||||||
|
|
||||||
if (!_isPresented && self.window) {
|
if (!_isPresented && self.window) {
|
||||||
RCTAssert(self.reactViewController, @"Can't present modal view controller without a presenting view controller");
|
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;
|
_isPresented = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,5 +40,6 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
RCT_EXPORT_VIEW_PROPERTY(animated, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(animated, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(transparent, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(transparent, BOOL)
|
||||||
|
RCT_EXPORT_VIEW_PROPERTY(onShow, RCTDirectEventBlock)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user