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';
|
2024-10-14 22:06:39 +00:00
|
|
|
import { ElasticSpacer, HorizontalSpacer, VerticalSpacer } from '@/components/shared/Spacers';
|
2024-10-13 11:29:36 +00:00
|
|
|
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';
|
2024-10-13 22:20:52 +00:00
|
|
|
import { i18n } from '@/app/i18n/i18n';
|
2024-10-13 11:29:36 +00:00
|
|
|
|
|
|
|
|
interface TimerContentProps {
|
|
|
|
|
isWorkPhase: boolean;
|
|
|
|
|
timeLeft: number;
|
|
|
|
|
reps: number;
|
|
|
|
|
currentRep: number;
|
|
|
|
|
isRunning: boolean;
|
|
|
|
|
handleStop: () => void;
|
|
|
|
|
handleContine: () => void;
|
2024-10-14 22:06:39 +00:00
|
|
|
nextRep: () => void;
|
|
|
|
|
previousRep: () => void;
|
2024-10-13 11:29:36 +00:00
|
|
|
bgColor: TimerBgColor;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-13 21:18:08 +00:00
|
|
|
type NavigationProp = NativeStackNavigationProp<RootStackParamList, 'Dashboard'>;
|
2024-10-13 11:29:36 +00:00
|
|
|
|
2024-10-13 22:20:52 +00:00
|
|
|
const t = i18n.scoped('timer.timerContent');
|
|
|
|
|
|
2024-10-13 11:29:36 +00:00
|
|
|
export default function TimerContent({
|
|
|
|
|
isWorkPhase,
|
|
|
|
|
timeLeft,
|
|
|
|
|
reps,
|
|
|
|
|
currentRep,
|
|
|
|
|
isRunning,
|
|
|
|
|
handleStop,
|
|
|
|
|
handleContine,
|
2024-10-14 22:06:39 +00:00
|
|
|
nextRep,
|
|
|
|
|
previousRep,
|
2024-10-13 11:29:36 +00:00
|
|
|
bgColor,
|
|
|
|
|
}: TimerContentProps ) {
|
|
|
|
|
const navigation = useNavigation<NavigationProp>();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2024-10-13 22:20:52 +00:00
|
|
|
<Title>{isWorkPhase ? t('fight') : t('rest')}</Title>
|
2024-10-13 11:29:36 +00:00
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={8} />
|
|
|
|
|
|
|
|
|
|
<Time>
|
|
|
|
|
{formatTime(timeLeft)}
|
|
|
|
|
</Time>
|
|
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={8} />
|
|
|
|
|
|
|
|
|
|
<Reps>{currentRep} / {reps}</Reps>
|
|
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={8} />
|
|
|
|
|
|
|
|
|
|
<ButtonContainer bgColor={bgColor}>
|
2024-10-14 22:06:39 +00:00
|
|
|
<Button label={t('prev')} onPress={previousRep} />
|
|
|
|
|
|
|
|
|
|
<ElasticSpacer />
|
|
|
|
|
|
2024-10-13 11:29:36 +00:00
|
|
|
{isRunning ? (
|
2024-10-13 22:20:52 +00:00
|
|
|
<Button label={t('stop')} onPress={handleStop} />
|
2024-10-13 11:29:36 +00:00
|
|
|
) : (
|
2024-10-13 22:20:52 +00:00
|
|
|
<Button label={t('start')} onPress={handleContine} />
|
2024-10-13 11:29:36 +00:00
|
|
|
)}
|
|
|
|
|
|
2024-10-14 22:06:39 +00:00
|
|
|
<ElasticSpacer />
|
2024-10-13 11:29:36 +00:00
|
|
|
|
2024-10-14 22:06:39 +00:00
|
|
|
<Button label={t('next')} onPress={nextRep} />
|
2024-10-13 11:29:36 +00:00
|
|
|
</ButtonContainer>
|
2024-10-14 22:06:39 +00:00
|
|
|
|
|
|
|
|
<VerticalSpacer heightUnits={4} />
|
|
|
|
|
|
|
|
|
|
<Button label={i18n.t('back')} onPress={() => navigation.navigate('Dashboard')} />
|
2024-10-13 11:29:36 +00:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ButtonContainer = styled(View)<{ bgColor: TimerBgColor }>(({ theme, bgColor }) => ({
|
2024-10-14 22:06:39 +00:00
|
|
|
backgroundColor: theme.colors[bgColor],
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'space-between',
|
2024-10-13 11:29:36 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}));
|