Browse Source

Merge branch 'feature/save_errors' into develop

feature/upgrade_sdk build_3.1.1
Dslak 5 years ago
parent
commit
e59340702c
  1. BIN
      vds-app/App/assets/buttonBg.png
  2. 77
      vds-app/App/components/Button.js
  3. 1
      vds-app/App/components/Variables.js
  4. 17
      vds-app/App/screens/Exam.js
  5. 3
      vds-app/App/screens/Info.js
  6. 15
      vds-app/App/screens/Quiz.js
  7. 23
      vds-app/App/screens/QuizIndex.js
  8. 32
      vds-app/App/screens/Recap.js
  9. 18
      vds-app/App/screens/RecapTrueFalse.js
  10. 37
      vds-app/App/screens/Results.js
  11. 48
      vds-app/App/screens/Splash.js
  12. 14
      vds-app/App/screens/TrueFalse.js
  13. 2
      vds-app/app.json
  14. 1
      vds-app/package.json

BIN
vds-app/App/assets/buttonBg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

77
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 (
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}>
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : '', {fontWeight: "500"}]}>{text}</Text>
<Text style={[styles.subtitle, hasShadow ? styles.shadow : '']}>{subtitle}</Text>
</TouchableOpacity>
)
if(hasBg) {
if(subtitle) {
return (
<TouchableOpacity onPress={onPress} style={[styles.button, styles.noPadding, buttonColor, planeButton, noBorderButton, isHalf]}>
<ImageBackground source={bgImage} style={styles.buttonBg}>
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '', {fontWeight: "500"}]}>{text}</Text>
<Text style={[styles.subtitle, styles.buttonPadding, hasShadow ? styles.shadow : '']}>{subtitle}</Text>
</ImageBackground>
</TouchableOpacity>
)
} else {
return (
<TouchableOpacity onPress={onPress} style={[styles.button, styles.noPadding, buttonColor, planeButton, noBorderButton, isHalf]}>
<ImageBackground source={bgImage} style={styles.buttonBg}>
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text>
</ImageBackground>
</TouchableOpacity>
)
}
} else {
return (
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}>
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text>
</TouchableOpacity>
)
if(subtitle) {
return (
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}>
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '', {fontWeight: "500"}]}>{text}</Text>
<Text style={[styles.subtitle, styles.buttonPadding, hasShadow ? styles.shadow : '']}>{subtitle}</Text>
</TouchableOpacity>
)
} else {
return (
<TouchableOpacity onPress={onPress} style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}>
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text>
</TouchableOpacity>
)
}
}
} else {
if(subtitle) {
return (
<View style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}>
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : ''], {fontWeight: "500"}}>{text}</Text>
<Text style={[styles.subtitle, hasShadow ? styles.shadow : '']}>{subtitle}</Text>
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : ''], {fontWeight: "500"}}>{text}</Text>
<Text style={[styles.subtitle, styles.buttonPadding, hasShadow ? styles.shadow : '']}>{subtitle}</Text>
</View>
)
} else {
return (
<View style={[styles.button, buttonColor, planeButton, noBorderButton, isHalf]}>
<Text style={[styles.text, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text>
<Text style={[styles.text, styles.buttonPadding, buttonBig, hasShadow ? styles.shadow : '']}>{text}</Text>
</View>
)
}
@ -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 (
<View style={[styles.buttonContainer, boxedStyle]}>{children}</View>

1
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",

17
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 {
<SafeAreaView style={styles.safearea}>
<Text style={styles.timer}>{new Date(this.state.timer * 1000).toISOString().substr(11, 8)}</Text>
<View>
<Text style={styles.textCode}>{question.id}</Text>
<Text style={styles.text}>{question.question}</Text>
<ButtonContainer>

3
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)}
/>
<Text></Text>

15
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 ?
<SafeAreaView style={styles.safearea}>
<View>
<Text style={styles.textCode}>{question.id}</Text>
<Text style={styles.text}>{question.question}</Text>
<ButtonContainer>

23
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 {
<ImageBackground source={bgImage} style={styles.bg} resizeMode="cover">
<ScrollView >
<View style={{marginVertical: 60}}>
<RowItem name="TEST" textColor={colors.white} onPress={()=>
this.props.navigation.navigate("Quiz", {
title: "TEST",
questions: testQuestions,
color: colors.blue
})}/>
<RowItem name={texts.aerodynamics} subtitle={aerodynamicsQuestions.length} textColor={colors.white} onPress={()=>
this.props.navigation.navigate("Quiz", {
title: texts.aerodynamics,

32
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 {
<SafeAreaView style={styles.safearea}>
{questions.map( (question, index) => (
<View style={styles.box} key={question.id}>
<Text style={styles.text}>{question.text}</Text>
<Text style={styles.textCode}>{question.id}</Text>
<Text style={styles.text}>{question.question}</Text>
<ButtonContainer>
{question.answers.map( (answer, index) => (

18
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 {
<SafeAreaView style={styles.safearea}>
{questions.map( (question, index) => (
<View style={styles.box} key={question.id}>
<Text style={styles.text}>{question.text}</Text>
<Text style={styles.textCode}>{question.id}</Text>
<Text style={styles.text}>{question.question}</Text>
<ButtonContainer>
{question.answers.map( (answer, index) => {

37
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 (
<View style={styles.container} >
@ -182,9 +197,13 @@ class Results extends React.Component {
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.percentage}: ${Math.round(percentage)}%`}</Text>
</Text>
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`}</Text>
</Text>
{
currentResults.points ? (
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.points}: ${currentResults.points}/${currentResults.totalPoints}`}</Text>
</Text>
) : null
}
{currentResults.isExam ?
<Text style={[styles.textSmall, resultStyle]}>

48
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 ? (
<Button
text={texts.wrong_review}
subtitle={`(${storeWrongAnswers.length})`}
isBig={false}
hasBg={true}
noPadding={true}
hasShadow={true}
color={colors.white_alpha}
onPress={() =>
this.props.navigation.navigate("Quiz", {
title: texts.wrong_review,
questions: storeWrongAnswers,
isWrong: true,
color: colors.blue
})}
/>
) : null
}
<Button
text={texts.exam}
subtitle={`(${texts.exam_simulation})`}
isBig={false}
hasBg={true}
noPadding={true}
hasShadow={true}
color={colors.white_alpha}
@ -173,6 +213,7 @@ class Splash extends React.Component {
text={texts.trueFalse}
subtitle={`(${texts.trueFalseSubtitle})`}
isBig={false}
hasBg={true}
noPadding={true}
hasShadow={true}
color={colors.white_alpha}
@ -187,6 +228,7 @@ class Splash extends React.Component {
text={texts.dictionaryTitle}
subtitle={`(${texts.dictionarySubtitle})`}
isBig={false}
hasBg={true}
noPadding={true}
hasShadow={true}
color={colors.white_alpha}
@ -195,6 +237,7 @@ class Splash extends React.Component {
<Button
text={texts.infoTitle}
isBig={false}
hasBg={true}
noPadding={true}
hasShadow={true}
color={colors.white_alpha}
@ -203,6 +246,7 @@ class Splash extends React.Component {
<Button
text={texts.exit}
isBig={false}
hasBg={true}
noPadding={true}
hasShadow={true}
noBorder={true}

14
vds-app/App/screens/TrueFalse.js

@ -39,7 +39,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
},
textAnswer: {
color: colors.black,
@ -151,7 +160,7 @@ class Quiz extends React.Component {
nextState.wrongCount = state.wrongCount + 1
nextState.wrongAnswers = state.wrongAnswers
nextState.wrongAnswers.push(
{ text: question.question,
{ question: question.question,
id: question.id,
clicked: question.answers[state.activeAnswerId].id,
answers: question.answers
@ -215,6 +224,7 @@ class Quiz extends React.Component {
{!this.state.results ?
<SafeAreaView style={styles.safearea}>
<View>
<Text style={styles.textCode}>{question.id}</Text>
<Text style={styles.text}>{question.question}</Text>
<Text style={styles.textAnswer}>{randomAnswer.text}</Text>

2
vds-app/app.json

@ -8,7 +8,7 @@
"ios",
"android"
],
"version": "2.1.3",
"version": "3.1.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {

1
vds-app/package.json

@ -4,6 +4,7 @@
"start": "expo start",
"android": "expo start --android",
"build-android": "expo build:android -t app-bundle",
"build-ios": "expo build:ios",
"ios": "expo start --ios",
"eject": "expo eject",
"lint": "eslint ."

Loading…
Cancel
Save