From 7a3221248feac3cfba964a1e4a7fe3d17b2a70e6 Mon Sep 17 00:00:00 2001 From: Agusti Date: Wed, 11 Sep 2024 15:32:22 +0200 Subject: [PATCH] feat: passes down info about previousFrame to LoadingScreen component like aspect ratio, buttons, and input --- packages/render/src/ui/frame.base.tsx | 10 ++++++++++ packages/render/src/ui/types.ts | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/packages/render/src/ui/frame.base.tsx b/packages/render/src/ui/frame.base.tsx index 078fe40e..30b2c5cb 100644 --- a/packages/render/src/ui/frame.base.tsx +++ b/packages/render/src/ui/frame.base.tsx @@ -79,6 +79,8 @@ export function BaseFrameUI>({ const rootRef = useRef(null); const rootDimensionsRef = useRef(); const previousFrameAspectRatioRef = useRef<"1:1" | "1.91:1" | undefined>(); + const previousFrameButtonsRef = useRef(null); + const previousFrameTextInputRef = useRef(null); const onImageLoadEnd = useCallback(() => { setIsImageLoading(false); @@ -242,6 +244,11 @@ export function BaseFrameUI>({ ? components.LoadingScreen( { frameState: frameUiState, + previousFrame: { + aspectRatio: previousFrameAspectRatioRef.current ?? null, + buttons: previousFrameButtonsRef.current ?? 0, + textInput: previousFrameTextInputRef.current ?? false, + }, dimensions: rootDimensionsRef.current ?? null, }, theme?.LoadingScreen || ({} as TStylingProps) @@ -272,6 +279,9 @@ export function BaseFrameUI>({ previousFrameAspectRatioRef.current = frameUiState.frame.imageAspectRatio ?? "1.91:1"; + // track number of buttons + previousFrameButtonsRef.current = frameUiState.frame.buttons?.length ?? 0; + previousFrameTextInputRef.current = frameUiState.frame.inputText !== undefined; Promise.resolve( frameState.onButtonPress( // @todo change the type onButtonPress to accept partial frame as well because that can happen if partial frames are enabled diff --git a/packages/render/src/ui/types.ts b/packages/render/src/ui/types.ts index b11c89c4..d8de91d7 100644 --- a/packages/render/src/ui/types.ts +++ b/packages/render/src/ui/types.ts @@ -75,6 +75,11 @@ export type FrameImageContainerProps = { export type FrameLoadingScreenProps = FrameUIStateProps & { dimensions: RootContainerDimensions | null; + previousFrame?: { + aspectRatio?: "1:1" | "1.91:1" | null; + buttons?: number; + textInput?: boolean; + }; }; export type FrameButtonContainerProps = {