From d4a19aa1f5bb39f0379141eb9adea4458cfa5ffa Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Fri, 27 Sep 2024 18:18:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20Ex=20-=20`ModalSheetVi?= =?UTF-8?q?ewTest01`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/src/examples/ModalSheetViewTest01.tsx | 80 ++++++++++++++++++- 1 file changed, 77 insertions(+), 3 deletions(-) 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, }} /> )}