Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetViewEventEmitter Modal Focus Event
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Oct 2, 2024
1 parent 20c6213 commit 5989b1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/types/ModalSheetViewEventEmitter.ts
Original file line number Diff line number Diff line change
@@ -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';


Expand All @@ -15,6 +15,7 @@ export enum ModalSheetViewEvents {
onModalDidShow = "onModalDidShow",
onModalWillHide = "onModalWillHide",
onModalDidHide = "onModalDidHide",
onModalFocusChange = "onModalFocusChange",

// presentation controller event delegates
onModalSheetWillDismissViaGesture = "onModalSheetWillDismissViaGesture",
Expand All @@ -37,6 +38,8 @@ export type ModalSheetViewEventEmitterMap = RemapObject<typeof ModalSheetViewEve
onModalDidShow: OnModalDidShowEventPayload;
onModalWillHide: OnModalWillHideEventPayload;
onModalDidHide: OnModalDidHideEventPayload;
onModalFocusChange: OnModalFocusChangeEventPayload;

onModalSheetWillDismissViaGesture: onModalSheetWillDismissViaGestureEventPayload;
onModalSheetDidDismissViaGesture: onModalSheetDidDismissViaGestureEventPayload;
onModalSheetDidAttemptToDismissViaGesture: onModalSheetDidAttemptToDismissViaGestureEventPayload;
Expand Down

0 comments on commit 5989b1d

Please sign in to comment.