Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetViewEventEmitter - Modal Dismiss Events
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 30, 2024
1 parent 3918772 commit 248e740
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ export const RNIModalSheetView = React.forwardRef<
event.nativeEvent
);
}}
onModalWillDismiss={(event) => {
props.onModalWillDismiss?.(event);
event.stopPropagation();

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

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

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


export enum ModalSheetViewEvents {
// common modal presentation events
onModalWillPresent = "onModalWillPresent",
onModalDidPresent = "onModalDidPresent",
onModalWillDismiss = "onModalWillDismiss",
onModalDidDismiss = "onModalDidDismiss",
onModalWillShow = "onModalWillShow",
onModalDidShow = "onModalDidShow",
onModalWillHide = "onModalWillHide",
Expand All @@ -24,6 +26,8 @@ export type ModalSheetViewEventKeys = keyof typeof ModalSheetViewEvents;
export type ModalSheetViewEventEmitterMap = RemapObject<typeof ModalSheetViewEvents, {
onModalWillPresent: OnModalWillPresentEventPayload;
onModalDidPresent: OnModalDidPresentEventPayload;
onModalWillDismiss: OnModalWillDismissEventPayload;
onModalDidDismiss: OnModalDidDidDismissEventPayload;
onModalWillShow: OnModalWillShowEventPayload;
onModalDidShow: OnModalDidShowEventPayload;
onModalWillHide: OnModalWillHideEventPayload;
Expand Down

0 comments on commit 248e740

Please sign in to comment.