Skip to content

Commit

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

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

modalEventEmitterRef.current!.emit(
'onModalSheetStateDidChange',
event.nativeEvent,
);
}}
>
{props.children}
</RNIModalSheetNativeView>
Expand Down
9 changes: 9 additions & 0 deletions src/types/ModalSheetViewEventEmitter.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
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 { OnModalSheetStateDidChangeEventPayload, OnModalSheetStateWillChangeEventPayload } from '../native_components/RNIModalSheetVIew';


export enum ModalSheetViewEvents {
// common modal presentation events
onModalWillPresent = "onModalWillPresent",
onModalDidPresent = "onModalDidPresent",
onModalWillShow = "onModalWillShow",
onModalDidShow = "onModalDidShow",
onModalWillHide = "onModalWillHide",
onModalDidHide = "onModalDidHide",

// modal sheet events
onModalSheetStateWillChange = "onModalSheetStateWillChange",
onModalSheetStateDidChange = "onModalSheetStateDidChange",
};

export type ModalSheetViewEventKeys = keyof typeof ModalSheetViewEvents;
Expand All @@ -21,6 +28,8 @@ export type ModalSheetViewEventEmitterMap = RemapObject<typeof ModalSheetViewEve
onModalDidShow: OnModalDidShowEventPayload;
onModalWillHide: OnModalWillHideEventPayload;
onModalDidHide: OnModalDidHideEventPayload;
onModalSheetStateWillChange: OnModalSheetStateWillChangeEventPayload;
onModalSheetStateDidChange: OnModalSheetStateDidChangeEventPayload;
}>;

export type ModalSheetViewEventEmitter = TSEventEmitter<
Expand Down

0 comments on commit db266f0

Please sign in to comment.