Browse Source

Merge branch 'feature/info' into develop

master
Dslak 6 years ago
parent
commit
d1736293e3
  1. 9
      vds-app/App/components/Variables.js
  2. 11
      vds-app/App/index.js
  3. 59
      vds-app/App/screens/Exam.js
  4. 132
      vds-app/App/screens/Info.js
  5. 61
      vds-app/App/screens/Results.js
  6. 21
      vds-app/App/screens/Splash.js
  7. 5
      vds-app/app.json

9
vds-app/App/components/Variables.js

@ -38,7 +38,14 @@ export const texts = {
meteorology: "Meteorologia e aerologia",
physiopathology: "Fisiopatologia del volo",
piloting_techniques: "Tecniche di pilotaggio",
restart: "Ricomincia"
restart: "Ricomincia",
infoTitle: "Informazioni",
version: "Versione",
author: "Autore",
description: "VDS Quiz è una applicazione che utilizza le 500 domande ufficiali dell'AeCI, nella simulazione le domande vengono estrapolate seguendo lo schema ufficiale d'esame.",
source: "Domande ufficiali",
pdfLinkText: "Fonte: AeCI \"500 Quiz\"",
pdfLink: "http://www.aeci.it/upload/files/quiz_VDS-VL_2017.pdf"
}
export const examScheme = [

11
vds-app/App/index.js

@ -6,6 +6,7 @@ import QuizIndex from "./screens/QuizIndex"
import Quiz from "./screens/Quiz"
import Exam from "./screens/Exam"
import Results from "./screens/Results"
import Info from "./screens/Info"
import { colors, texts} from "./components/Variables"
const MainStack = createStackNavigator({
@ -29,6 +30,16 @@ const MainStack = createStackNavigator({
}
})
},
Info: {
screen: Info,
navigationOptions: ({ navigation }) => ({
header: null,
backgroundColor: colors.yellow,
headerStyle: {
backgroundColor: colors.yellow
}
})
},
Banner: {
screen: Banner,
navigationOptions: ({ navigation }) => ({

59
vds-app/App/screens/Exam.js

@ -1,8 +1,31 @@
import React from "react"
import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, ImageBackground } from "react-native"
import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, ImageBackground, BackHandler } from "react-native"
import { Button, ButtonContainer } from "../components/Button"
import { colors, texts } from "../components/Variables"
import { colors, texts, examScheme } from "../components/Variables"
import aerodynamicsQuestions from "../data/aerodynamics"
import firstAidQuestions from "../data/firstAid"
import flightSafetyQuestions from "../data/flightSafety"
import instrumentsQuestions from "../data/instruments"
import legislationQuestions from "../data/legislation"
import materialsQuestions from "../data/materials"
import meteorologyQuestions from "../data/meteorology"
import physiopathologyQuestions from "../data/physiopathology"
import pilotingTechniquesQuestions from "../data/pilotingTechniques"
const allQuestions = {
aerodynamics: aerodynamicsQuestions,
firstAid: firstAidQuestions,
flightSafety: flightSafetyQuestions,
instruments: instrumentsQuestions,
legislation: legislationQuestions,
materials: materialsQuestions,
meteorology: meteorologyQuestions,
physiopathology: physiopathologyQuestions,
pilotingTechniques: pilotingTechniquesQuestions
}
const bgImage = require("../assets/bg.jpg")
@ -58,6 +81,36 @@ class Exam extends React.Component {
timer: maxTime
}
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton)
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton)
}
handleBackButton = () => {
console.log('Mount Exam component')
const tmpQuestions = []
examScheme.forEach( (elem) => {
let currentSection = allQuestions[elem.section]
for(let i=0; i<elem.questions; i++) {
const currentIndex = Math.floor(Math.random() * currentSection.length)
tmpQuestions.push(currentSection[currentIndex])
currentSection = currentSection.filter( (item, index) => index != currentIndex)
}
})
//tmpQuestions.forEach( (e) => { console.log(e.id) })
this.props.navigation.navigate("Splash", {
examQuestions: tmpQuestions
})
return true
}
answer = (correct, id, points) => {
this.setState(
state => {
@ -112,8 +165,6 @@ class Exam extends React.Component {
}
})
}
}
componentWillUnmount(){

132
vds-app/App/screens/Info.js

@ -0,0 +1,132 @@
import React from "react"
import { View, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, BackHandler, Linking} from "react-native"
import { Button, ButtonContainer } from "../components/Button"
import { colors, texts } from "../components/Variables"
const screen = Dimensions.get("window")
const header = require("../assets/header.png")
const pkg = require('../../app.json')
const currentInfo = {
correct: "aaa",
wrong: "aaa"
}
const styles = StyleSheet.create({
container: {
backgroundColor: colors.dark_blue,
flex: 1
},
safearea: {
flex: 1,
marginTop: 0,
justifyContent: "space-between",
paddingHorizontal: 20
},
headerContainer: {
marginTop: -40,
alignItems: "center",
justifyContent: "center",
width: "100%",
height: screen.width/1.5
},
header: {
width: "100%"
},
button: {
position: "absolute",
bottom: 40,
left: 40,
width: screen.width-80
},
box: {
width: screen.width-40,
},
text: {
color: colors.white,
fontSize: 22,
textAlign: "center",
fontWeight: "400",
lineHeight: 40,
textShadowColor: 'rgba(0, 0, 0, 0.75)',
textShadowOffset: {width: -1, height: 1},
textShadowRadius: 10
},
textSmall: {
fontSize: 18,
color: colors.white,
fontWeight: "400",
textAlign: "center",
paddingHorizontal: 20,
paddingVertical: 20,
textShadowColor: 'rgba(0, 0, 0, 0.75)',
textShadowOffset: {width: -1, height: 1},
textShadowRadius: 10
},
noPadding: {
paddingVertical: 0,
},
textLabel: {
paddingHorizontal: 20,
paddingVertical: 20
},
bold: {
fontSize: 26,
fontWeight: "600"
}
})
class Info extends React.Component {
state = {}
openURL = (url) => {
Linking.openURL(url).catch((err) => console.error('An error occurred', err))
}
render() {
return (
<View style={styles.container} >
<View style={styles.headerContainer} >
<Image source={header} style={styles.header} resizeMode="contain" />
</View>
<SafeAreaView style={styles.safearea}>
<View style={styles.box}>
<Text style={styles.text}>
<Text style={[styles.textLabel, styles.bold]}>{`${pkg.expo.name}`}</Text>
</Text>
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.version}: ${pkg.expo.version}`}</Text>
</Text>
<Text style={styles.text}>
<Text style={styles.textLabel}>{`${texts.author}: ${pkg.expo.author}`}</Text>
</Text>
<Text style={styles.textSmall}>
{texts.description}
</Text>
<Button
text={texts.source}
subtitle={texts.pdfLinkText}
isBig={false}
onPress={() => this.openURL(texts.pdfLink)}
/>
</View>
</SafeAreaView>
</View>
)
}
}
export default Info

61
vds-app/App/screens/Results.js

@ -2,13 +2,35 @@ import React from "react"
import { View, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, BackHandler} from "react-native"
import { Button, ButtonContainer } from "../components/Button"
import { colors, texts } from "../components/Variables"
import { colors, texts, examScheme } from "../components/Variables"
import aerodynamicsQuestions from "../data/aerodynamics"
import firstAidQuestions from "../data/firstAid"
import flightSafetyQuestions from "../data/flightSafety"
import instrumentsQuestions from "../data/instruments"
import legislationQuestions from "../data/legislation"
import materialsQuestions from "../data/materials"
import meteorologyQuestions from "../data/meteorology"
import physiopathologyQuestions from "../data/physiopathology"
import pilotingTechniquesQuestions from "../data/pilotingTechniques"
const screen = Dimensions.get("window")
const header = require("../assets/header.png")
const maxTime = 0 // 10
let interval = null
const allQuestions = {
aerodynamics: aerodynamicsQuestions,
firstAid: firstAidQuestions,
flightSafety: flightSafetyQuestions,
instruments: instrumentsQuestions,
legislation: legislationQuestions,
materials: materialsQuestions,
meteorology: meteorologyQuestions,
physiopathology: physiopathologyQuestions,
pilotingTechniques: pilotingTechniquesQuestions
}
const styles = StyleSheet.create({
container: {
backgroundColor: colors.dark_blue,
@ -107,8 +129,25 @@ class Results extends React.Component {
}
handleBackButton = () => {
this.props.navigation.navigate("Splash", {})
return true;
console.log('Mount Exam component')
const tmpQuestions = []
examScheme.forEach( (elem) => {
let currentSection = allQuestions[elem.section]
for(let i=0; i<elem.questions; i++) {
const currentIndex = Math.floor(Math.random() * currentSection.length)
tmpQuestions.push(currentSection[currentIndex])
currentSection = currentSection.filter( (item, index) => index != currentIndex)
}
})
//tmpQuestions.forEach( (e) => { console.log(e.id) })
this.props.navigation.navigate("Splash", {
examQuestions: tmpQuestions
})
return true
}
render() {
@ -125,15 +164,6 @@ class Results extends React.Component {
console.log(currentResults)
/*
setTimeout( () => {
this.props.navigation.navigate("Splash", {
title: texts.section_quizzes,
color: colors.blue
})
}, 5000)
*/
return (
<View style={styles.container} >
<View style={styles.headerContainer} >
@ -165,16 +195,11 @@ class Results extends React.Component {
<View style={styles.button}>
<Button
text={texts.restart}
onPress={() => {
this.props.navigation.navigate("Splash", {
title: texts.section_quizzes,
color: colors.blue
})}
onPress={() => {this.handleBackButton()}
}
/>
</View>
</SafeAreaView>
</View>

21
vds-app/App/screens/Splash.js

@ -1,5 +1,5 @@
import React from "react"
import { View, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image } from "react-native"
import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image } from "react-native"
import { AdMobBanner } from "expo-ads-admob"
import { Button, ButtonContainer } from "../components/Button"
@ -18,10 +18,6 @@ const styles = StyleSheet.create({
},
bannerContainer: {
backgroundColor: colors.dark_blue,
position: "absolute",
bottom: 0,
left: 0,
right: 0,
flex: 1,
alignItems: "center",
justifyContent: "center"
@ -91,8 +87,6 @@ class Splash extends React.Component {
//console.log("Banner error: ", e)
}
render() {
if(this.state.timer==maxTime) {
@ -117,7 +111,7 @@ class Splash extends React.Component {
}
return (
<View style={styles.container} >
<ScrollView style={styles.container} >
<View style={styles.headerContainer} >
<Image source={header} style={styles.header} resizeMode="contain" />
</View>
@ -134,7 +128,6 @@ class Splash extends React.Component {
color: colors.blue
})}
/>
<Button
text={texts.exam}
subtitle={`(${texts.exam_simulation})`}
@ -146,8 +139,14 @@ class Splash extends React.Component {
color: colors.blue
})}
/>
</ButtonContainer>
<Button
text={texts.infoTitle}
isBig={false}
onPress={() =>
this.props.navigation.navigate("Info", {})}
/>
</ButtonContainer>
</View>
</SafeAreaView>
@ -164,7 +163,7 @@ class Splash extends React.Component {
) : null
}
</View>
</View>
</ScrollView>
)
}
}

5
vds-app/app.json

@ -8,7 +8,8 @@
"ios",
"android"
],
"version": "1.4.1",
"version": "1.4.5",
"author": "Dslak",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
@ -26,7 +27,7 @@
"icon": "./assets/icon.png",
"package": "com.dslak.vdsquiz",
"permissions": [],
"versionCode": 5,
"versionCode": 6,
"config": {
"googleMobileAdsAppId": "ca-app-pub-4145771316565790~1876877627"
}

Loading…
Cancel
Save