Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
128 lines
3.1 KiB
TypeScript
128 lines
3.1 KiB
TypeScript
/**
|
|
* Loading and Skeleton primitives.
|
|
*
|
|
* - <Loading> — centered ActivityIndicator with optional label
|
|
* - <Skeleton> — animated placeholder block (uses opacity cycling, no Reanimated)
|
|
*/
|
|
|
|
import { useEffect, useRef } from "react";
|
|
import {
|
|
ActivityIndicator,
|
|
Animated,
|
|
StyleSheet,
|
|
Text,
|
|
View,
|
|
type StyleProp,
|
|
type ViewStyle,
|
|
} from "react-native";
|
|
|
|
import { colors } from "@/components/me/theme";
|
|
import { radius, spacing } from "@/src/shared/theme";
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Loading indicator
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export interface LoadingProps {
|
|
label?: string;
|
|
size?: "small" | "large";
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
export function Loading({ label, size = "small", style }: LoadingProps): React.JSX.Element {
|
|
return (
|
|
<View style={[styles.center, style]}>
|
|
<ActivityIndicator size={size} color={colors.accent} />
|
|
{label ? <Text style={styles.label}>{label}</Text> : null}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Skeleton placeholder
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export interface SkeletonProps {
|
|
width?: number | `${number}%`;
|
|
height?: number;
|
|
borderRadius?: number;
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
export function Skeleton({
|
|
width = "100%",
|
|
height = 16,
|
|
borderRadius = radius.md,
|
|
style,
|
|
}: SkeletonProps): React.JSX.Element {
|
|
const opacity = useRef(new Animated.Value(0.4)).current;
|
|
|
|
useEffect(() => {
|
|
const animation = Animated.loop(
|
|
Animated.sequence([
|
|
Animated.timing(opacity, {
|
|
toValue: 0.8,
|
|
duration: 800,
|
|
useNativeDriver: true,
|
|
}),
|
|
Animated.timing(opacity, {
|
|
toValue: 0.4,
|
|
duration: 800,
|
|
useNativeDriver: true,
|
|
}),
|
|
]),
|
|
);
|
|
animation.start();
|
|
return () => animation.stop();
|
|
}, [opacity]);
|
|
|
|
return (
|
|
<Animated.View
|
|
style={[
|
|
styles.skeleton,
|
|
{ width, height, borderRadius, opacity },
|
|
style,
|
|
]}
|
|
/>
|
|
);
|
|
}
|
|
|
|
/** A column of skeleton lines — useful for card placeholders. */
|
|
export interface SkeletonCardProps {
|
|
lines?: number;
|
|
style?: StyleProp<ViewStyle>;
|
|
}
|
|
|
|
export function SkeletonCard({ lines = 3, style }: SkeletonCardProps): React.JSX.Element {
|
|
return (
|
|
<View style={[styles.skeletonCard, style]}>
|
|
{Array.from({ length: lines }).map((_, i) => (
|
|
<Skeleton
|
|
key={i}
|
|
width={i === 0 ? "60%" : "100%"}
|
|
height={i === 0 ? 18 : 13}
|
|
/>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
center: {
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
paddingVertical: spacing.xl,
|
|
gap: spacing.sm,
|
|
},
|
|
label: { color: colors.muted, fontSize: 13 },
|
|
skeleton: { backgroundColor: colors.cardAlt },
|
|
skeletonCard: {
|
|
backgroundColor: colors.card,
|
|
borderColor: colors.border,
|
|
borderWidth: 1,
|
|
borderRadius: radius.lg,
|
|
padding: spacing.lg,
|
|
gap: spacing.sm,
|
|
},
|
|
});
|