From 259116ace0d6577ae6a6528799c2e08721a5cf43 Mon Sep 17 00:00:00 2001 From: Dslak Date: Fri, 1 Nov 2019 14:49:15 +0100 Subject: [PATCH 1/2] add button color on answer --- vds-app/App/components/Button.js | 17 ++++++++++++++--- vds-app/App/components/Variables.js | 2 ++ vds-app/App/screens/Banner.js | 2 +- vds-app/App/screens/Exam.js | 9 +++++---- vds-app/App/screens/Quiz.js | 16 +++++++--------- vds-app/App/screens/Splash.js | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/vds-app/App/components/Button.js b/vds-app/App/components/Button.js index 5fe22d6..b57f336 100644 --- a/vds-app/App/components/Button.js +++ b/vds-app/App/components/Button.js @@ -31,20 +31,31 @@ const styles = StyleSheet.create({ } }) -export const Button = ({ text, subtitle = null, isBig = false, onPress = () => {} }) => { +export const Button = ({ text, subtitle = null, isBig = false, colorize = false, onPress = () => {} }) => { const buttonBig = isBig ? {fontSize: 25} : {} + let buttonColor = {backgroundColor: colors.white_alpha} + if(colorize && colorize.answered) { + //console.log(colorize) + if(colorize.isCorrect) { + buttonColor = {backgroundColor: colors.green_light} + } else { + if(colorize.clicked == colorize.id) { + buttonColor = {backgroundColor: colors.red_light} + } + } + } if(subtitle) { return ( - + {text} {subtitle} ) } else { return ( - + {text} ) diff --git a/vds-app/App/components/Variables.js b/vds-app/App/components/Variables.js index d177f29..bfa8c5e 100644 --- a/vds-app/App/components/Variables.js +++ b/vds-app/App/components/Variables.js @@ -8,8 +8,10 @@ export const colors = { dark_blue: "#1279be", red: "#af321e", red_alpha: "rgba(175, 50, 30, 0.9)", + red_light: "#af442f", green: "#28A125", green_alpha: "rgba(40, 160, 40, 0.9)", + green_light: "#5bc135", yellow: "#e1ff3c", yellow_alpha: "rgba(225, 255, 60, 0.9)", orange: "#ff9b32" diff --git a/vds-app/App/screens/Banner.js b/vds-app/App/screens/Banner.js index 5b5c52d..c7432dd 100644 --- a/vds-app/App/screens/Banner.js +++ b/vds-app/App/screens/Banner.js @@ -38,7 +38,7 @@ class Banner extends React.Component { } bannerError = (e) => { - console.log("Banner error: ", e) + //console.log("Banner error: ", e) } render() { diff --git a/vds-app/App/screens/Exam.js b/vds-app/App/screens/Exam.js index 4aa7998..c177921 100644 --- a/vds-app/App/screens/Exam.js +++ b/vds-app/App/screens/Exam.js @@ -54,10 +54,10 @@ class Exam extends React.Component { timer: maxTime } - answer = correct => { + answer = (correct, id) => { this.setState( state => { - const nextState = { answered: true } + const nextState = { answered: true, clickedId: id } if (correct) { nextState.correctCount = state.correctCount + 1 @@ -71,7 +71,7 @@ class Exam extends React.Component { }, () => { if(this.state.timer > 1 || (this.state.correctCount+this.state.wrongCount) < this.state.totalCount) { - setTimeout(() => this.nextQuestion(), 750) + setTimeout(() => this.nextQuestion(), correct ? 750 : 2000) } } ) @@ -138,7 +138,8 @@ class Exam extends React.Component {