Skip to content

Commit

Permalink
fix(ios): onShow event of modal component not working (#4012)
Browse files Browse the repository at this point in the history
remove obsolete onLayout property of shadowView
  • Loading branch information
wwwcg committed Sep 13, 2024
1 parent dc2dc48 commit cc825e1
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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']}
Expand Down
6 changes: 2 additions & 4 deletions renderer/native/ios/renderer/HippyComponentData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
26 changes: 1 addition & 25 deletions renderer/native/ios/renderer/HippyUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,6 @@ - (void)createRenderNodes:(std::vector<std::shared_ptr<DomNode>> &&)nodes
[uiManager->_componentTransactionListeners addObject:view];
}
[tempCreatedViews addObject:view];
// TODO: hippy3 events binding handling, performance needs to be improved here.
const std::vector<std::string> &eventNames = [shadowView allEventNames];
for (auto &event : eventNames) {
[uiManager addEventNameInMainThread:event
forView:view
onRootNode:shadowView.rootNode];
}
}
}];
}
Expand Down Expand Up @@ -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<NSNumber *,__kindof UIView *> *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<NSNumber *,__kindof UIView *> *viewRegistry) {
Expand Down Expand Up @@ -1204,8 +1190,7 @@ - (void)addEventName:(const std::string &)name
} forKey:vsyncKey];
}
}];
}
else {
} else {
std::string name_ = name;
[self addUIBlock:^(HippyUIManager *uiManager, NSDictionary<NSNumber *,__kindof UIView *> *viewRegistry) {
UIView *view = viewRegistry[@(node_id)];
Expand All @@ -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 {
Expand Down Expand Up @@ -1384,13 +1367,6 @@ - (void)addTouchEventListenerForType:(const std::string &)type
}
}

- (void)addShowEventListenerForType:(const std::string &)type
forView:(UIView *)view
onRootNode:(std::weak_ptr<RootNode>)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<hippy::RootNode>)rootNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ typedef void (^HippyViewInsertionBlock)(UIView *container, NSArray<UIView *> *ch


@property(nonatomic, strong) UIColor *backgroundColor; // Used to propagate to children
@property(nonatomic, copy) HippyDirectEventBlock onLayout;
@property(nonatomic, readonly) BOOL confirmedLayoutDirectionDidUpdated;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cc825e1

Please sign in to comment.