From db266f0cbc71bbb1cc1405eb65be2135c6a92e0a Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Sun, 29 Sep 2024 09:03:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`ModalSheetViewEve?= =?UTF-8?q?ntEmitter`=20-=20Modal=20State=20Chnage=20Events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNIModalSheetVIew/RNIModalSheetView.tsx | 18 ++++++++++++++++++ src/types/ModalSheetViewEventEmitter.ts | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx b/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx index 0cdec48d..da5c361e 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx @@ -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} diff --git a/src/types/ModalSheetViewEventEmitter.ts b/src/types/ModalSheetViewEventEmitter.ts index 6e924c62..2c6a7776 100644 --- a/src/types/ModalSheetViewEventEmitter.ts +++ b/src/types/ModalSheetViewEventEmitter.ts @@ -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; @@ -21,6 +28,8 @@ export type ModalSheetViewEventEmitterMap = RemapObject; export type ModalSheetViewEventEmitter = TSEventEmitter<