Skip to content

Commit

Permalink
⭐️ Impl: RNIModalSheetView.reactChildrenCount Prop Scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Oct 1, 2024
1 parent 8c79f56 commit ba3f001
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
16 changes: 16 additions & 0 deletions ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView {

public static var propKeyPathMap: PropKeyPathMap {
return [
"reactChildrenCount": \.reactChildrenCountProp,
"shouldAllowDismissalViaGesture": \.shouldAllowDismissalViaGesture,
];
};
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ios/RNIModalSheetView/RNIModalSheetViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<{}>;

Expand All @@ -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
Expand Down

0 comments on commit ba3f001

Please sign in to comment.