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.4 KiB
49 lines
1.4 KiB
import React from "react";
|
|
import Question, { QuestionChildProps } from "./Question";
|
|
import Slider from "../ui/Slider";
|
|
import Text from "../ui/Text";
|
|
import { View } from "react-native";
|
|
import SegmentedControl from "@react-native-segmented-control/segmented-control";
|
|
|
|
export default React.forwardRef<any, QuestionChildProps>(
|
|
(props, ref): React.ReactElement => {
|
|
const MIN_WEIGHT = 40;
|
|
const MAX_WEIGHT = 200;
|
|
const UNITS = ["kg", "lb"];
|
|
const [weight, setWeight] = React.useState(MIN_WEIGHT);
|
|
const [unit, setUnit] = React.useState("kg");
|
|
return (
|
|
<Question question="Quel est votre poids ?" {...ref} {...props}>
|
|
<SegmentedControl
|
|
values={UNITS}
|
|
selectedIndex={UNITS.indexOf(unit)}
|
|
onValueChange={setUnit}
|
|
/>
|
|
<View className="flex-row justify-center">
|
|
{weight <= MIN_WEIGHT ? (
|
|
<Text className="mt-8" size="4xl">
|
|
- de
|
|
</Text>
|
|
) : null}
|
|
{weight >= MAX_WEIGHT ? (
|
|
<Text className="mt-8" size="4xl">
|
|
+ de
|
|
</Text>
|
|
) : null}
|
|
<Text size="8xl" weight="bold">
|
|
{weight}
|
|
</Text>
|
|
<Text className="mt-8" size="4xl">
|
|
{unit}
|
|
</Text>
|
|
</View>
|
|
<Slider
|
|
minimumValue={MIN_WEIGHT}
|
|
maximumValue={MAX_WEIGHT}
|
|
onValueChange={setWeight}
|
|
/>
|
|
</Question>
|
|
);
|
|
}
|
|
);
|