Skip to content
Snippets Groups Projects
Commit 85980898 authored by HARTZ HENRI's avatar HARTZ HENRI
Browse files

refactor: delete answerButtonImage

parent 94746d85
Branches
1 merge request!137Feature/142 add sound response
import {TouchableOpacity, Text, StyleSheet, View, Image} from "react-native";
import {ButtonsStyles} from "../../styles/ButtonsStyles";
import {TextsStyles} from "../../styles/TextsStyles";
interface Props{
url: string;
handleButtonPressed:() => void;
buttonStyle?: any;
indicator?: number | undefined;
}
/**
* AnswerButtonImage : Un bouton par défaut, il possède déjà un style mais on peut le surcharger grâce à la propriété buttonStyle
* @param url - Texte du bouton
* @param handleButtonPressed - Fonction qui sera exécutée lorsque le bouton sera pressé
* @param buttonStyle - Surcharge du style du bouton
* @param buttonText - Surcharge du style du texte du bouton
*/
export default function AnswerButtonImage({url, handleButtonPressed, buttonStyle, indicator}: Props){
return(
<View style={styles.containerButton}>
<TouchableOpacity onPress={handleButtonPressed} style={[styles.defaultButton,buttonStyle]}>
{indicator !== undefined && (
<View style={styles.indicator}>
<Text style={styles.indicatorText}>{indicator}</Text>
</View>
)}
<Image
style={[styles.answerImage]}
source={{uri: url}}
/>
</TouchableOpacity>
</View>
)
}
const styles = StyleSheet.create({
defaultButton: {
backgroundColor: "#45128C",
padding: 10,
alignItems: "center",
justifyContent: 'center',
borderRadius: 10,
},
indicator: {
position: "absolute",
top: "-16%",
left: "5%",
width: 25,
height: 25,
borderRadius: 15,
backgroundColor: "#D3D3D3",
justifyContent: "center",
alignItems: "center",
zIndex: 1,
},
indicatorText: {
color: "#000",
fontWeight: "bold",
fontSize: 14,
},
answerImage: {
width: '100%',
height: '100%',
},
containerButton: {
height: 150,
width: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}
})
\ No newline at end of file
......@@ -136,23 +136,14 @@ export default function PlayingQuizBody({ quizInformations, runId, actualQuestio
contentContainerStyle={styles.buttonListContentContainer}
>
{actualQuestion.answers.map((answer, index) => (
actualQuestion.type === "image" ?
<AnswerButtonImage
key={index}
url={answer.text}
handleButtonPressed={() => onAnsweredButtonClicked(answer.id)}
buttonStyle={getStyleOfAnswerButton(answer.id, selectedAnswerId, correctAnswerId, quizState)}
/>
:
<AnswerButton
key={index}
text={answer.text}
handleButtonPressed={() => onAnsweredButtonClicked(answer.id)}
buttonStyle={getStyleOfAnswerButton(answer.id, selectedAnswerId, correctAnswerId, quizState)}
buttonText={getStyleOfAnswerButtonText(answer.id, selectedAnswerId, correctAnswerId, quizState)}
/>
<AnswerButton
key={index}
text={answer.text}
handleButtonPressed={() => onAnsweredButtonClicked(answer.id)}
buttonStyle={getStyleOfAnswerButton(answer.id, selectedAnswerId, correctAnswerId, quizState)}
buttonText={getStyleOfAnswerButtonText(answer.id, selectedAnswerId, correctAnswerId, quizState)}
/>
))}
{/* </View> */}
</ScrollView>
<View style={styles.playButtonContainer}>
<BlueButton onPress={() => quizState === QuizState.ANSWERING ? onValidation() : onContinue()} text={quizState === QuizState.ANSWERING ? "CONFIRM" : "CONTINUE"} buttonStyle={{borderRadius: 50}} isDisabled={false}/>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment