Zipline-Android-App/components/skeleton/Skeleton.tsx
Stef-00012 438f3b9bbe
Some checks failed
Build APK / build (push) Has been cancelled
add skeleton loading, fix not being able to login when non-admin
2025-05-05 19:37:09 +02:00

53 lines
978 B
TypeScript

import type { ReactElement } from "react";
import { colors } from "@/constants/skeleton";
import { Skeleton as NativeSkeleton } from "moti/skeleton";
import { type DimensionValue, View } from "react-native";
interface Props {
children?: ReactElement | null;
disableAnimation?: boolean;
width?: DimensionValue;
height?: DimensionValue;
radius?: "round" | "square" | number;
}
function Skeleton({
children,
disableAnimation,
width,
height,
radius,
}: Props) {
if (disableAnimation) {
if (radius === "square") radius = 0;
else if (radius === "round") radius = 9999;
return (
<View
style={{
width: width,
height: height,
borderRadius: radius || 8,
backgroundColor: colors[1],
}}
>
{children}
</View>
);
}
return (
<NativeSkeleton
colors={colors}
width={width}
height={height}
radius={radius}
>
{children}
</NativeSkeleton>
);
}
Skeleton.Group = NativeSkeleton.Group;
export default Skeleton;