From 2a8070f132b4066aa8718662102252811c516619 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Fri, 27 Sep 2024 18:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=20Impl:=20`ModalSheetView.ge?= =?UTF-8?q?tCachedModalMetrics`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ModalSheetView/ModalSheetView.tsx | 3 +++ src/components/ModalSheetView/ModalSheetViewTypes.tsx | 1 + .../RNIModalSheetVIew/RNIModalSheetView.tsx | 9 +++++++++ .../RNIModalSheetVIew/RNIModalSheetViewTypes.ts | 1 + 4 files changed, 14 insertions(+) diff --git a/src/components/ModalSheetView/ModalSheetView.tsx b/src/components/ModalSheetView/ModalSheetView.tsx index 7b5b21c9..58f43e58 100644 --- a/src/components/ModalSheetView/ModalSheetView.tsx +++ b/src/components/ModalSheetView/ModalSheetView.tsx @@ -41,6 +41,9 @@ export const ModalSheetView = React.forwardRef< ...commandArgs, }); }, + getCachedModalMetrics: () => { + return nativeRef.current?.getCachedModalMetrics(); + }, getModalMetrics: async () => { if(nativeRef.current == null) { throw Error("Unable to get ref to native sheet"); diff --git a/src/components/ModalSheetView/ModalSheetViewTypes.tsx b/src/components/ModalSheetView/ModalSheetViewTypes.tsx index 2b4bdc72..11df65e9 100644 --- a/src/components/ModalSheetView/ModalSheetViewTypes.tsx +++ b/src/components/ModalSheetView/ModalSheetViewTypes.tsx @@ -6,6 +6,7 @@ import type { RNIModalSheetViewProps, RNIModalSheetViewRef } from "../../native_ type ModalSheetViewRefInherited = Pick; diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx b/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx index e3e8bae1..a45b383d 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetView.tsx @@ -13,6 +13,11 @@ export const RNIModalSheetView = React.forwardRef< >((props, ref) => { const [viewID, setViewID] = React.useState(); const [reactTag, setReactTag] = React.useState(); + + const [ + cachedModalMetrics, + setCachedModalMetrics + ] = React.useState(); React.useImperativeHandle(ref, () => ({ getReactTag: () => { @@ -41,6 +46,9 @@ export const RNIModalSheetView = React.forwardRef< /* commandArgs: */ commandArgs, ); }, + getCachedModalMetrics: () => { + return cachedModalMetrics; + }, getModalMetrics: async () => { if(viewID == null) return; const module = Helpers.getRNIUtilitiesModule(); @@ -51,6 +59,7 @@ export const RNIModalSheetView = React.forwardRef< /* commandArgs: */ {}, ); + setCachedModalMetrics(result as any); return result as any; }, })); diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts index 050f8712..d525e66f 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts @@ -19,6 +19,7 @@ export type RNIModalSheetViewRef = { isAnimated: boolean; }) => Promise; + getCachedModalMetrics: () => ModalMetrics | undefined; getModalMetrics: () => Promise; };