From 5989b1d680a45a7a11646dc309bc3bfe4157bc61 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Wed, 2 Oct 2024 13:11:59 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`ModalSheetViewEve?= =?UTF-8?q?ntEmitter`=20Modal=20Focus=20Event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNIModalSheetVIew/RNIModalSheetView.tsx | 9 +++++++++ src/types/ModalSheetViewEventEmitter.ts | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx b/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx index 87724b7..8c9d086 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx @@ -192,6 +192,15 @@ export const RNIModalSheetView = React.forwardRef< event.nativeEvent ); }} + onModalFocusChange={(event) => { + props.onModalFocusChange?.(event); + event.stopPropagation(); + + modalEventEmitterRef.current!.emit( + 'onModalFocusChange', + event.nativeEvent + ); + }} onModalSheetStateWillChange={(event) => { props.onModalSheetStateWillChange?.(event); event.stopPropagation(); diff --git a/src/types/ModalSheetViewEventEmitter.ts b/src/types/ModalSheetViewEventEmitter.ts index 6dad4c2..eb3b0f4 100644 --- a/src/types/ModalSheetViewEventEmitter.ts +++ b/src/types/ModalSheetViewEventEmitter.ts @@ -1,7 +1,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 { OnModalDidDidDismissEventPayload, OnModalDidHideEventPayload, OnModalDidPresentEventPayload, OnModalDidShowEventPayload, OnModalFocusChangeEventPayload, OnModalWillDismissEventPayload, OnModalWillHideEventPayload, OnModalWillPresentEventPayload, OnModalWillShowEventPayload } from './CommonModalEvents'; import type { OnModalSheetStateDidChangeEventPayload, OnModalSheetStateWillChangeEventPayload, onModalSheetDidAttemptToDismissViaGestureEventPayload, onModalSheetDidDismissViaGestureEventPayload, onModalSheetWillDismissViaGestureEventPayload } from '../native_components/RNIModalSheetVIew'; @@ -15,6 +15,7 @@ export enum ModalSheetViewEvents { onModalDidShow = "onModalDidShow", onModalWillHide = "onModalWillHide", onModalDidHide = "onModalDidHide", + onModalFocusChange = "onModalFocusChange", // presentation controller event delegates onModalSheetWillDismissViaGesture = "onModalSheetWillDismissViaGesture", @@ -37,6 +38,8 @@ export type ModalSheetViewEventEmitterMap = RemapObject