From 8c79f563220eb2d4f853524a7bf38bb84b20c262 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Tue, 1 Oct 2024 07:59:37 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`ModalSheetView.sh?= =?UTF-8?q?ouldAllowDismissalViaGesture`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNIModalSheetViewDelegate.swift | 13 +++++++++++-- ios/RNIModalSheetView/RNIModalSheetViewManager.mm | 2 ++ .../ModalSheetView/ModalSheetViewTypes.tsx | 1 + .../RNIModalSheetVIew/RNIModalSheetNativeView.ts | 1 + .../RNIModalSheetViewNativeComponent.ts | 2 ++ .../RNIModalSheetVIew/RNIModalSheetViewTypes.ts | 3 +++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift index 8637b148..3a0a23e2 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift +++ b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift @@ -35,7 +35,9 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { }; public static var propKeyPathMap: PropKeyPathMap { - return [:]; + return [ + "shouldAllowDismissalViaGesture": \.shouldAllowDismissalViaGesture, + ]; }; // MARK: Properties @@ -55,7 +57,13 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { // ------------------------ public var reactProps: NSDictionary = [:]; - + + public var shouldAllowDismissalViaGesture: Bool = true { + willSet { + self.modalSheetController?.shouldAllowDismissal = newValue; + } + }; + // MARK: Init // ---------- @@ -80,6 +88,7 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { modalVC.mainSheetContentParent = mainSheetContentParent; modalVC.view.backgroundColor = .systemBackground; + modalVC.shouldAllowDismissal = self.shouldAllowDismissalViaGesture; modalVC.lifecycleEventDelegates.add(self); modalVC.modalLifecycleEventDelegates.add(self); diff --git a/ios/RNIModalSheetView/RNIModalSheetViewManager.mm b/ios/RNIModalSheetView/RNIModalSheetViewManager.mm index 0a1459ed..86488a77 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewManager.mm +++ b/ios/RNIModalSheetView/RNIModalSheetViewManager.mm @@ -28,6 +28,8 @@ - (UIView *)view return [[RNIModalSheetView new] initWithBridge:self.bridge]; } +RNI_EXPORT_VIEW_PROPERTY(shouldAllowDismissalViaGesture, BOOL); + RNI_EXPORT_VIEW_EVENT(onDidSetViewID, RCTBubblingEventBlock) RNI_EXPORT_VIEW_EVENT(onModalWillPresent, RCTBubblingEventBlock); diff --git a/src/components/ModalSheetView/ModalSheetViewTypes.tsx b/src/components/ModalSheetView/ModalSheetViewTypes.tsx index f40a6b71..0a275d4a 100644 --- a/src/components/ModalSheetView/ModalSheetViewTypes.tsx +++ b/src/components/ModalSheetView/ModalSheetViewTypes.tsx @@ -31,6 +31,7 @@ export type ModalSheetViewRef = & ModalSheetViewRefInheritedRemapped; export type ModalSheetViewInheritedProps = Pick; diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts index 47c68cd6..364b1e36 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts @@ -27,6 +27,9 @@ export type RNIModalSheetViewRef = { }; export type RNIModalSheetViewInheritedOptionalProps = Partial