From ba3f00134ee068ab20af942d37709e74cd3aeda6 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Tue, 1 Oct 2024 08:00:41 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`RNIModalSheetView?= =?UTF-8?q?.reactChildrenCount`=20Prop=20Scaffolding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNIModalSheetViewDelegate.swift | 16 ++++++++++++++++ .../RNIModalSheetViewManager.mm | 1 + .../RNIModalSheetViewNativeComponent.ts | 8 +++++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift index 3a0a23e..9523646 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift +++ b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift @@ -36,6 +36,7 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { public static var propKeyPathMap: PropKeyPathMap { return [ + "reactChildrenCount": \.reactChildrenCountProp, "shouldAllowDismissalViaGesture": \.shouldAllowDismissalViaGesture, ]; }; @@ -58,6 +59,21 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { public var reactProps: NSDictionary = [:]; + public var reactChildrenCount: Int = 0; + var reactChildrenCountProp: NSNumber = 0 { + willSet { + let oldCount = self.reactChildrenCount; + let newCount = newValue.intValue; + + guard oldCount != newCount else { + return; + }; + + self.reactChildrenCount = newCount; + // TODO: Add code for verifying child count before presenting + } + }; + public var shouldAllowDismissalViaGesture: Bool = true { willSet { self.modalSheetController?.shouldAllowDismissal = newValue; diff --git a/ios/RNIModalSheetView/RNIModalSheetViewManager.mm b/ios/RNIModalSheetView/RNIModalSheetViewManager.mm index 86488a7..dd1928c 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewManager.mm +++ b/ios/RNIModalSheetView/RNIModalSheetViewManager.mm @@ -28,6 +28,7 @@ - (UIView *)view return [[RNIModalSheetView new] initWithBridge:self.bridge]; } +RNI_EXPORT_VIEW_PROPERTY(reactChildrenCount, NSNumber); RNI_EXPORT_VIEW_PROPERTY(shouldAllowDismissalViaGesture, BOOL); RNI_EXPORT_VIEW_EVENT(onDidSetViewID, RCTBubblingEventBlock) diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewNativeComponent.ts b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewNativeComponent.ts index eb5f135..1017141 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewNativeComponent.ts +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewNativeComponent.ts @@ -6,10 +6,13 @@ import type { HostComponent, ViewProps } from 'react-native'; // stubs export interface NativeProps extends ViewProps { // props + reactChildrenCount: Int32; shouldAllowDismissalViaGesture?: boolean; + // common/shared events onDidSetViewID?: BubblingEventHandler<{}>; + // common modal events onModalWillPresent?: BubblingEventHandler<{}>; onModalDidPresent?: BubblingEventHandler<{}>; @@ -18,14 +21,13 @@ export interface NativeProps extends ViewProps { onModalWillShow?: BubblingEventHandler<{}>; onModalDidShow?: BubblingEventHandler<{}>; + onModalWillHide?: BubblingEventHandler<{}>; onModalDidHide?: BubblingEventHandler<{}>; + // events onModalSheetStateWillChange?: BubblingEventHandler<{}>; onModalSheetStateDidChange?: BubblingEventHandler<{}>; - - // value prop stubs - reactChildrenCount: Int32; }; // stubs