diff --git a/vds-app/App/assets/buttonBg.png b/vds-app/App/assets/buttonBg.png new file mode 100644 index 0000000..b1709a8 Binary files /dev/null and b/vds-app/App/assets/buttonBg.png differ diff --git a/vds-app/App/components/Button.js b/vds-app/App/components/Button.js index 1d89d81..7a41ba2 100644 --- a/vds-app/App/components/Button.js +++ b/vds-app/App/components/Button.js @@ -1,20 +1,26 @@ import React from "react" -import { View, TouchableOpacity, Text, StyleSheet } from "react-native" +import { View, TouchableOpacity, Text, StyleSheet, ImageBackground } from "react-native" import { colors } from "../components/Variables" +const bgImage = require("../assets/buttonBg.png") + const styles = StyleSheet.create({ button: { backgroundColor: colors.white_alpha, borderWidth: 4, borderColor: 'transparent', borderRadius: 10, - paddingHorizontal: 20, + //paddingHorizontal: 20, paddingVertical: 15, alignItems: "center", justifyContent: "center", width: "100%", marginTop: 15 }, + noPadding: { + paddingHorizontal: 0, + paddingVertical: 0, + }, text: { color: colors.white, fontSize: 20, @@ -36,11 +42,21 @@ const styles = StyleSheet.create({ marginTop: 20, justifyContent: "space-between", overflow: "hidden", - borderRadius: 10 + borderRadius: 20 + }, + buttonBg: { + flex: 1, + paddingVertical: 15, + height: '100%', + width: '100%', + resizeMode: 'cover' + }, + buttonPadding: { + paddingHorizontal: 20 } }) -export const Button = ({ text, subtitle = null, isBig = false, colorize = false, color = false, noPadding = false, noBorder = false, halfSize = false, hasShadow = false, onPress = false }) => { +export const Button = ({ text, subtitle = null, isBig = false, colorize = false, color = false, noPadding = false, noBorder = false, halfSize = false, hasShadow = false, hasBg = false, onPress = false }) => { const buttonBig = isBig ? {fontSize: 25} : {} const isClicked = colorize.clicked == colorize.id @@ -65,32 +81,53 @@ export const Button = ({ text, subtitle = null, isBig = false, colorize = false, } if(onPress) { - if(subtitle) { - return ( - - {text} - {subtitle} - - ) + if(hasBg) { + if(subtitle) { + return ( + + + {text} + {subtitle} + + + ) + } else { + return ( + + + {text} + + + ) + } } else { - return ( - - {text} - - ) + if(subtitle) { + return ( + + {text} + {subtitle} + + ) + } else { + return ( + + {text} + + ) + } } } else { if(subtitle) { return ( - {text} - {subtitle} + {text} + {subtitle} ) } else { return ( - {text} + {text} ) } @@ -100,7 +137,7 @@ export const Button = ({ text, subtitle = null, isBig = false, colorize = false, export const ButtonContainer = ({ children, isBoxed = false}) => { - let boxedStyle = isBoxed ? {borderWidth: 3, borderColor: colors.white_alpha2} : {} + let boxedStyle = isBoxed ? {borderWidth: 2, borderColor: colors.white_alpha2} : {} return ( {children} diff --git a/vds-app/App/components/Variables.js b/vds-app/App/components/Variables.js index f581e12..b93e3f9 100644 --- a/vds-app/App/components/Variables.js +++ b/vds-app/App/components/Variables.js @@ -23,6 +23,7 @@ export const colors = { export const texts = { quizzes: "Seleziona un argomento", section_quizzes: "Quiz per argomento", + wrong_review: "Rivedi domande sbagliate", section_quizzes_subtitle: "Esercitati su argomenti specifici", exam: "Simulazione esame", exam_simulation: "30 domande in 30min", diff --git a/vds-app/App/screens/Exam.js b/vds-app/App/screens/Exam.js index 1a2d637..9b56ca5 100644 --- a/vds-app/App/screens/Exam.js +++ b/vds-app/App/screens/Exam.js @@ -37,7 +37,16 @@ const styles = StyleSheet.create({ fontSize: 20, textAlign: "center", fontWeight: "600", - paddingVertical: 20 + paddingTop: 5, + paddingBottom: 20 + }, + textCode: { + color: colors.white, + fontSize: 12, + textAlign: "center", + fontWeight: "500", + paddingTop: 20, + paddingBottom: 0 }, timer: { color: colors.white, @@ -106,8 +115,6 @@ class Exam extends React.Component { } }) - //tmpQuestions.forEach( (e) => { console.log(e.id) }) - this.props.navigation.navigate("Splash", { examQuestions: tmpQuestions }) @@ -142,13 +149,12 @@ class Exam extends React.Component { nextState.answerCorrect = false nextState.wrongAnswers = state.wrongAnswers nextState.wrongAnswers.push( - { text: question.question, + { question: question.question, id: question.id, clicked: id, answers: question.answers } ) - //console.log(state.wrongAnswers) } return nextState }, @@ -219,6 +225,7 @@ class Exam extends React.Component { {new Date(this.state.timer * 1000).toISOString().substr(11, 8)} + {question.id} {question.question} diff --git a/vds-app/App/screens/Info.js b/vds-app/App/screens/Info.js index 5f8b9c8..9e9fa29 100644 --- a/vds-app/App/screens/Info.js +++ b/vds-app/App/screens/Info.js @@ -65,7 +65,7 @@ const styles = StyleSheet.create({ textSmall: { lineHeight: 23, marginTop: 15, - borderRadius: 10, + borderRadius: 20, backgroundColor: colors.white_alpha, borderWidth: 0, borderColor: colors.white_alpha, @@ -196,6 +196,7 @@ class Info extends React.Component { text={texts.source} subtitle={texts.pdfLinkText} isBig={false} + hasBg={true} onPress={() => this.openURL(texts.pdfLink)} /> diff --git a/vds-app/App/screens/Quiz.js b/vds-app/App/screens/Quiz.js index 6ba17cc..b56e89c 100644 --- a/vds-app/App/screens/Quiz.js +++ b/vds-app/App/screens/Quiz.js @@ -17,7 +17,16 @@ const styles = StyleSheet.create({ fontSize: 20, textAlign: "center", fontWeight: "600", - paddingVertical: 20 + paddingTop: 5, + paddingBottom: 20 + }, + textCode: { + color: colors.white, + fontSize: 12, + textAlign: "center", + fontWeight: "500", + paddingTop: 20, + paddingBottom: 0 }, safearea: { flex: 1, @@ -100,7 +109,7 @@ class Quiz extends React.Component { nextState.answerCorrect = false, nextState.wrongAnswers = state.wrongAnswers nextState.wrongAnswers.push( - { text: question.question, + { question: question.question, id: question.id, clicked: id, answers: question.answers @@ -126,6 +135,7 @@ class Quiz extends React.Component { this.props.navigation.navigate("Results", { results: { isExam: false, + isWrong: this.props.navigation.getParam("isWrong"), total: this.state.totalCount, correct: this.state.correctCount, wrong: this.state.wrongCount, @@ -159,6 +169,7 @@ class Quiz extends React.Component { {!this.state.results ? + {question.id} {question.question} diff --git a/vds-app/App/screens/QuizIndex.js b/vds-app/App/screens/QuizIndex.js index 0ad600c..55c9a76 100644 --- a/vds-app/App/screens/QuizIndex.js +++ b/vds-app/App/screens/QuizIndex.js @@ -1,5 +1,5 @@ import React from "react" -import { View, ScrollView, StatusBar, BackHandler, StyleSheet, Dimensions, ImageBackground } from "react-native" +import { View, ScrollView, StatusBar, BackHandler, StyleSheet, Dimensions, ImageBackground, AsyncStorage } from "react-native" import aerodynamicsQuestions from "../data/aerodynamics" import firstAidQuestions from "../data/firstAid" @@ -39,8 +39,20 @@ const styles = StyleSheet.create({ class QuizIndex extends React.Component { + state = { + storeWrongAnswers: [] + } + componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) + AsyncStorage.getItem('storeWrongAnswers').then((value) => { + //console.log('storeWrongAnswers: ', JSON.parse(value)) + this.setState( (state) => { + return { + storeWrongAnswers: JSON.parse(value) + } + }) + }).done() } componentWillUnmount() { @@ -57,6 +69,15 @@ class QuizIndex extends React.Component { + + + + this.props.navigation.navigate("Quiz", { + title: "TEST", + questions: testQuestions, + color: colors.blue + })}/> + this.props.navigation.navigate("Quiz", { title: texts.aerodynamics, diff --git a/vds-app/App/screens/Recap.js b/vds-app/App/screens/Recap.js index 82019b9..64dd9ef 100644 --- a/vds-app/App/screens/Recap.js +++ b/vds-app/App/screens/Recap.js @@ -1,5 +1,5 @@ import React from "react" -import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, ImageBackground, BackHandler} from "react-native" +import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, ImageBackground, BackHandler, AsyncStorage} from "react-native" import { AdMobBanner } from "expo-ads-admob" import { Button, ButtonContainer } from "../components/Button" @@ -66,7 +66,15 @@ const styles = StyleSheet.create({ fontSize: 20, textAlign: "center", fontWeight: "600", - paddingTop: 10 + paddingTop: 0 + }, + textCode: { + color: colors.white, + fontSize: 12, + textAlign: "center", + fontWeight: "500", + paddingTop: 10, + paddingBottom: 0 }, textBig: { color: colors.white, @@ -97,8 +105,20 @@ const styles = StyleSheet.create({ class Recap extends React.Component { + state = { + storeWrongAnswers: [] + } + componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) + AsyncStorage.getItem('storeWrongAnswers').then((value) => { + //console.log('storeWrongAnswers: ', JSON.parse(value)) + this.setState( (state) => { + return { + storeWrongAnswers: JSON.parse(value) + } + }) + }).done() } componentWillUnmount() { @@ -117,10 +137,9 @@ class Recap extends React.Component { } }) - //tmpQuestions.forEach( (e) => { console.log(e.id) }) - this.props.navigation.navigate("Splash", { - examQuestions: tmpQuestions + examQuestions: tmpQuestions, + storeWrongAnswers: this.state.storeWrongAnswers }) return true } @@ -141,7 +160,8 @@ class Recap extends React.Component { {questions.map( (question, index) => ( - {question.text} + {question.id} + {question.question} {question.answers.map( (answer, index) => ( diff --git a/vds-app/App/screens/RecapTrueFalse.js b/vds-app/App/screens/RecapTrueFalse.js index 9fbd61b..5b7b720 100644 --- a/vds-app/App/screens/RecapTrueFalse.js +++ b/vds-app/App/screens/RecapTrueFalse.js @@ -1,5 +1,5 @@ import React from "react" -import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, ImageBackground, BackHandler} from "react-native" +import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, ImageBackground, BackHandler, AsyncStorage} from "react-native" import { AdMobBanner } from "expo-ads-admob" import { Button, ButtonContainer } from "../components/Button" @@ -66,7 +66,15 @@ const styles = StyleSheet.create({ fontSize: 20, textAlign: "center", fontWeight: "600", - paddingTop: 10 + paddingTop: 0 + }, + textCode: { + color: colors.white, + fontSize: 12, + textAlign: "center", + fontWeight: "500", + paddingTop: 10, + paddingBottom: 0 }, textBig: { color: colors.white, @@ -99,6 +107,9 @@ class RecapTrueFalse extends React.Component { componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) + AsyncStorage.getItem('storeWrongAnswers').then((value) => { + console.log(value) + }).done() } componentWillUnmount() { @@ -145,7 +156,8 @@ class RecapTrueFalse extends React.Component { {questions.map( (question, index) => ( - {question.text} + {question.id} + {question.question} {question.answers.map( (answer, index) => { diff --git a/vds-app/App/screens/Results.js b/vds-app/App/screens/Results.js index 2a47526..51f9f23 100644 --- a/vds-app/App/screens/Results.js +++ b/vds-app/App/screens/Results.js @@ -1,5 +1,5 @@ import React from "react" -import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, BackHandler} from "react-native" +import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, BackHandler, AsyncStorage} from "react-native" import { Button, ButtonContainer } from "../components/Button" import { colors, texts, examScheme } from "../components/Variables" @@ -119,11 +119,27 @@ class Results extends React.Component { state = { bannerExpanded: true, - timer: maxTime + timer: maxTime, + storeWrongAnswers: [] } componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) + + AsyncStorage.getItem('storeWrongAnswers').then( (value) => { + const currentResults = this.props.navigation.getParam("results") + const wrongAnswers = currentResults.wrongAnswers || [] + const stored = JSON.parse(value) || [] + const result = currentResults.isWrong ? wrongAnswers : Object.assign([], wrongAnswers, stored); + AsyncStorage.setItem('storeWrongAnswers', JSON.stringify(result)) + + this.setState( (state) => { + return { + storeWrongAnswers: result + } + }) + + }).done() } componentWillUnmount() { @@ -142,14 +158,14 @@ class Results extends React.Component { } }) - //tmpQuestions.forEach( (e) => { console.log(e.id) }) - this.props.navigation.navigate("Splash", { - examQuestions: tmpQuestions + examQuestions: tmpQuestions, + storeWrongAnswers: this.state.storeWrongAnswers }) return true } + render() { const currentResults = this.props.navigation.getParam("results") @@ -163,7 +179,6 @@ class Results extends React.Component { boxStyle = percentage >= 80 ? percentage >= 85 ? styles.boxCorrect : styles.boxUnsafe : styles.boxWrong } - //console.log(currentResults) return ( @@ -182,9 +197,13 @@ class Results extends React.Component { {`${texts.percentage}: ${Math.round(percentage)}%`} - - {`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`} - + { + currentResults.points ? ( + + {`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`} + + ) : null + } {currentResults.isExam ? diff --git a/vds-app/App/screens/Splash.js b/vds-app/App/screens/Splash.js index 836c2d4..c4187dd 100644 --- a/vds-app/App/screens/Splash.js +++ b/vds-app/App/screens/Splash.js @@ -1,5 +1,5 @@ import React from "react" -import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, Alert, BackHandler } from "react-native" +import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, Alert, BackHandler, AsyncStorage } from "react-native" import { AdMobBanner } from "expo-ads-admob" import { Button, ButtonContainer } from "../components/Button" @@ -81,7 +81,8 @@ class Splash extends React.Component { state = { bannerExpanded: true, - timer: maxTime + timer: maxTime, + storeWrongAnswers: this.props.navigation.getParam("storeWrongAnswers", []) || [] } bannerError = (e) => { @@ -90,6 +91,17 @@ class Splash extends React.Component { componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) + AsyncStorage.getItem('storeWrongAnswers').then( (value) => { + if(!value) { + AsyncStorage.setItem('storeWrongAnswers', JSON.stringify([])) + } + + this.setState( (state) => { + return { + storeWrongAnswers: value ? JSON.parse(value) : [] + } + }) + }).done() } componentWillUnmount() { @@ -111,6 +123,10 @@ class Splash extends React.Component { render() { + const storeWrongAnswers = this.props.navigation.getParam("storeWrongAnswers") || this.state.storeWrongAnswers + + //console.log(storeWrongAnswers.length) + if(this.state.timer==maxTime) { interval = setInterval( () => { this.setState( (state) => { @@ -145,6 +161,7 @@ class Splash extends React.Component { text={texts.section_quizzes} subtitle={`(${texts.section_quizzes_subtitle})`} isBig={false} + hasBg={true} noPadding={true} hasShadow={true} color={colors.white_alpha} @@ -154,10 +171,33 @@ class Splash extends React.Component { color: colors.white_alpha })} /> + + { + storeWrongAnswers.length ? ( +