From 1d2b8f92227257e18ebbf0587e98eb65cf9c22bf Mon Sep 17 00:00:00 2001 From: Dslak Date: Wed, 6 Nov 2019 10:18:14 +0100 Subject: [PATCH] add info box --- vds-app/App/components/Variables.js | 9 +- vds-app/App/index.js | 11 +++ vds-app/App/screens/Exam.js | 59 ++++++++++++- vds-app/App/screens/Info.js | 132 ++++++++++++++++++++++++++++ vds-app/App/screens/Results.js | 61 +++++++++---- vds-app/App/screens/Splash.js | 21 +++-- vds-app/app.json | 5 +- 7 files changed, 262 insertions(+), 36 deletions(-) create mode 100644 vds-app/App/screens/Info.js diff --git a/vds-app/App/components/Variables.js b/vds-app/App/components/Variables.js index 8af7d0a..62fc9f2 100644 --- a/vds-app/App/components/Variables.js +++ b/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 = [ diff --git a/vds-app/App/index.js b/vds-app/App/index.js index e87af68..81b7321 100644 --- a/vds-app/App/index.js +++ b/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 }) => ({ diff --git a/vds-app/App/screens/Exam.js b/vds-app/App/screens/Exam.js index f72efc8..c49043d 100644 --- a/vds-app/App/screens/Exam.js +++ b/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 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(){ diff --git a/vds-app/App/screens/Info.js b/vds-app/App/screens/Info.js new file mode 100644 index 0000000..06fc0f9 --- /dev/null +++ b/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 ( + + + + + + + + + {`${pkg.expo.name}`} + + + {`${texts.version}: ${pkg.expo.version}`} + + + {`${texts.author}: ${pkg.expo.author}`} + + + + {texts.description} + + +