Skip to content

Commit

Permalink
🛠 Refactor: Move to Deprecated Event Types
Browse files Browse the repository at this point in the history
* `TODO:2023-03-30-15-52-53` - Move deprecated native modal event types from `RNIModalViewEvents` to `RNIModalViewDeprecatedEvents`, and update library imports/exports.
* `TODO:2023-03-30-15-52-42` - WIP - Update typescript types for modal event objects to match native event object.

Summary:
* Deprecate modal events.
* Extract deprecated modal event types in `rc/native_components/RNIModalView/RNIModalViewEvents` to `RNIModalViewDeprecatedEvents`.
* Add placeholder modal event type for new modal event objects, i.e.: `RNIModalData`, `RNIModalBaseEvent`, `RNIModalBaseEvent`.
* Update types in `RNIModalViewEvents` to use placeholder placeholder event types.
* Update `RNIModalView` exports.
  • Loading branch information
dominicstop committed Mar 30, 2023
1 parent 7608eee commit fa66d8c
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 66 deletions.
75 changes: 75 additions & 0 deletions src/native_components/RNIModalView/RNIModalViewDeprecatedEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import type { NativeSyntheticEvent } from 'react-native';

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

/** @deprecated */
export type RNIModalDeprecatedBaseEvent = {
modalUUID: string;
isInFocus: boolean;
isPresented: boolean;
modalLevel: number;
modalLevelPrev: number;
reactTag?: number;
modalID?: string;
};

// Native Event Object
// -------------------

/** @deprecated */
export type OnModalShowEventObject = NativeSyntheticEvent<
RNIModalDeprecatedBaseEvent & {}
>;

/** @deprecated */
export type OnModalDismissEventObject = NativeSyntheticEvent<
RNIModalDeprecatedBaseEvent & {}
>;

/** @deprecated */
export type OnModalBlurEventObject = NativeSyntheticEvent<
RNIModalDeprecatedBaseEvent & {}
>;

/** @deprecated */
export type OnModalFocusEventObject = NativeSyntheticEvent<
RNIModalDeprecatedBaseEvent & {}
>;

/** @deprecated */
export type OnModalAttemptDismissEventObject = NativeSyntheticEvent<
RNIModalDeprecatedBaseEvent & {}
>;

// Event Handler Types
// -------------------

// prettier-ignore
/** @deprecated */
export type OnModalShowEvent = (
event: OnModalShowEventObject
) => void;

// prettier-ignore
/** @deprecated */
export type OnModalDismissEvent = (
event: OnModalDismissEventObject
) => void;

// prettier-ignore
/** @deprecated */
export type OnModalBlurEvent = (
event: OnModalBlurEventObject
) => void;

// prettier-ignore
/** @deprecated */
export type OnModalFocusEvent = (
event: OnModalFocusEventObject
) => void;

/** @deprecated */
export type OnModalAttemptDismissEvent = (
event: OnModalAttemptDismissEventObject
) => void;
88 changes: 22 additions & 66 deletions src/native_components/RNIModalView/RNIModalViewEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,43 @@ import type { NativeSyntheticEvent } from 'react-native';
// Event Object Types
// ------------------

export type RNIModalViewInfo = {
modalUUID: string;
isInFocus: boolean;
isPresented: boolean;
modalLevel: number;
modalLevelPrev: number;
};

// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalShowEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
>;

// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalDismissEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
>;

// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalBlurEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
>;

/// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalFocusEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
>;

// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalDidDismissEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
>;
/**
* Based on `RNIModalData`
*/
export type RNIModalData = {};

/**
* Based on `RNIModalBaseEventData`
*/
export type RNIModalBaseEvent = RNIModalData & {};

/**
* Based on `RNIOnModalFocusEventData`
*/
export type RNIOnModalFocusEvent = RNIModalData & {};

// Native Event Object
// -------------------

// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalWillDismissEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
RNIModalBaseEvent & {}
>;

// TODO - See TODO:2023-03-04-13-06-27 - Impl: Update
// `RNIModalView` Native Events
export type OnModalAttemptDismissEventObject = NativeSyntheticEvent<
RNIModalViewInfo & {}
export type OnModalDidDismissEventObject = NativeSyntheticEvent<
RNIModalBaseEvent & {}
>;

// Event Handler Types
// -------------------

// prettier-ignore
export type OnModalShowEvent = (
event: OnModalShowEventObject
) => void;

// prettier-ignore
export type OnModalDismissEvent = (
event: OnModalDismissEventObject
) => void;

// prettier-ignore
export type OnModalBlurEvent = (
event: OnModalBlurEventObject
) => void;

// prettier-ignore
export type OnModalFocusEvent = (
event: OnModalFocusEventObject
) => void;

export type OnModalDidDismissEvent = (
event: OnModalDidDismissEventObject
) => void;

export type OnModalWillDismissEvent = (
event: OnModalWillDismissEventObject
) => void;

export type OnModalAttemptDismissEvent = (
event: OnModalAttemptDismissEventObject
export type OnModalDidDismissEvent = (
event: OnModalDidDismissEventObject
) => void;
1 change: 1 addition & 0 deletions src/native_components/RNIModalView/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

export * from './RNIModalView';
export * from './RNIModalViewEvents';
export * from './RNIModalViewDeprecatedEvents';
export * from './RNIModalViewTypes';

0 comments on commit fa66d8c

Please sign in to comment.