Add Illness Question #11

Merged
anthony.richard merged 1 commits from Add_Illness_Question into Quiz_Behind 4 months ago

@ -1,27 +1,18 @@
import BackButton from "@/components/BackButton"; import BackButton from "@/components/BackButton";
import { toBgColor, toTextColor } from "@/components/Constants"; import { toBgColor, toTextColor } from "@/components/Constants";
import WeightQuestion, { import { WeightQuestionRef } from "@/components/quiz/WeightQuestion";
WeightQuestionRef,
} from "@/components/quiz/WeightQuestion";
import React, { useRef, useState } from "react"; import React, { useRef, useState } from "react";
import { View } from "react-native"; import { View } from "react-native";
import Button from "@/components/ui/Button";
import Screen from "@/components/ui/Screen"; import Screen from "@/components/ui/Screen";
import Text from "@/components/ui/Text"; import Text from "@/components/ui/Text";
import Button from "@/components/ui/Button"; import { FrequencyQuestionRef } from "@/components/quiz/FrequencyQuestion";
import HeightQuestion, { import { GoalQuestionRef } from "@/components/quiz/GoalQuestion";
HeightQuestionRef, import { GenderQuestionRef } from "@/components/quiz/GenderQuestion";
} from "@/components/quiz/HeightQuestion"; import { HeightQuestionRef } from "@/components/quiz/HeightQuestion";
import AgeQuestion, { AgeQuestionRef } from "@/components/quiz/AgeQuestion"; import { AgeQuestionRef } from "@/components/quiz/AgeQuestion";
import BeginnerQuestion, { import { BeginnerQuestionRef } from "@/components/quiz/BeginnerQuestion";
BeginnerQuestionRef, import IllnessQuestion from "@/components/quiz/IllnessQuestion";
} 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";
export default function Quiz() { export default function Quiz() {
const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0); const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0);
@ -39,19 +30,20 @@ export default function Quiz() {
} }
const questions: Question[] = [ const questions: Question[] = [
{ component: GoalQuestion, props: { ref: goalRef } }, { component: IllnessQuestion, props: {} },
{ component: GenderQuestion, props: { ref: genderRef } }, // { component: GoalQuestion, props: { ref: goalRef } },
{ // { component: GenderQuestion, props: { ref: genderRef } },
component: WeightQuestion, // {
props: { ref: weightRef }, // component: WeightQuestion,
}, // props: { ref: weightRef },
{ component: HeightQuestion, props: { ref: heightRef } }, // },
{ component: AgeQuestion, props: { ref: ageRef } }, // { component: HeightQuestion, props: { ref: heightRef } },
{ component: BeginnerQuestion, props: { ref: beginnerRef } }, // { component: AgeQuestion, props: { ref: ageRef } },
{ // { component: BeginnerQuestion, props: { ref: beginnerRef } },
component: FrequencyQuestion, // {
props: { ref: frequencyRef, isMale: genderRef.current?.getAnswer() }, // component: FrequencyQuestion,
}, // props: { ref: frequencyRef, isMale: genderRef.current?.getAnswer() },
// },
]; ];
const goNext = () => { const goNext = () => {
@ -75,10 +67,14 @@ export default function Quiz() {
return ( return (
<Screen> <Screen>
<View className="gap-4 justify-between h-full"> <View className="gap-4 justify-between h-full">
<View className="flex-row justify-between items-center"> <View className="flex-row justify-between items-center gap-4">
<BackButton <BackButton
className="mt-2"
onPress={() => setCurrentQuestionIndex((i) => Math.max(i - 1, 0))} onPress={() => setCurrentQuestionIndex((i) => Math.max(i - 1, 0))}
/> />
<Text size="2xl" weight="bold">
Questionnaire
</Text>
<View className={"px-4 py-2 rounded-2xl" + " " + toBgColor("blue")}> <View className={"px-4 py-2 rounded-2xl" + " " + toBgColor("blue")}>
<Text className={toTextColor("blue")} weight="bold"> <Text className={toTextColor("blue")} weight="bold">
{currentQuestionIndex + 1} sur {questions.length} {currentQuestionIndex + 1} sur {questions.length}

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

@ -1,26 +1,26 @@
import { router } from "expo-router"; import { router } from "expo-router";
import Button from "./ui/Button"; import Button from "./ui/Button";
import { TouchableOpacityProps } from "react-native"; import { ButtonProps } from "./ui/Button";
import { AntDesign } from "@expo/vector-icons"; import { AntDesign } from "@expo/vector-icons";
import React from "react"; import React from "react";
import { AntDesignIconNames } from "./Icons"; import { AntDesignIconNames } from "./Icons";
interface Props extends TouchableOpacityProps { interface Props extends ButtonProps {
icon?: AntDesignIconNames; icon?: AntDesignIconNames;
} }
export default React.forwardRef<any, Props>( export default React.forwardRef<any, Props>(
(props, ref): React.ReactElement => { ({ icon, onPress, className, ...props }, ref): React.ReactElement => {
const { icon, onPress } = props;
const defaultOnPress = () => { const defaultOnPress = () => {
router.back(); router.back();
}; };
return ( return (
<Button <Button
className="h-16 w-16 mb-4" className={"h-16 w-16 mb-4" + " " + className}
onPress={onPress ?? defaultOnPress} onPress={onPress ?? defaultOnPress}
{...ref} {...ref}
{...props}
> >
<AntDesign name={icon ?? "arrowleft"} size={24} /> <AntDesign name={icon ?? "arrowleft"} size={24} />
</Button> </Button>

@ -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<any, QuestionChildProps>(
({ ...props }, ref) => {
const [selected, setSelected] = useState<string[]>([]);
type DataItem = {
label: string;
value: EHealthProblem;
};
const data: DataItem[] = [
{ label: "Arthrose", value: "ARTHROSE" },
{ label: "Migraine", value: "MIGRAINE" },
];
const renderItem = (item: { label: string }) => {
return (
<View className="p-4">
<Text>{item.label}</Text>
</View>
);
};
return (
<Question
question="Avez-vous des problèmes physiques ?"
{...props}
{...ref}
>
<Image className="self-center" source={WheelChair} alt="" />
<View className="border-2 border-orange-500 rounded-3xl p-4">
<MultiSelect
data={data}
labelField="label"
valueField="value"
placeholder="Selectionnez un problème physique "
searchPlaceholder="Search..."
value={selected}
onChange={setSelected}
renderItem={renderItem}
/>
</View>
</Question>
);
}
);

@ -8,7 +8,7 @@ import { Size } from "../Constants";
export type ButtonStyle = "default" | "outline" | "secondary"; export type ButtonStyle = "default" | "outline" | "secondary";
//@ts-ignore //@ts-ignore
interface Props extends TouchableOpacityProps { export interface ButtonProps extends TouchableOpacityProps {
size?: Size; size?: Size;
style?: ButtonStyle; style?: ButtonStyle;
insideClassName?: string; insideClassName?: string;
@ -16,7 +16,7 @@ interface Props extends TouchableOpacityProps {
afterIcon?: AntDesignIconNames; afterIcon?: AntDesignIconNames;
} }
export default React.forwardRef<any, Props>( export default React.forwardRef<any, ButtonProps>(
( (
{ {
size, size,

17
package-lock.json generated

@ -37,6 +37,7 @@
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-hook-form": "^7.54.2", "react-hook-form": "^7.54.2",
"react-native": "0.76.6", "react-native": "0.76.6",
"react-native-element-dropdown": "^2.12.4",
"react-native-gesture-handler": "^2.20.2", "react-native-gesture-handler": "^2.20.2",
"react-native-gifted-charts": "^1.4.54", "react-native-gifted-charts": "^1.4.54",
"react-native-reanimated": "^3.16.7", "react-native-reanimated": "^3.16.7",
@ -12247,6 +12248,22 @@
"node": ">=10" "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": { "node_modules/react-native-gesture-handler": {
"version": "2.22.0", "version": "2.22.0",
"resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.22.0.tgz", "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.22.0.tgz",

@ -44,6 +44,7 @@
"react-dom": "18.3.1", "react-dom": "18.3.1",
"react-hook-form": "^7.54.2", "react-hook-form": "^7.54.2",
"react-native": "0.76.6", "react-native": "0.76.6",
"react-native-element-dropdown": "^2.12.4",
"react-native-gesture-handler": "^2.20.2", "react-native-gesture-handler": "^2.20.2",
"react-native-gifted-charts": "^1.4.54", "react-native-gifted-charts": "^1.4.54",
"react-native-reanimated": "^3.16.7", "react-native-reanimated": "^3.16.7",

Loading…
Cancel
Save