feat(mobile): MIKRO POLISH-2 cyklande laddningsmeddelanden på scan-väntan
This commit is contained in:
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user