import React, { useEffect, useState } from 'react'; import { View, Text } from 'react-native'; import { useAppTheme } from '@theme'; import { getStyles } from './countdownTimer.styles'; interface CountdownTimerProps { durationSeconds: number; onExpire: () => void; color?: string; } export const CountdownTimer: React.FC = ({ durationSeconds, onExpire, color, }) => { const { colors } = useAppTheme(); const styles = getStyles(colors); const [timeLeft, setTimeLeft] = useState(durationSeconds); useEffect(() => { if (timeLeft <= 0) { onExpire(); return; } const timer = setInterval(() => { setTimeLeft((prev) => prev - 1); }, 1000); return () => clearInterval(timer); }, [timeLeft, onExpire]); const progressColor = color || colors.primary; return ( {timeLeft}s ); }; export default CountdownTimer;