diff --git a/app/(quiz)/quiz.tsx b/app/(quiz)/quiz.tsx index 5d365af..3eae98c 100644 --- a/app/(quiz)/quiz.tsx +++ b/app/(quiz)/quiz.tsx @@ -1,27 +1,18 @@ import BackButton from "@/components/BackButton"; import { toBgColor, toTextColor } from "@/components/Constants"; -import WeightQuestion, { - WeightQuestionRef, -} from "@/components/quiz/WeightQuestion"; +import { WeightQuestionRef } from "@/components/quiz/WeightQuestion"; import React, { useRef, useState } from "react"; import { View } from "react-native"; +import Button from "@/components/ui/Button"; import Screen from "@/components/ui/Screen"; import Text from "@/components/ui/Text"; -import Button from "@/components/ui/Button"; -import HeightQuestion, { - HeightQuestionRef, -} from "@/components/quiz/HeightQuestion"; -import AgeQuestion, { AgeQuestionRef } from "@/components/quiz/AgeQuestion"; -import BeginnerQuestion, { - BeginnerQuestionRef, -} from "@/components/quiz/BeginnerQuestion"; -import FrequencyQuestion, { - FrequencyQuestionRef, -} from "@/components/quiz/FrequencyQuestion"; -import GenderQuestion, { - GenderQuestionRef, -} from "@/components/quiz/GenderQuestion"; -import GoalQuestion, { GoalQuestionRef } from "@/components/quiz/GoalQuestion"; +import { FrequencyQuestionRef } from "@/components/quiz/FrequencyQuestion"; +import { GoalQuestionRef } from "@/components/quiz/GoalQuestion"; +import { GenderQuestionRef } from "@/components/quiz/GenderQuestion"; +import { HeightQuestionRef } from "@/components/quiz/HeightQuestion"; +import { AgeQuestionRef } from "@/components/quiz/AgeQuestion"; +import { BeginnerQuestionRef } from "@/components/quiz/BeginnerQuestion"; +import IllnessQuestion from "@/components/quiz/IllnessQuestion"; export default function Quiz() { const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0); @@ -39,19 +30,20 @@ export default function Quiz() { } const questions: Question[] = [ - { component: GoalQuestion, props: { ref: goalRef } }, - { component: GenderQuestion, props: { ref: genderRef } }, - { - component: WeightQuestion, - props: { ref: weightRef }, - }, - { component: HeightQuestion, props: { ref: heightRef } }, - { component: AgeQuestion, props: { ref: ageRef } }, - { component: BeginnerQuestion, props: { ref: beginnerRef } }, - { - component: FrequencyQuestion, - props: { ref: frequencyRef, isMale: genderRef.current?.getAnswer() }, - }, + { component: IllnessQuestion, props: {} }, + // { component: GoalQuestion, props: { ref: goalRef } }, + // { component: GenderQuestion, props: { ref: genderRef } }, + // { + // component: WeightQuestion, + // props: { ref: weightRef }, + // }, + // { component: HeightQuestion, props: { ref: heightRef } }, + // { component: AgeQuestion, props: { ref: ageRef } }, + // { component: BeginnerQuestion, props: { ref: beginnerRef } }, + // { + // component: FrequencyQuestion, + // props: { ref: frequencyRef, isMale: genderRef.current?.getAnswer() }, + // }, ]; const goNext = () => { @@ -75,10 +67,14 @@ export default function Quiz() { return ( - + setCurrentQuestionIndex((i) => Math.max(i - 1, 0))} /> + + Questionnaire + {currentQuestionIndex + 1} sur {questions.length} diff --git a/assets/images/wheelchair.png b/assets/images/wheelchair.png new file mode 100644 index 0000000..e6005c3 Binary files /dev/null and b/assets/images/wheelchair.png differ diff --git a/components/BackButton.tsx b/components/BackButton.tsx index 05c40f8..2cab0db 100644 --- a/components/BackButton.tsx +++ b/components/BackButton.tsx @@ -1,26 +1,26 @@ import { router } from "expo-router"; import Button from "./ui/Button"; -import { TouchableOpacityProps } from "react-native"; +import { ButtonProps } from "./ui/Button"; import { AntDesign } from "@expo/vector-icons"; import React from "react"; import { AntDesignIconNames } from "./Icons"; -interface Props extends TouchableOpacityProps { +interface Props extends ButtonProps { icon?: AntDesignIconNames; } export default React.forwardRef( - (props, ref): React.ReactElement => { - const { icon, onPress } = props; + ({ icon, onPress, className, ...props }, ref): React.ReactElement => { const defaultOnPress = () => { router.back(); }; return ( diff --git a/components/quiz/IllnessQuestion.tsx b/components/quiz/IllnessQuestion.tsx new file mode 100644 index 0000000..4822d66 --- /dev/null +++ b/components/quiz/IllnessQuestion.tsx @@ -0,0 +1,54 @@ +import React, { useState } from "react"; +import Question, { QuestionChildProps } from "./Question"; +import { Image, View, Text } from "react-native"; +import { MultiSelect } from "react-native-element-dropdown"; + +//@ts-ignore +import WheelChair from "@/assets/images/wheelchair.png"; +import { EHealthProblem } from "@/model/enums/Enums"; + +export default React.forwardRef( + ({ ...props }, ref) => { + const [selected, setSelected] = useState([]); + + type DataItem = { + label: string; + value: EHealthProblem; + }; + + const data: DataItem[] = [ + { label: "Arthrose", value: "ARTHROSE" }, + { label: "Migraine", value: "MIGRAINE" }, + ]; + + const renderItem = (item: { label: string }) => { + return ( + + {item.label} + + ); + }; + + return ( + + + + + + + ); + } +); diff --git a/components/ui/Button.tsx b/components/ui/Button.tsx index 2abf5b1..6d53996 100644 --- a/components/ui/Button.tsx +++ b/components/ui/Button.tsx @@ -8,7 +8,7 @@ import { Size } from "../Constants"; export type ButtonStyle = "default" | "outline" | "secondary"; //@ts-ignore -interface Props extends TouchableOpacityProps { +export interface ButtonProps extends TouchableOpacityProps { size?: Size; style?: ButtonStyle; insideClassName?: string; @@ -16,7 +16,7 @@ interface Props extends TouchableOpacityProps { afterIcon?: AntDesignIconNames; } -export default React.forwardRef( +export default React.forwardRef( ( { size, diff --git a/package-lock.json b/package-lock.json index 7abaa8c..923d197 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "react-dom": "18.3.1", "react-hook-form": "^7.54.2", "react-native": "0.76.6", + "react-native-element-dropdown": "^2.12.4", "react-native-gesture-handler": "^2.20.2", "react-native-gifted-charts": "^1.4.54", "react-native-reanimated": "^3.16.7", @@ -12247,6 +12248,22 @@ "node": ">=10" } }, + "node_modules/react-native-element-dropdown": { + "version": "2.12.4", + "resolved": "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.12.4.tgz", + "integrity": "sha512-abZc5SVji9FIt7fjojRYrbuvp03CoeZJrgvezQoDoSOrpiTqkX69ix5m+j06W2AVncA0VWvbT+vCMam8SoVadw==", + "license": "MIT", + "dependencies": { + "lodash": "^4.17.21" + }, + "engines": { + "node": ">= 16.0.0" + }, + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/react-native-gesture-handler": { "version": "2.22.0", "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.22.0.tgz", diff --git a/package.json b/package.json index d413f18..9bb52a4 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "react-dom": "18.3.1", "react-hook-form": "^7.54.2", "react-native": "0.76.6", + "react-native-element-dropdown": "^2.12.4", "react-native-gesture-handler": "^2.20.2", "react-native-gifted-charts": "^1.4.54", "react-native-reanimated": "^3.16.7",