Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetViewEventEmitter - Presentation Controller Relat…
Browse files Browse the repository at this point in the history
…ed Events
  • Loading branch information
dominicstop committed Oct 1, 2024
1 parent 91ce3f6 commit 0ad9e5a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,33 @@ export const RNIModalSheetView = React.forwardRef<
event.nativeEvent
);
}}
onModalSheetWillDismissViaGesture={(event) => {
props.onModalSheetWillDismissViaGesture?.(event);
event.stopPropagation();

modalEventEmitterRef.current!.emit(
'onModalSheetWillDismissViaGesture',
event.nativeEvent
);
}}
onModalSheetDidDismissViaGesture={(event) => {
props.onModalSheetDidDismissViaGesture?.(event);
event.stopPropagation();

modalEventEmitterRef.current!.emit(
'onModalSheetDidDismissViaGesture',
event.nativeEvent
);
}}
onModalSheetDidAttemptToDismissViaGesture={(event) => {
props.onModalSheetDidAttemptToDismissViaGesture?.(event);
event.stopPropagation();

modalEventEmitterRef.current!.emit(
'onModalSheetDidAttemptToDismissViaGesture',
event.nativeEvent
);
}}
onModalSheetStateWillChange={(event) => {
props.onModalSheetStateWillChange?.(event);
event.stopPropagation();
Expand Down
10 changes: 9 additions & 1 deletion src/types/ModalSheetViewEventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TSEventEmitter } from '@dominicstop/ts-event-emitter';
import type { RemapObject } from 'react-native-ios-utilities';

import type { OnModalDidDidDismissEventPayload, OnModalDidHideEventPayload, OnModalDidPresentEventPayload, OnModalDidShowEventPayload, OnModalWillDismissEventPayload, OnModalWillHideEventPayload, OnModalWillPresentEventPayload, OnModalWillShowEventPayload } from './CommonModalEvents';
import type { OnModalSheetStateDidChangeEventPayload, OnModalSheetStateWillChangeEventPayload } from '../native_components/RNIModalSheetVIew';
import type { OnModalSheetStateDidChangeEventPayload, OnModalSheetStateWillChangeEventPayload, onModalSheetDidAttemptToDismissViaGestureEventPayload, onModalSheetDidDismissViaGestureEventPayload, onModalSheetWillDismissViaGestureEventPayload } from '../native_components/RNIModalSheetVIew';


export enum ModalSheetViewEvents {
Expand All @@ -16,6 +16,11 @@ export enum ModalSheetViewEvents {
onModalWillHide = "onModalWillHide",
onModalDidHide = "onModalDidHide",

// presentation controller event delegates
onModalSheetWillDismissViaGesture = "onModalSheetWillDismissViaGesture",
onModalSheetDidDismissViaGesture = "onModalSheetDidDismissViaGesture",
onModalSheetDidAttemptToDismissViaGesture = "onModalSheetDidAttemptToDismissViaGesture",

// modal sheet events
onModalSheetStateWillChange = "onModalSheetStateWillChange",
onModalSheetStateDidChange = "onModalSheetStateDidChange",
Expand All @@ -32,6 +37,9 @@ export type ModalSheetViewEventEmitterMap = RemapObject<typeof ModalSheetViewEve
onModalDidShow: OnModalDidShowEventPayload;
onModalWillHide: OnModalWillHideEventPayload;
onModalDidHide: OnModalDidHideEventPayload;
onModalSheetWillDismissViaGesture: onModalSheetWillDismissViaGestureEventPayload;
onModalSheetDidDismissViaGesture: onModalSheetDidDismissViaGestureEventPayload;
onModalSheetDidAttemptToDismissViaGesture: onModalSheetDidAttemptToDismissViaGestureEventPayload;
onModalSheetStateWillChange: OnModalSheetStateWillChangeEventPayload;
onModalSheetStateDidChange: OnModalSheetStateDidChangeEventPayload;
}>;
Expand Down

0 comments on commit 0ad9e5a

Please sign in to comment.