Skip to content

Commit

Permalink
⭐️ Impl: Types - RNIModalData
Browse files Browse the repository at this point in the history
Related:
* `TODO:2023-03-04-13-15-11` - Refactor: Update Modal Events
* `TODO:2023-03-30-15-52-42` - Update typescript types for modal event objects to match native event object.
  • Loading branch information
dominicstop committed Apr 14, 2023
1 parent 00da899 commit 963b961
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './native_modules/RNIModalViewModule';

export * from './types/UIModalTypes';
export * from './types/UIBlurEffectStyles';
export * from './types/RNIModalViewRelatedTypes';
34 changes: 32 additions & 2 deletions src/native_components/RNIModalView/RNIModalViewEvents.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
import type { NativeSyntheticEvent } from 'react-native';

import type {
ModalFocusState,
ModalPresentationState,
} from 'src/types/RNIModalViewRelatedTypes';

// Event Object Types
// ------------------

/**
* Based on `RNIModalData`
*/
export type RNIModalData = {};
export type RNIModalData = {
modalNativeID: string;
modalIndex: 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 RNIModalBaseEvent = RNIModalData & {};
export type RNIModalBaseEvent = RNIModalData & {
reactTag: number;
modalID?: string;
};

/**
* Based on `RNIOnModalFocusEventData`
Expand Down
20 changes: 20 additions & 0 deletions src/types/RNIModalViewRelatedTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** Maps to `RNIModalFocusState` */
export type ModalFocusState =
| 'INITIAL'
| 'FOCUSING'
| 'FOCUSED'
| 'BLURRING'
| 'BLURRED';

/** Maps to `RNIModalPresentationState` */
export type ModalPresentationState =
| 'INITIAL'
| 'PRESENTING_PROGRAMMATIC'
| 'PRESENTING_UNKNOWN'
| 'PRESENTED'
| 'PRESENTED_UNKNOWN'
| 'DISMISSING_GESTURE'
| 'DISMISSING_PROGRAMMATIC'
| 'DISMISSING_UNKNOWN'
| 'DISMISS_GESTURE_CANCELLING'
| 'DISMISSED';

0 comments on commit 963b961

Please sign in to comment.