Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetView.shouldAllowDismissalViaGesture
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 30, 2024
1 parent dd152bb commit 8c79f56
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView {
};

public static var propKeyPathMap: PropKeyPathMap {
return [:];
return [
"shouldAllowDismissalViaGesture": \.shouldAllowDismissalViaGesture,
];
};

// MARK: Properties
Expand All @@ -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
// ----------

Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions ios/RNIModalSheetView/RNIModalSheetViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/components/ModalSheetView/ModalSheetViewTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type ModalSheetViewRef =
& ModalSheetViewRefInheritedRemapped;

export type ModalSheetViewInheritedProps = Pick<RNIModalSheetViewProps,
| 'shouldAllowDismissalViaGesture'
| 'shouldEnableDebugBackgroundColors'

// common view events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type RNIModalSheetViewNativeComponentBaseProps =

export type RNIModalSheetNativeViewBaseProps = RemapObject<RNIModalSheetViewNativeComponentBaseProps, {
reactChildrenCount: number;
shouldAllowDismissalViaGesture: boolean;

onModalWillPresent: OnModalWillPresentEvent;
onModalDidPresent: OnModalDidPresentEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { HostComponent, ViewProps } from 'react-native';

// stubs
export interface NativeProps extends ViewProps {
// props
shouldAllowDismissalViaGesture?: boolean;
// common/shared events
onDidSetViewID?: BubblingEventHandler<{}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export type RNIModalSheetViewRef = {
};

export type RNIModalSheetViewInheritedOptionalProps = Partial<Pick<RNIModalSheetNativeViewProps,
// props
| 'shouldAllowDismissalViaGesture'

// shared/internal events
| 'onDidSetViewID'

Expand Down

0 comments on commit 8c79f56

Please sign in to comment.