From 875f3a5066c176a342a9f142d32cd251534b1639 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Wed, 7 Dec 2022 10:17:31 +0800 Subject: [PATCH] iOS: when not set onclick on view, should passthrough touch event --- doric-iOS/Pod/Classes/Shader/DoricFlexNode.m | 3 ++- .../Pod/Classes/Shader/DoricHLayoutNode.m | 3 ++- doric-iOS/Pod/Classes/Shader/DoricStackNode.m | 3 ++- doric-iOS/Pod/Classes/Shader/DoricUIView.h | 9 +++++++++ doric-iOS/Pod/Classes/Shader/DoricUIView.m | 18 ++++++++++++++++++ .../Pod/Classes/Shader/DoricVLayoutNode.m | 3 ++- doric-iOS/Pod/Classes/Shader/DoricViewNode.m | 1 + 7 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 doric-iOS/Pod/Classes/Shader/DoricUIView.h create mode 100644 doric-iOS/Pod/Classes/Shader/DoricUIView.m diff --git a/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m b/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m index e0c28930..c082a04b 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricFlexNode.m @@ -21,8 +21,9 @@ #import "DoricFlexNode.h" #import "DoricExtensions.h" #import +#import "DoricUIView.h" -@interface DoricFlexView : UIView +@interface DoricFlexView : DoricUIView @end @implementation DoricFlexView diff --git a/doric-iOS/Pod/Classes/Shader/DoricHLayoutNode.m b/doric-iOS/Pod/Classes/Shader/DoricHLayoutNode.m index c5cfe7a8..736d9b6e 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricHLayoutNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricHLayoutNode.m @@ -22,10 +22,11 @@ #import "DoricHLayoutNode.h" #import "DoricExtensions.h" +#import "DoricUIView.h" @implementation DoricHLayoutNode - (UIView *)build { - return [[UIView new] also:^(UIView *it) { + return [[DoricUIView new] also:^(DoricUIView *it) { it.doricLayout.layoutType = DoricHLayout; }]; } diff --git a/doric-iOS/Pod/Classes/Shader/DoricStackNode.m b/doric-iOS/Pod/Classes/Shader/DoricStackNode.m index 087a1548..e6291ab8 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricStackNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricStackNode.m @@ -22,11 +22,12 @@ #import "DoricStackNode.h" #import "DoricExtensions.h" +#import "DoricUIView.h" @implementation DoricStackNode - (UIView *)build { - return [[UIView new] also:^(UIView *it) { + return [[DoricUIView new] also:^(DoricUIView *it) { it.doricLayout.layoutType = DoricStack; }]; } diff --git a/doric-iOS/Pod/Classes/Shader/DoricUIView.h b/doric-iOS/Pod/Classes/Shader/DoricUIView.h new file mode 100644 index 00000000..59216618 --- /dev/null +++ b/doric-iOS/Pod/Classes/Shader/DoricUIView.h @@ -0,0 +1,9 @@ +// +// Created by pengfei.zhou on 2022/12/6. +// + +#import + + +@interface DoricUIView : UIView +@end \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/Shader/DoricUIView.m b/doric-iOS/Pod/Classes/Shader/DoricUIView.m new file mode 100644 index 00000000..51a141ae --- /dev/null +++ b/doric-iOS/Pod/Classes/Shader/DoricUIView.m @@ -0,0 +1,18 @@ +// +// Created by pengfei.zhou on 2022/12/6. +// + +#import "DoricUIView.h" + + +@implementation DoricUIView +- (nullable UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { + UIView *target = [super hitTest:point withEvent:event]; + if (self.gestureRecognizers.count == 0 && target == self) { + return nil; + } else { + return target; + } +} + +@end \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/Shader/DoricVLayoutNode.m b/doric-iOS/Pod/Classes/Shader/DoricVLayoutNode.m index 93cc16af..0218d078 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricVLayoutNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricVLayoutNode.m @@ -22,11 +22,12 @@ #import "DoricVLayoutNode.h" #import "DoricExtensions.h" +#import "DoricUIView.h" @implementation DoricVLayoutNode - (UIView *)build { - return [[UIView new] also:^(UIView *it) { + return [[DoricUIView new] also:^(DoricUIView *it) { it.doricLayout.layoutType = DoricVLayout; }]; } diff --git a/doric-iOS/Pod/Classes/Shader/DoricViewNode.m b/doric-iOS/Pod/Classes/Shader/DoricViewNode.m index 4b206193..c04ea29c 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricViewNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricViewNode.m @@ -30,6 +30,7 @@ #import "DoricPromise.h" #import "DoricFlexNode.h" #import "DoricErrorHintNode.h" +#import "DoricUIView.h" @interface AnimationCallback : NSObject @property(nonatomic, strong) NSMutableDictionary *dictionary;