Skip to content

Commit

Permalink
⭐️ Impl: ModalSheetView State Change Events Scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 28, 2024
1 parent 0c84b2b commit f80e203
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView {
public enum Events: String, CaseIterable {
case onModalWillPresent;
case onModalDidPresent;

case onModalWillShow;
case onModalDidShow;

case onModalWillHide;
case onModalDidHide;

case onModalSheetStateWillChange;
case onModalSheetStateDidChange;
};

public static var propKeyPathMap: PropKeyPathMap {
Expand Down
3 changes: 3 additions & 0 deletions ios/RNIModalSheetView/RNIModalSheetViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ - (UIView *)view
RNI_EXPORT_VIEW_EVENT(onModalWillHide, RCTBubblingEventBlock);
RNI_EXPORT_VIEW_EVENT(onModalDidHide, RCTBubblingEventBlock);

RNI_EXPORT_VIEW_EVENT(onModalSheetStateWillChange, RCTBubblingEventBlock);
RNI_EXPORT_VIEW_EVENT(onModalSheetStateDidChange, RCTBubblingEventBlock);

#endif

@end
Expand Down
5 changes: 4 additions & 1 deletion src/components/ModalSheetView/ModalSheetViewTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export type ModalSheetViewInheritedProps = Pick<RNIModalSheetViewProps,
| 'onModalDidShow'
| 'onModalWillHide'
| 'onModalDidHide'

// modal sheet events
| 'onModalSheetStateWillChange'
| 'onModalSheetStateDidChange'
>;

export type ModalSheetViewBaseProps = {
Expand All @@ -53,5 +57,4 @@ export type ModalSheetViewBaseProps = {
export type ModalSheetViewProps = PropsWithChildren<
ModalSheetViewInheritedProps
& ModalSheetViewBaseProps
& ViewProps
>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type NativeProps as RNIModalSheetViewNativeComponentProps,
} from './RNIModalSheetViewNativeComponent';

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


Expand All @@ -23,6 +24,9 @@ export type RNIModalSheetNativeViewBaseProps = RemapObject<RNIModalSheetViewNati

onModalWillHide: OnModalWillHideEvent;
onModalDidHide: OnModalDidHideEvent;

onModalSheetStateWillChange: OnModalSheetStateWillChangeEvent;
onModalSheetStateDidChange: OnModalSheetStateDidChangeEvent;
}>;

export type RNIModalSheetNativeViewProps =
Expand Down
20 changes: 17 additions & 3 deletions src/native_components/RNIModalSheetVIew/RNIModalSheetViewEvents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@

import type { ViewProps } from 'react-native';
import type { OnDidSetViewIDEventPayload } from 'react-native-ios-utilities';

import type { BubblingEventHandler } from 'react-native/Libraries/Types/CodegenTypes';


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

export type OnModalSheetStateWillChangeEventPayload = Readonly<{
}>;

export type OnModalSheetStateDidChangeEventPayload = Readonly<{
}>;

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

export type OnModalSheetStateWillChangeEvent =
BubblingEventHandler<OnModalSheetStateWillChangeEventPayload>;

export type OnModalSheetStateDidChangeEvent =
BubblingEventHandler<OnModalSheetStateDidChangeEventPayload>;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface NativeProps extends ViewProps {
onModalWillHide?: BubblingEventHandler<{}>;
onModalDidHide?: BubblingEventHandler<{}>;

onModalSheetStateWillChange?: BubblingEventHandler<{}>;
onModalSheetStateDidChange?: BubblingEventHandler<{}>;

// value prop stubs
reactChildrenCount: Int32;
};
Expand Down

0 comments on commit f80e203

Please sign in to comment.