feat(mobile): MIKRO POLISH-2 cyklande laddningsmeddelanden på scan-väntan

This commit is contained in:
Sven (AAMOS AI)
2026-08-17 21:17:24 +07:00
parent b1a93be974
commit 653f94de86
2 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ export default function ScanReviewScreen() {
if (query.isLoading || job?.status === "queued" || job?.status === "running") { if (query.isLoading || job?.status === "queued" || job?.status === "running") {
return ( return (
<Screen scroll={false}> <Screen scroll={false}>
<LoadingView /> <LoadingView messages={["Analyserar bilden…", "Hittar ingredienser…", "Matchar mot ditt kök…", "Snart klar…"]} />
<Body muted>{t("scan.analyzing")}</Body> <Body muted>{t("scan.analyzing")}</Body>
</Screen> </Screen>
); );
+12 -2
View File
@@ -1,4 +1,5 @@
import type { PropsWithChildren, ReactNode } from "react"; import type { PropsWithChildren, ReactNode } from "react";
import { useEffect, useState } from "react";
import { import {
ActivityIndicator, ActivityIndicator,
KeyboardAvoidingView, KeyboardAvoidingView,
@@ -204,11 +205,20 @@ export function ProgressBar({
); );
} }
export function LoadingView() { export function LoadingView({ messages }: { messages?: string[] } = {}) {
const [i, setI] = useState(0);
const list = messages ?? [];
useEffect(() => {
setI(0);
if (list.length <= 1) return;
const id = setInterval(() => setI((v) => (v + 1 < list.length ? v + 1 : v)), 1800);
return () => clearInterval(id);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [list.length]);
return ( return (
<View style={styles.center}> <View style={styles.center}>
<ActivityIndicator size="large" color={colors.primary} /> <ActivityIndicator size="large" color={colors.primary} />
<Small>{t("common.loading")}</Small> <Small>{list.length ? list[i] : t("common.loading")}</Small>
</View> </View>
); );
} }