-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Extract `RNIModalView` native view component to `src/native_components/RNIModalView`.
- Loading branch information
1 parent
4df1fe8
commit 5838956
Showing
7 changed files
with
210 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
|
||
export * from './ModalView'; | ||
export * from './ModalViewModule'; | ||
export * from './constants/Enums'; | ||
export * from './context/ModalContext'; | ||
export * from './hoc/withModalLifecycle';export * from './types/UIModalTypes'; | ||
export * from './hoc/withModalLifecycle'; | ||
|
||
export * from './native_components/RNIModalView'; | ||
|
||
// | ||
export * from './types/UIModalTypes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
View, | ||
UIManager, | ||
requireNativeComponent, | ||
Platform, | ||
HostComponent, | ||
} from 'react-native'; | ||
|
||
import type { | ||
RNIModalViewCommandMap, | ||
RNIModalViewConstantMap, | ||
RNIModalViewProps, | ||
} from './RNIModalViewTypes'; | ||
|
||
const nativeViewName = 'RNIModalView'; | ||
|
||
/** | ||
* Do not use `RNIModalView` if platform is not iOS. | ||
*/ | ||
export const RNIModalView: HostComponent<RNIModalViewProps> = Platform.select({ | ||
ios: () => requireNativeComponent(nativeViewName) as any, | ||
default: () => View, | ||
})(); | ||
|
||
export const RNIModalViewCommands = UIManager[nativeViewName] | ||
?.Commands as RNIModalViewCommandMap; | ||
|
||
export const RNIModalViewConstants = UIManager[nativeViewName] | ||
?.Constants as RNIModalViewConstantMap; | ||
|
||
export const AvailableBlurEffectStyles = | ||
RNIModalViewConstants?.availableBlurEffectStyles ?? []; | ||
|
||
export const AvailablePresentationStyles = | ||
RNIModalViewConstants?.availablePresentationStyles ?? []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-disable no-trailing-spaces */ | ||
|
||
import type { NativeSyntheticEvent } from 'react-native'; | ||
|
||
// Event Object Types | ||
// ------------------ | ||
|
||
export type RNIModalViewNativeEventBase = { | ||
modalUUID: string; | ||
isInFocus: boolean; | ||
isPresented: boolean; | ||
modalLevel: number; | ||
modalLevelPrev: number; | ||
}; | ||
|
||
// TODO | ||
export type OnModalShowEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnModalDismissEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnRequestResultEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnModalBlurEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnModalFocusEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnModalDidDismissEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnModalWillDismissEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// TODO | ||
export type OnModalAttemptDismissEventObject = NativeSyntheticEvent< | ||
RNIModalViewNativeEventBase & {} | ||
>; | ||
|
||
// Event Handler Types | ||
// ------------------- | ||
|
||
// eslint-disable-next-line prettier/prettier | ||
export type OnModalShowEvent = ( | ||
event: OnModalShowEventObject | ||
) => void; | ||
|
||
// eslint-disable-next-line prettier/prettier | ||
export type OnModalDismissEvent = ( | ||
event: OnModalDismissEventObject | ||
) => void; | ||
|
||
// eslint-disable-next-line prettier/prettier | ||
export type OnRequestResultEvent = ( | ||
event: OnRequestResultEventObject | ||
) => void; | ||
|
||
// eslint-disable-next-line prettier/prettier | ||
export type OnModalBlurEvent = ( | ||
event: OnModalBlurEventObject | ||
) => void; | ||
|
||
// eslint-disable-next-line prettier/prettier | ||
export type OnModalFocusEvent = ( | ||
event: OnModalFocusEventObject | ||
) => void; | ||
|
||
export type OnModalDidDismissEvent = ( | ||
event: OnModalDidDismissEventObject | ||
) => void; | ||
|
||
export type OnModalWillDismissEvent = ( | ||
event: OnModalWillDismissEventObject | ||
) => void; | ||
|
||
export type OnModalAttemptDismissEvent = ( | ||
event: OnModalAttemptDismissEventObject | ||
) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { ViewProps } from 'react-native'; | ||
|
||
import type { UIBlurEffectStyles } from 'src/types/UIBlurEffectStyles'; | ||
|
||
import type { | ||
UIModalPresentationStyle, | ||
UIModalTransitionStyle, | ||
} from 'src/types/UIModalTypes'; | ||
|
||
import type { | ||
ViewManagerCommandMap, | ||
ViewManagerConstantMap, | ||
} from 'src/types/ViewModuleRelatedTypes'; | ||
|
||
import type { | ||
OnModalShowEvent, | ||
OnModalDismissEvent, | ||
OnRequestResultEvent, | ||
OnModalBlurEvent, | ||
OnModalFocusEvent, | ||
OnModalDidDismissEvent, | ||
OnModalWillDismissEvent, | ||
OnModalAttemptDismissEvent, | ||
} from './RNIModalViewEvents'; | ||
|
||
export type RNIModalViewProps = ViewProps & { | ||
// Props - Flags | ||
// -------------- | ||
|
||
presentViaMount: boolean; | ||
isModalBGBlurred: boolean; | ||
enableSwipeGesture: boolean; | ||
hideNonVisibleModals: boolean; | ||
isModalBGTransparent: boolean; | ||
isModalInPresentation: boolean; | ||
allowModalForceDismiss: boolean; | ||
|
||
// Props - Strings | ||
// -------------- | ||
|
||
modalID: string; | ||
modalTransitionStyle: UIModalTransitionStyle; | ||
modalBGBlurEffectStyle: UIBlurEffectStyles; | ||
modalPresentationStyle: UIModalPresentationStyle; | ||
|
||
// Props - Events | ||
// -------------- | ||
|
||
onModalShow: OnModalShowEvent; | ||
onModalDismiss: OnModalDismissEvent; | ||
onRequestResult: OnRequestResultEvent; | ||
|
||
onModalBlur: OnModalBlurEvent; | ||
onModalFocus: OnModalFocusEvent; | ||
|
||
onModalDidDismiss: OnModalDidDismissEvent; | ||
onModalWillDismiss: OnModalWillDismissEvent; | ||
onModalAttemptDismiss: OnModalAttemptDismissEvent; | ||
}; | ||
|
||
export type RNIModalViewCommandMap = ViewManagerCommandMap< | ||
'requestModalInfo' | 'requestModalPresentation' | ||
>; | ||
|
||
export type RNIModalViewConstantMap = ViewManagerConstantMap<{ | ||
availableBlurEffectStyles: UIBlurEffectStyles[]; | ||
availablePresentationStyles: UIModalPresentationStyle[]; | ||
}>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
export * from './RNIModalView'; | ||
export * from './RNIModalViewEvents'; | ||
export * from './RNIModalViewTypes'; |