import React, { useEffect, useRef } from 'react';
import {
View,
StyleSheet,
Animated,
useColorScheme,
} from 'react-native';
import { Colors } from '../constants/Colors';
interface SkeletonRowProps {
delay?: number;
}
function SkeletonRow({ delay = 0 }: SkeletonRowProps) {
const colorScheme = useColorScheme() ?? 'light';
const colors = Colors[colorScheme];
const opacity = useRef(new Animated.Value(0.3)).current;
useEffect(() => {
const animation = Animated.loop(
Animated.sequence([
Animated.timing(opacity, {
toValue: 0.7,
duration: 800,
useNativeDriver: true,
delay,
}),
Animated.timing(opacity, {
toValue: 0.3,
duration: 800,
useNativeDriver: true,
}),
])
);
animation.start();
return () => animation.stop();
}, [opacity, delay]);
const bgColor = colorScheme === 'dark' ? '#374151' : '#e5e7eb';
return (
);
}
export function TaskListSkeleton() {
return (
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
row: {
flexDirection: 'row',
alignItems: 'center',
paddingVertical: 16,
paddingHorizontal: 16,
borderBottomWidth: StyleSheet.hairlineWidth,
minHeight: 64,
},
dot: {
width: 10,
height: 10,
borderRadius: 5,
marginRight: 12,
},
content: {
flex: 1,
gap: 8,
},
titleBar: {
height: 16,
width: '70%',
borderRadius: 4,
},
subtitleBar: {
height: 12,
width: '40%',
borderRadius: 4,
},
});