Skip to content

Commit

Permalink
⭐️ Impl: Types - ModalViewTypes
Browse files Browse the repository at this point in the history
Summary: Add initial types for props for `ModalView` component.
  • Loading branch information
dominicstop committed Jan 9, 2023
1 parent 0b21c1d commit a437d76
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/ModalView/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ModalContext } from '../../context/ModalContext';
import { RNIModalView } from '../../native_components/RNIModalView';

import { RNIModalViewModule } from '../../native_modules/RNIModalViewModule';
import type { ModalViewProps, ModalViewState } from './ModalViewTypes';

//
//
Expand Down Expand Up @@ -57,7 +58,12 @@ const hasScrollViewContext: boolean =
//
//

export class ModalView extends React.PureComponent {
// prettier-ignore
export class ModalView extends
React.PureComponent<ModalViewProps, ModalViewState> {
// eslint-disable-next-line no-trailing-spaces

// prettier-ignore
static proptypes = {
// Props: Events ---------------------
onRequestResult: Proptypes.func,
Expand Down
51 changes: 51 additions & 0 deletions src/components/ModalView/ModalViewTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import type { ViewProps, ViewStyle } from 'react-native';
import type { RNIModalViewProps } from 'src/native_components/RNIModalView';

export type ModalViewBaseProps = Partial<
Pick<
RNIModalViewProps,
// props - flags
| 'presentViaMount'
| 'isModalBGBlurred'
| 'enableSwipeGesture'
| 'hideNonVisibleModals'
| 'isModalBGTransparent'
| 'isModalInPresentation'
| 'allowModalForceDismiss'

// props - string
| 'modalID'
| 'modalTransitionStyle'
| 'modalBGBlurEffectStyle'
| 'modalPresentationStyle'

// props - events
| 'onModalShow'
| 'onModalDismiss'
| 'onRequestResult'
| 'onModalBlur'
| 'onModalFocus'
| 'onModalDidDismiss'
| 'onModalWillDismiss'
| 'onModalAttemptDismiss'
>
> & {
// TODO: Rename to `shouldAutoCloseOnUnmount`
autoCloseOnUnmount?: boolean;
setEnableSwipeGestureFromProps?: boolean;
setModalInPresentationFromProps?: boolean;

containerStyle: ViewStyle;
children: React.ReactChildren;
};

// prettier-ignore
export type ModalViewProps =
ViewProps & ModalViewBaseProps;

export type ModalViewState = {
visible: boolean;
childProps: unknown;
enableSwipeGesture: boolean;
isModalInPresentation: boolean;
};
2 changes: 2 additions & 0 deletions src/components/ModalView/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './ModalView';
export * from './ModalViewTypes';

0 comments on commit a437d76

Please sign in to comment.