diff --git a/src/native_components/RNIModalView/RNIModalViewEventData.ts b/src/native_components/RNIModalView/RNIModalViewEventData.ts new file mode 100644 index 00000000..00ed39f6 --- /dev/null +++ b/src/native_components/RNIModalView/RNIModalViewEventData.ts @@ -0,0 +1,71 @@ +import type { CGPoint, CGSize } from 'src/types/NativeTypes'; + +import type { + ModalFocusState, + ModalPresentationState, +} from 'src/types/RNIModalViewRelatedTypes'; + +// Event Object Types +// ------------------ + +/** Based on `RNIModalData` */ +export type RNIModalData = { + modalNativeID: string; + modalIndex: number; + modalIndexPrev: number; + currentModalIndex: number; + modalFocusState: ModalFocusState; + modalFocusStatePref: ModalFocusState; + wasBlurCancelled: boolean; + wasFocusCancelled: boolean; + modalPresentationState: ModalPresentationState; + modalPresentationStatePrev: ModalPresentationState; + isInitialPresent: boolean; + wasCancelledPresent: boolean; + wasCancelledDismiss: boolean; + wasCancelledDismissViaGesture: boolean; + isModalPresented: boolean; + isModalInFocus: boolean; + computedIsModalInFocus: boolean; + computedIsModalPresented: boolean; + computedModalIndex: number; + computedViewControllerIndex: number; + computedCurrentModalIndex: number; + synthesizedWindowID?: string; +}; + +/** Based on `RNIModalBaseEventData` */ +export type RNIModalBaseEventData = RNIModalData & { + reactTag: number; + modalID?: string; +}; + +/** Based on `RNIOnModalFocusEventData` */ +export type RNIOnModalFocusEventData = RNIModalBaseEventData & { + senderInfo: RNIModalData; + isInitial: boolean; +}; + +/** Based on `RNIModalSwipeGestureEventData` */ +export type RNIModalSwipeGestureEventData = { + position: CGPoint; +}; + +/** Based on `RNIModalDidSnapEventData` */ +export type RNIModalDidSnapEventData = { + selectedDetentIdentifier?: string; + modalContentSize: CGSize; +}; + +/** Based on RNIModalDidChangeSelectedDetentIdentifierEventData */ +export type RNIModalDidChangeSelectedDetentIdentifierEventData = { + sheetDetentStringPrevious?: string; + sheetDetentStringCurrent?: string; +}; + +/** Based on RNIModalDetentDidComputeEventData */ +export type RNIModalDetentDidComputeEventData = { + maximumDetentValue: number; + computedDetentValue: number; + key: string; +}; diff --git a/src/native_components/RNIModalView/RNIModalViewEventObjects.ts b/src/native_components/RNIModalView/RNIModalViewEventObjects.ts new file mode 100644 index 00000000..9a148369 --- /dev/null +++ b/src/native_components/RNIModalView/RNIModalViewEventObjects.ts @@ -0,0 +1,73 @@ +import type { NativeSyntheticEvent } from 'react-native'; + +import type { + RNIModalBaseEventData, + RNIModalDetentDidComputeEventData, + RNIModalDidChangeSelectedDetentIdentifierEventData, + RNIOnModalFocusEventData, + RNIModalDidSnapEventData, + RNIModalSwipeGestureEventData, +} from './RNIModalViewEventData'; + +// Native Event Object +// ------------------- + +export type OnModalWillPresentEventObject = + NativeSyntheticEvent; + +export type OnModalDidPresentEventObject = + NativeSyntheticEvent; + +export type OnModalWillDismissEventObject = + NativeSyntheticEvent; + +export type OnModalDidDismissEventObject = + NativeSyntheticEvent; + +export type OnModalWillShowEventObject = + NativeSyntheticEvent; + +export type OnModalDidShowEventObject = + NativeSyntheticEvent; + +export type OnModalWillHideEventObject = + NativeSyntheticEvent; + +export type OnModalDidHideEventObject = + NativeSyntheticEvent; + +export type OnPresentationControllerWillDismissEventObject = + NativeSyntheticEvent; + +export type OnPresentationControllerDidDismissEventObject = + NativeSyntheticEvent; + +export type OnPresentationControllerDidAttemptToDismissEventObject = + NativeSyntheticEvent; + +export type OnModalWillFocusEventObject = + NativeSyntheticEvent; + +export type OnModalDidFocusEventObject = + NativeSyntheticEvent; + +export type OnModalDetentDidComputeEventObject = + NativeSyntheticEvent; + +export type OnModalDidChangeSelectedDetentIdentifierEventObject = + NativeSyntheticEvent; + +export type OnModalWillBlurEventObject = + NativeSyntheticEvent; + +export type OnModalDidBlurEventObject = + NativeSyntheticEvent; + +export type OnModalDidSnapEventObject = + NativeSyntheticEvent; + +export type OnModalSwipeGestureStartEventObject = + NativeSyntheticEvent; + +export type OnModalSwipeGestureDidEndEventObject = + NativeSyntheticEvent; diff --git a/src/native_components/RNIModalView/RNIModalViewEvents.ts b/src/native_components/RNIModalView/RNIModalViewEvents.ts index 0158cfd5..d0b14a3e 100644 --- a/src/native_components/RNIModalView/RNIModalViewEvents.ts +++ b/src/native_components/RNIModalView/RNIModalViewEvents.ts @@ -1,145 +1,27 @@ -import type { NativeSyntheticEvent } from 'react-native'; -import type { CGPoint, CGSize } from 'src/types/NativeTypes'; +/* eslint-disable prettier/prettier */ import type { - ModalFocusState, - ModalPresentationState, -} from 'src/types/RNIModalViewRelatedTypes'; - -// Event Object Types -// ------------------ - -/** Based on `RNIModalData` */ -export type RNIModalData = { - modalNativeID: string; - modalIndex: number; - modalIndexPrev: number; - currentModalIndex: number; - modalFocusState: ModalFocusState; - modalFocusStatePref: ModalFocusState; - wasBlurCancelled: boolean; - wasFocusCancelled: boolean; - modalPresentationState: ModalPresentationState; - modalPresentationStatePrev: ModalPresentationState; - isInitialPresent: boolean; - wasCancelledPresent: boolean; - wasCancelledDismiss: boolean; - wasCancelledDismissViaGesture: boolean; - isModalPresented: boolean; - isModalInFocus: boolean; - computedIsModalInFocus: boolean; - computedIsModalPresented: boolean; - computedModalIndex: number; - computedViewControllerIndex: number; - computedCurrentModalIndex: number; - synthesizedWindowID?: string; -}; - -/** Based on `RNIModalBaseEventData` */ -export type RNIModalBaseEventData = RNIModalData & { - reactTag: number; - modalID?: string; -}; - -/** Based on `RNIOnModalFocusEventData` */ -export type RNIOnModalFocusEventData = RNIModalBaseEventData & { - senderInfo: RNIModalData; - isInitial: boolean; -}; - -/** Based on `RNIModalSwipeGestureEventData` */ -export type RNIModalSwipeGestureEventData = { - position: CGPoint; -}; - -/** Based on `RNIModalDidSnapEventData` */ -export type RNIModalDidSnapEventData = { - selectedDetentIdentifier?: string; - modalContentSize: CGSize; -}; - -/** Based on RNIModalDidChangeSelectedDetentIdentifierEventData */ -export type RNIModalDidChangeSelectedDetentIdentifierEventData = { - sheetDetentStringPrevious?: string; - sheetDetentStringCurrent?: string; -}; - -/** Based on RNIModalDetentDidComputeEventData */ -export type RNIModalDetentDidComputeEventData = { - maximumDetentValue: number; - computedDetentValue: number; - key: string; -}; - -// Native Event Object -// ------------------- - -export type OnModalWillPresentEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; -export type OnModalDidPresentEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; - -export type OnModalWillDismissEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; -export type OnModalDidDismissEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; - -export type OnModalWillShowEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; -export type OnModalDidShowEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; - -export type OnModalWillHideEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; -export type OnModalDidHideEventObject = NativeSyntheticEvent< - RNIModalBaseEventData & {} ->; - -export type OnPresentationControllerWillDismissEventObject = - NativeSyntheticEvent; - -export type OnPresentationControllerDidDismissEventObject = - NativeSyntheticEvent; - -export type OnPresentationControllerDidAttemptToDismissEventObject = - NativeSyntheticEvent; - -export type OnModalWillFocusEventObject = NativeSyntheticEvent< - RNIOnModalFocusEventData & {} ->; - -export type OnModalDidFocusEventObject = NativeSyntheticEvent< - RNIOnModalFocusEventData & {} ->; - -export type OnModalDetentDidComputeEventObject = - NativeSyntheticEvent; - -export type OnModalDidChangeSelectedDetentIdentifierEventObject = - NativeSyntheticEvent; - -export type OnModalWillBlurEventObject = NativeSyntheticEvent< - RNIOnModalFocusEventData & {} ->; -export type OnModalDidBlurEventObject = NativeSyntheticEvent< - RNIOnModalFocusEventData & {} ->; - -export type OnModalDidSnapEventObject = - NativeSyntheticEvent; - -export type OnModalSwipeGestureStartEventObject = - NativeSyntheticEvent; - -export type OnModalSwipeGestureDidEndEventObject = - NativeSyntheticEvent; + OnModalWillPresentEventObject, + OnModalDidPresentEventObject, + OnModalWillDismissEventObject, + OnModalDidDismissEventObject, + OnModalWillShowEventObject, + OnModalDidShowEventObject, + OnModalWillHideEventObject, + OnModalDidHideEventObject, + OnPresentationControllerWillDismissEventObject, + OnPresentationControllerDidDismissEventObject, + OnPresentationControllerDidAttemptToDismissEventObject, + OnModalWillFocusEventObject, + OnModalDidFocusEventObject, + OnModalWillBlurEventObject, + OnModalDidBlurEventObject, + OnModalDetentDidComputeEventObject, + OnModalDidChangeSelectedDetentIdentifierEventObject, + OnModalDidSnapEventObject, + OnModalSwipeGestureStartEventObject, + OnModalSwipeGestureDidEndEventObject, +} from './RNIModalViewEventObjects'; // Event Handler Types // ------------------- @@ -160,13 +42,21 @@ export type OnModalDidDismissEvent = ( event: OnModalDidDismissEventObject ) => void; -export type OnModalWillShowEvent = (event: OnModalWillShowEventObject) => void; +export type OnModalWillShowEvent = ( + event: OnModalWillShowEventObject +) => void; -export type OnModalDidShowEvent = (event: OnModalDidShowEventObject) => void; +export type OnModalDidShowEvent = ( + event: OnModalDidShowEventObject +) => void; -export type OnModalWillHideEvent = (event: OnModalWillHideEventObject) => void; +export type OnModalWillHideEvent = ( + event: OnModalWillHideEventObject +) => void; -export type OnModalDidHideEvent = (event: OnModalDidHideEventObject) => void; +export type OnModalDidHideEvent = ( + event: OnModalDidHideEventObject +) => void; export type OnPresentationControllerWillDismissEvent = ( event: OnPresentationControllerWillDismissEventObject @@ -184,11 +74,17 @@ export type OnModalWillFocusEvent = ( event: OnModalWillFocusEventObject ) => void; -export type OnModalDidFocusEvent = (event: OnModalDidFocusEventObject) => void; +export type OnModalDidFocusEvent = ( + event: OnModalDidFocusEventObject +) => void; -export type OnModalWillBlurEvent = (event: OnModalWillBlurEventObject) => void; +export type OnModalWillBlurEvent = ( + event: OnModalWillBlurEventObject +) => void; -export type OnModalDidBlurEvent = (event: OnModalDidBlurEventObject) => void; +export type OnModalDidBlurEvent = ( + event: OnModalDidBlurEventObject +) => void; export type OnModalDetentDidComputeEvent = ( event: OnModalDetentDidComputeEventObject @@ -198,7 +94,9 @@ export type OnModalDidChangeSelectedDetentIdentifierEvent = ( event: OnModalDidChangeSelectedDetentIdentifierEventObject ) => void; -export type OnModalDidSnapEvent = (event: OnModalDidSnapEventObject) => void; +export type OnModalDidSnapEvent = ( + event: OnModalDidSnapEventObject +) => void; export type OnModalSwipeGestureStartEvent = ( event: OnModalSwipeGestureStartEventObject diff --git a/src/native_components/RNIModalView/index.ts b/src/native_components/RNIModalView/index.ts index 4e2b1da7..6501c417 100644 --- a/src/native_components/RNIModalView/index.ts +++ b/src/native_components/RNIModalView/index.ts @@ -1,4 +1,6 @@ export * from './RNIModalView'; export * from './RNIModalViewEvents'; +export * from './RNIModalViewEventObjects'; +export * from './RNIModalViewEventData'; export * from './RNIModalViewDeprecatedEvents'; export * from './RNIModalViewTypes';