import React from "react";
import Question, { QuestionChildProps } from "./Question";
import Slider from "../ui/Slider";
import { View } from "react-native";
import Text from "../ui/Text";

export default React.forwardRef<any, QuestionChildProps>(
  (props, ref): React.ReactElement => {
    const MIN_AGE = 18;
    const MAX_AGE = 100;
    const [age, setAge] = React.useState(MIN_AGE);
    return (
      <Question question="Quel âge avez-vous ?" {...ref} {...props}>
        <View className="flex-row justify-center">
          {age <= MIN_AGE ? (
            <Text className="mt-8" size="4xl">
              - de
            </Text>
          ) : null}
          {age >= MAX_AGE ? (
            <Text className="mt-8" size="4xl">
              + de
            </Text>
          ) : null}
          <Text size="8xl" weight="bold">
            {age}
          </Text>
          <Text className="mt-8" size="4xl">
            ans
          </Text>
        </View>
        <Slider
          minimumValue={MIN_AGE}
          maximumValue={MAX_AGE}
          onValueChange={setAge}
        />
      </Question>
    );
  }
);
