You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
import React, { useImperativeHandle } from "react";
|
|
import { View } from "react-native";
|
|
import SegmentedControl from "../ui/SegmentedControl";
|
|
import Text from "../ui/Text";
|
|
import Question, { QuestionChildProps } from "./Question";
|
|
|
|
const ANSWERS = ["1", "2", "3", "4", "5"];
|
|
|
|
export interface FrequencyQuestionRef {
|
|
getAnswer: () => number;
|
|
}
|
|
|
|
export interface FrequencyQuestionProps extends QuestionChildProps {
|
|
isMale: boolean;
|
|
}
|
|
|
|
export default React.forwardRef<FrequencyQuestionRef, FrequencyQuestionProps>(
|
|
({ isMale, ...props }, ref): React.ReactElement => {
|
|
const [answer, setAnswer] = React.useState("1");
|
|
|
|
useImperativeHandle(ref, () => ({
|
|
getAnswer: () => parseInt(answer),
|
|
}));
|
|
|
|
return (
|
|
<Question
|
|
question="Nombre de séance(s) par semaine ?"
|
|
{...ref}
|
|
{...props}
|
|
>
|
|
<View className="items-center">
|
|
<Text size="2xl">
|
|
Je suis {isMale ? "prêt" : "prête"} à m'entraîner
|
|
</Text>
|
|
<Text size="9xl" weight="bold">
|
|
{answer}
|
|
</Text>
|
|
<Text size="2xl">fois par semaine !</Text>
|
|
</View>
|
|
<SegmentedControl
|
|
values={ANSWERS}
|
|
selectedIndex={ANSWERS.indexOf(answer)}
|
|
onValueChange={setAnswer}
|
|
/>
|
|
</Question>
|
|
);
|
|
}
|
|
);
|