Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetView Presentation Events JS Scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 27, 2024
1 parent 5dce892 commit adffaf0
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/components/ModalSheetView/ModalSheetViewTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ export type ModalSheetViewRef =

export type ModalSheetViewInheritedProps = Pick<RNIModalSheetViewProps,
| 'shouldEnableDebugBackgroundColors'

// common view events
| 'onDidSetViewID'

// common modal presentation events
| 'onModalWillPresent'
| 'onModalDidPresent'
| 'onModalWillShow'
| 'onModalDidShow'
| 'onModalWillHide'
| 'onModalDidHide'
>;

export type ModalSheetViewBaseProps = {
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export * from './components/ModalSheetView';

export type * from './types/ModalViewControllerMetrics';
export type * from './types/PresentationControllerMetrics';
export type * from './types/ModalMetrics';
export type * from './types/ModalMetrics';
export type * from './types/CommonModalEvents';
12 changes: 12 additions & 0 deletions src/native_components/RNIModalSheetVIew/RNIModalSheetNativeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ import {
type NativeProps as RNIModalSheetViewNativeComponentProps,
} from './RNIModalSheetViewNativeComponent';

import type { OnModalWillPresentEvent, OnModalDidPresentEvent, OnModalWillShowEvent, OnModalDidShowEvent, OnModalWillHideEvent, OnModalDidHideEvent } from '../../types/CommonModalEvents';


type RNIModalSheetViewNativeComponentBaseProps =
NativeComponentBaseProps<RNIModalSheetViewNativeComponentProps>;

export type RNIModalSheetNativeViewBaseProps = RemapObject<RNIModalSheetViewNativeComponentBaseProps, {
reactChildrenCount: number;

onModalWillPresent: OnModalWillPresentEvent;
onModalDidPresent: OnModalDidPresentEvent;

onModalWillShow: OnModalWillShowEvent;
onModalDidShow: OnModalDidShowEvent;

onModalWillHide: OnModalWillHideEvent;
onModalDidHide: OnModalDidHideEvent;
}>;

export type RNIModalSheetNativeViewProps =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';

import type { BubblingEventHandler, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
import type { HostComponent, ViewProps } from 'react-native';

Expand All @@ -7,6 +8,14 @@ export interface NativeProps extends ViewProps {
// common/shared events
onDidSetViewID?: BubblingEventHandler<{}>;

onModalWillPresent?: BubblingEventHandler<{}>;
onModalDidPresent?: BubblingEventHandler<{}>;

onModalWillShow?: BubblingEventHandler<{}>;
onModalDidShow?: BubblingEventHandler<{}>;
onModalWillHide?: BubblingEventHandler<{}>;
onModalDidHide?: BubblingEventHandler<{}>;

// value prop stubs
reactChildrenCount: Int32;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export type RNIModalSheetViewRef = {
export type RNIModalSheetViewInheritedOptionalProps = Partial<Pick<RNIModalSheetNativeViewProps,
// shared/internal events
| 'onDidSetViewID'

// common modal presentation events
| 'onModalWillPresent'
| 'onModalDidPresent'
| 'onModalWillShow'
| 'onModalDidShow'
| 'onModalWillHide'
| 'onModalDidHide'
>>;

export type RNIModalSheetViewBaseProps = {
Expand Down
39 changes: 39 additions & 0 deletions src/types/CommonModalEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { BubblingEventHandler } from 'react-native/Libraries/Types/CodegenTypes';


// MARK: Event Objects
// -------------------

export type OnModalWillPresentPayload = Readonly<{}>;

export type OnModalDidPresentEventPayload = Readonly<{}>;

export type OnModalWillShowEventPayload = Readonly<{}>;

export type OnModalDidShowEventPayload = Readonly<{}>;

export type OnModalWillHideEventPayload = Readonly<{}>;

export type OnModalDidHideEventPayload = Readonly<{}>;

// MARK: Events
// ------------

export type OnModalWillPresentEvent =
BubblingEventHandler<OnModalWillPresentPayload>;

export type OnModalDidPresentEvent =
BubblingEventHandler<OnModalDidPresentEventPayload>;

export type OnModalWillShowEvent =
BubblingEventHandler<OnModalWillShowEventPayload>;

export type OnModalDidShowEvent =
BubblingEventHandler<OnModalDidShowEventPayload>;

export type OnModalWillHideEvent =
BubblingEventHandler<OnModalWillHideEventPayload>;

export type OnModalDidHideEvent =
BubblingEventHandler<OnModalDidHideEventPayload>;

0 comments on commit adffaf0

Please sign in to comment.