diff --git a/example/src/examples/ModalSheetViewTest01.tsx b/example/src/examples/ModalSheetViewTest01.tsx index 0622a4a4..7957c0ba 100644 --- a/example/src/examples/ModalSheetViewTest01.tsx +++ b/example/src/examples/ModalSheetViewTest01.tsx @@ -6,11 +6,17 @@ import { ExampleItemCard, ObjectPropertyDisplay, CardButton, Colors } from 'reac import { ModalSheetView, ModalSheetViewMainContent, type ModalSheetViewRef } from 'react-native-ios-modal'; import type { ExampleItemProps } from './SharedExampleTypes'; +import type { ModalMetrics } from '../../../src/types/ModalMetrics'; export function ModalSheetViewTest01(props: ExampleItemProps) { const modalSheetViewRef = React.useRef(null); + const [ + modalMetrics, + setModalMetrics + ] = React.useState(); + const [ shouldMountRecursiveContent, setShouldMountRecursiveContent, @@ -19,6 +25,37 @@ export function ModalSheetViewTest01(props: ExampleItemProps) { const recursionLevel = props.extraProps?.recursionLevel as any as number ?? 0; + let dataForDebugDisplay = { + }; + + if(modalMetrics != null) { + const modalMetricsUpdated = { + ...modalMetrics, + modalViewControllerMetrics: { + ...modalMetrics.modalViewControllerMetrics, + instanceID: [ + modalMetrics.modalViewControllerMetrics.instanceID + ], + }, + presentationControllerMetrics: { + ...modalMetrics.presentationControllerMetrics, + instanceID: [ + modalMetrics.presentationControllerMetrics?.instanceID + ], + }, + }; + + dataForDebugDisplay = { + ...dataForDebugDisplay, + ...modalMetricsUpdated + }; + }; + + const hasDataForDebugDisplay = + Object.keys(dataForDebugDisplay).length > 0; + + const isFirstRecursion = (recursionLevel == 0); + return ( - {(recursionLevel != 0) && ( + {!isFirstRecursion && ( { - await modalSheetViewRef.current?.dismissModal(); + const modalSheetViewRefPrev: ModalSheetViewRef | null = + props.extraProps?.modalSheetViewRefPrev as any; + + if(modalSheetViewRefPrev == null){ + return; + }; + + await modalSheetViewRefPrev.dismissModal(); console.log( 'ModalSheetViewTest01', '\n - dismiss modal completed', @@ -60,6 +107,32 @@ export function ModalSheetViewTest01(props: ExampleItemProps) { }} /> )} + {!isFirstRecursion && ( + { + + const modalSheetViewRefPrev: ModalSheetViewRef | null = + props.extraProps?.modalSheetViewRefPrev as any; + + if(modalSheetViewRefPrev == null){ + return; + }; + + const modalMetrics = + await modalSheetViewRefPrev.getModalMetrics(); + + setModalMetrics(modalMetrics); + console.log( + 'ModalSheetViewTest01', + '\n - invoked getModalMetrics', + '\n', + modalMetrics, + ); + }} + /> + )} modalSheetViewRef.current = ref} @@ -77,6 +150,7 @@ export function ModalSheetViewTest01(props: ExampleItemProps) { index={props.index} extraProps={{ recursionLevel: recursionLevel + 1, + modalSheetViewRefPrev: modalSheetViewRef.current, }} /> )}