From 9a355a659277624990820a8bb7785e9123f9a329 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Mon, 2 Sep 2024 21:43:43 +0800 Subject: [PATCH] fix(ios): onShow event of modal component not working (#4012) remove obsolete onLayout property of shadowView --- .../src/components/Modal/index.jsx | 1 + .../native/ios/renderer/HippyComponentData.mm | 6 ++--- .../native/ios/renderer/HippyUIManager.mm | 26 +------------------ .../renderer/component/view/HippyShadowView.h | 1 - .../component/view/HippyViewManager.mm | 2 -- 5 files changed, 4 insertions(+), 32 deletions(-) diff --git a/driver/js/examples/hippy-react-demo/src/components/Modal/index.jsx b/driver/js/examples/hippy-react-demo/src/components/Modal/index.jsx index 7b2f772c5d3..1d59f0d1332 100644 --- a/driver/js/examples/hippy-react-demo/src/components/Modal/index.jsx +++ b/driver/js/examples/hippy-react-demo/src/components/Modal/index.jsx @@ -154,6 +154,7 @@ export default class ModalExpo extends React.Component { transparent={true} animationType={this.state.animationType} visible={visible} + onShow={() => { console.log('modal show'); }} requestClose={() => { /* Trigger when hardware back pressed */ }} orientationChange={(evt) => { console.log('orientation changed', evt.orientation); }} supportedOrientations={['portrait']} diff --git a/renderer/native/ios/renderer/HippyComponentData.mm b/renderer/native/ios/renderer/HippyComponentData.mm index 30f376fd65d..3eeaa26c128 100644 --- a/renderer/native/ios/renderer/HippyComponentData.mm +++ b/renderer/native/ios/renderer/HippyComponentData.mm @@ -192,11 +192,9 @@ - (HippyPropBlock)propBlockForKey:(NSString *)name inDictionary:(NSMutableDictio // Build setter block void (^setterBlock)(id target, id json) = nil; - if (type == NSSelectorFromString(@"HippyDirectEventBlock:")) { - //TODO - //The component event response logic no longer executes this code - } else { + { // Ordinary property handlers + // In hippy3, component's event property do not go here. NSMethodSignature *typeSignature = [[HippyConvert class] methodSignatureForSelector:type]; if (!typeSignature) { HippyLogError(@"No +[HippyConvert %@] function found.", NSStringFromSelector(type)); diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index 451aa0c4298..a91f31beb13 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -825,14 +825,6 @@ - (void)createRenderNodes:(std::vector> &&)nodes [uiManager->_componentTransactionListeners addObject:view]; } [tempCreatedViews addObject:view]; - - // TODO: hippy3 events binding handling, performance needs to be improved here. - const std::vector &eventNames = [shadowView allEventNames]; - for (auto &event : eventNames) { - [uiManager addEventNameInMainThread:event - forView:view - onRootNode:shadowView.rootNode]; - } } }]; } @@ -1169,12 +1161,6 @@ - (void)addEventName:(const std::string &)name UIView *view = viewRegistry[@(node_id)]; [uiManager addTouchEventListenerForType:name_ forView:view onRootNode:rootNode]; }]; - } else if (name == hippy::kShowEvent || name == hippy::kDismissEvent) { - std::string name_ = name; - [self addUIBlock:^(HippyUIManager *uiManager, NSDictionary *viewRegistry) { - UIView *view = viewRegistry[@(node_id)]; - [uiManager addShowEventListenerForType:name_ forView:view onRootNode:rootNode]; - }]; } else if (name == hippy::kPressIn || name == hippy::kPressOut) { std::string name_ = name; [self addUIBlock:^(HippyUIManager *uiManager, NSDictionary *viewRegistry) { @@ -1204,8 +1190,7 @@ - (void)addEventName:(const std::string &)name } forKey:vsyncKey]; } }]; - } - else { + } else { std::string name_ = name; [self addUIBlock:^(HippyUIManager *uiManager, NSDictionary *viewRegistry) { UIView *view = viewRegistry[@(node_id)]; @@ -1226,8 +1211,6 @@ - (void)addEventNameInMainThread:(const std::string &)name } else if (name == hippy::kTouchStartEvent || name == hippy::kTouchMoveEvent || name == hippy::kTouchEndEvent || name == hippy::kTouchCancelEvent) { [self addTouchEventListenerForType:name forView:view onRootNode:rootNode]; - } else if (name == hippy::kShowEvent || name == hippy::kDismissEvent) { - [self addShowEventListenerForType:name forView:view onRootNode:rootNode]; } else if (name == hippy::kPressIn || name == hippy::kPressOut) { [self addPressEventListenerForType:name forView:view onRootNode:rootNode]; } else { @@ -1384,13 +1367,6 @@ - (void)addTouchEventListenerForType:(const std::string &)type } } -- (void)addShowEventListenerForType:(const std::string &)type - forView:(UIView *)view - onRootNode:(std::weak_ptr)rootNode { - // Note: not implemented - // iOS do not have these event. -} - - (void)removeEventName:(const std::string &)eventName forDomNodeId:(int32_t)node_id onRootNode:(std::weak_ptr)rootNode { diff --git a/renderer/native/ios/renderer/component/view/HippyShadowView.h b/renderer/native/ios/renderer/component/view/HippyShadowView.h index df00d7a953b..07448d6d4d0 100644 --- a/renderer/native/ios/renderer/component/view/HippyShadowView.h +++ b/renderer/native/ios/renderer/component/view/HippyShadowView.h @@ -62,7 +62,6 @@ typedef void (^HippyViewInsertionBlock)(UIView *container, NSArray *ch @property(nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children -@property(nonatomic, copy) HippyDirectEventBlock onLayout; @property(nonatomic, readonly) BOOL confirmedLayoutDirectionDidUpdated; /** diff --git a/renderer/native/ios/renderer/component/view/HippyViewManager.mm b/renderer/native/ios/renderer/component/view/HippyViewManager.mm index c0e80e02415..05cbaa8948e 100644 --- a/renderer/native/ios/renderer/component/view/HippyViewManager.mm +++ b/renderer/native/ios/renderer/component/view/HippyViewManager.mm @@ -571,8 +571,6 @@ - (void)loadImageSource:(NSString *)path forView:(HippyView *)view { HIPPY_EXPORT_SHADOW_PROPERTY(overflow, NSString) -HIPPY_EXPORT_SHADOW_PROPERTY(onLayout, HippyDirectEventBlock) - HIPPY_EXPORT_VIEW_PROPERTY(onDidMount, HippyDirectEventBlock) HIPPY_EXPORT_VIEW_PROPERTY(onDidUnmount, HippyDirectEventBlock) HIPPY_EXPORT_VIEW_PROPERTY(onAttachedToWindow, HippyDirectEventBlock)