-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dpp): add epds survey on app (#162)
* feat(dpp) ajout du questionnaire côté app * feat(dpp) fix lors du clic sur une réponse * feat(dpp) gestion de l'affichage des boutons suivants * feat(dpp) affichage du résultat * feat(dpp) : retours de PR * Update front/constants/Labels.ts Co-authored-by: Benjamin Morali <benjaminmorali4@hotmail.fr> * feat(dpp) use EpdsQuestion component * feat(dpp) use EpdsFooter component * feat(dpp) Clean EpdsSurveyScreen styles Co-authored-by: Benjamin Morali <benjaminmorali4@hotmail.fr>
- Loading branch information
1 parent
c9cb9e8
commit 384583f
Showing
7 changed files
with
466 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import * as React from "react"; | ||
import { Dimensions, StyleSheet } from "react-native"; | ||
import { useRef } from "react"; | ||
import Colors from "../../constants/Colors"; | ||
import BackButton from "../BackButton"; | ||
import { View } from "../Themed"; | ||
import Icomoon, { IcomoonIcons } from "../Icomoon"; | ||
import Labels from "../../constants/Labels"; | ||
import Button from "../form/Button"; | ||
import SwiperFlatListRefProps from "react-native-swiper-flatlist"; | ||
|
||
interface Props { | ||
swiperCurrentIndex: number; | ||
swiperRef: React.RefObject<SwiperFlatListRefProps>; | ||
showValidateButton: boolean | undefined; | ||
questionIsAnswered: boolean | undefined; | ||
setDisplayResult: (value: boolean) => void; | ||
} | ||
|
||
const EpdsFooter: React.FC<Props> = ({ | ||
swiperCurrentIndex, | ||
swiperRef, | ||
showValidateButton, | ||
questionIsAnswered, | ||
setDisplayResult | ||
}) => { | ||
return ( | ||
<View style={[styles.footer, styles.justifyContentCenter]}> | ||
<View style={[styles.buttonsContainer, styles.justifyContentCenter]}> | ||
<View style={[styles.buttonContainer]}> | ||
{swiperCurrentIndex > 0 && ( | ||
<BackButton | ||
action={() => { | ||
swiperRef.current?.scrollToIndex({ | ||
index: swiperCurrentIndex - 1 | ||
}); | ||
}} | ||
/> | ||
)} | ||
</View> | ||
<View style={[styles.buttonContainer]}> | ||
{showValidateButton ? ( | ||
<View style={styles.justifyContentCenter}> | ||
<Button | ||
title={Labels.buttons.validate} | ||
rounded={true} | ||
disabled={false} | ||
action={() => setDisplayResult(true)} | ||
/> | ||
</View> | ||
) : ( | ||
questionIsAnswered && ( | ||
<Button | ||
title={Labels.buttons.next} | ||
rounded={false} | ||
disabled={false} | ||
icon={ | ||
<Icomoon | ||
name={IcomoonIcons.suivant} | ||
size={14} | ||
color={Colors.primaryBlue} | ||
/> | ||
} | ||
action={() => { | ||
swiperRef.current?.scrollToIndex({ | ||
index: swiperCurrentIndex + 1 | ||
}); | ||
}} | ||
/> | ||
) | ||
)} | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const width = Dimensions.get("window").width; | ||
const styles = StyleSheet.create({ | ||
footer: { | ||
flex: 1, | ||
paddingVertical: 10 | ||
}, | ||
justifyContentCenter: { | ||
alignItems: "center", | ||
justifyContent: "center" | ||
}, | ||
buttonContainer: { | ||
flex: 1 | ||
}, | ||
buttonsContainer: { | ||
flexDirection: "row" | ||
}, | ||
}); | ||
|
||
export default EpdsFooter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as React from "react"; | ||
import { Dimensions, StyleSheet } from "react-native"; | ||
import Colors from "../../constants/Colors"; | ||
import { Answer, QuestionAndAnswers } from "../../screens/EpdsSurveyScreen"; | ||
import Checkbox from "../form/Checkbox"; | ||
import { CommonText } from "../StyledText"; | ||
import { View } from "../Themed"; | ||
|
||
interface Props { | ||
questionAndAnswers: QuestionAndAnswers; | ||
questionIndex: number; | ||
updatePressedAnswer: (answer: Answer) => void; | ||
} | ||
|
||
const EpdsQuestion: React.FC<Props> = ({ | ||
questionAndAnswers, | ||
questionIndex, | ||
updatePressedAnswer | ||
}) => { | ||
return ( | ||
<View | ||
style={[styles.swipeView, styles.justifyContentCenter]} | ||
key={questionIndex} | ||
> | ||
<View style={styles.swipeViewMargin}> | ||
<CommonText style={[styles.title, styles.textAlignCenter]}> | ||
{questionAndAnswers.question} | ||
</CommonText> | ||
{questionAndAnswers.answers.map((answer, answerIndex) => { | ||
return ( | ||
<Checkbox | ||
key={answerIndex} | ||
title={answer.label} | ||
checked={answer.isChecked} | ||
onPress={() => { | ||
updatePressedAnswer(answer); | ||
}} | ||
/> | ||
); | ||
})} | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const width = Dimensions.get("window").width; | ||
const styles = StyleSheet.create({ | ||
justifyContentCenter: { | ||
alignItems: "center", | ||
justifyContent: "center" | ||
}, | ||
swipeView: { | ||
width | ||
}, | ||
swipeViewMargin: { | ||
margin: "10%" | ||
}, | ||
textAlignCenter: { | ||
textAlign: "center" | ||
}, | ||
title: { | ||
color: Colors.primaryBlueDark, | ||
fontSize: 15, | ||
fontWeight: "bold", | ||
paddingBottom: 15, | ||
paddingHorizontal: 15 | ||
} | ||
}); | ||
|
||
export default EpdsQuestion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.