2024-10-13 11:29:36 +00:00
|
|
|
import { Text, View } from '@/components/shared/Themed';
|
|
|
|
|
import styled from '@emotion/native';
|
|
|
|
|
import { formatTime } from '@/components/shared/business/timeHelpers';
|
|
|
|
|
import Button from '@/components/shared/Button';
|
|
|
|
|
import { VerticalSpacer } from '@/components/shared/Spacers';
|
|
|
|
|
import { TimerBgColor } from '@/components/useCases/timer/business/type';
|
|
|
|
|
import { useNavigation } from 'expo-router';
|
|
|
|
|
import { NativeStackNavigationProp } from 'react-native-screens/lib/typescript/native-stack/types';
|
|
|
|
|
import { RootStackParamList } from '@/app/RootStackParamList';
|
|
|
|
|
|
|
|
|
|
interface TimerContentProps {
|
|
|
|
|
isWorkPhase: boolean;
|
|
|
|
|
timeLeft: number;
|
|
|
|
|
reps: number;
|
|
|
|
|
currentRep: number;
|
|
|
|
|
isRunning: boolean;
|
|
|
|
|
handleStop: () => void;
|
|
|
|
|
handleContine: () => void;
|
|
|
|
|
bgColor: TimerBgColor;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-13 21:18:08 +00:00
|
|
|
type NavigationProp = NativeStackNavigationProp<RootStackParamList, 'Dashboard'>;
|
2024-10-13 11:29:36 +00:00
|
|
|
|
|
|
|
|
export default function TimerContent({
|
|
|
|
|
isWorkPhase,
|
|
|
|
|
timeLeft,
|
|
|
|
|
reps,
|
|
|
|
|
currentRep,
|
|
|
|
|
isRunning,
|
|
|
|
|
handleStop,
|
|
|
|
|
handleContine,
|
|
|
|
|
bgColor,
|
|
|
|
|
}: TimerContentProps ) {
|
|
|
|
|
const navigation = useNavigation<NavigationProp>();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Title>{isWorkPhase ? 'Fight' : 'Repos'}</Title>
|
|
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={8} />
|
|
|
|
|
|
|
|
|
|
<Time>
|
|
|
|
|
{formatTime(timeLeft)}
|
|
|
|
|
</Time>
|
|
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={8} />
|
|
|
|
|
|
|
|
|
|
<Reps>{currentRep} / {reps}</Reps>
|
|
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={8} />
|
|
|
|
|
|
|
|
|
|
<ButtonContainer bgColor={bgColor}>
|
|
|
|
|
{isRunning ? (
|
|
|
|
|
<Button label="Stop" onPress={handleStop} />
|
|
|
|
|
) : (
|
|
|
|
|
<Button label="Start" onPress={handleContine} />
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={3} />
|
|
|
|
|
|
2024-10-13 21:18:08 +00:00
|
|
|
<Button label="Retour" onPress={() => navigation.navigate('Dashboard')} />
|
2024-10-13 11:29:36 +00:00
|
|
|
</ButtonContainer>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ButtonContainer = styled(View)<{ bgColor: TimerBgColor }>(({ theme, bgColor }) => ({
|
|
|
|
|
backgroundColor: theme.colors[bgColor]
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const Title = styled(Text)(({ theme }) => ({
|
|
|
|
|
fontSize: 50,
|
|
|
|
|
fontWeight: 'bold',
|
|
|
|
|
color: theme.colors.white
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const Time = styled(Text)(({ theme }) => ({
|
|
|
|
|
fontSize: 100,
|
|
|
|
|
fontWeight: 'bold',
|
|
|
|
|
color: theme.colors.white
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const Reps = styled(Text)(({ theme }) => ({
|
|
|
|
|
fontSize: 30,
|
|
|
|
|
fontWeight: 'bold',
|
|
|
|
|
color: theme.colors.white
|
|
|
|
|
}));
|