This repository has been archived on 2025-11-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
trafficcue-client/src/lib/components/lnv/view.svelte.ts
Jannik 28796ee267
Some checks failed
TrafficCue CI / check (push) Failing after 57s
TrafficCue CI / build (push) Successful in 1m38s
TrafficCue CI / build-android (push) Successful in 15m1s
feat: add loading state to view
2025-09-16 18:24:24 +02:00

32 lines
740 B
TypeScript

import { getOnboardingView } from "$lib/onboarding.svelte";
export interface View {
type: string;
props?: Record<string, unknown>;
}
export const view = $state({
loading: false,
current: { type: getOnboardingView("main") } as View,
history: [] as View[],
back: () => {
view.loading = false;
if (view.history.length > 0) {
view.current = view.history.pop()!;
} else {
view.current = { type: "main" } as View; // Reset to main view if history is empty
}
},
switch: (to: string, props?: Record<string, unknown>) => {
if (view.current.type !== to) {
view.history.push(view.current);
}
view.loading = false;
view.current = { type: to, props } as View;
},
});
export const searchbar = $state({
text: "",
});