After Width: | Height: | Size: 244 KiB |
After Width: | Height: | Size: 422 KiB |
After Width: | Height: | Size: 521 KiB |
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 19 KiB |
@ -0,0 +1,162 @@ |
|||
import React from "react" |
|||
import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, Image, ImageBackground, BackHandler} from "react-native" |
|||
|
|||
import { Button, ButtonContainer } from "../components/Button" |
|||
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 bgImage = require("../assets/bg.jpg") |
|||
|
|||
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, |
|||
flex: 1 |
|||
}, |
|||
safearea: { |
|||
flex: 1, |
|||
marginTop: 0, |
|||
justifyContent: "space-between", |
|||
paddingHorizontal: 20, |
|||
paddingBottom: 40 |
|||
}, |
|||
headerContainer: { |
|||
marginTop: -40, |
|||
alignItems: "center", |
|||
justifyContent: "center", |
|||
width: "100%", |
|||
height: screen.width/1.5 |
|||
}, |
|||
header: { |
|||
width: "100%" |
|||
}, |
|||
box: { |
|||
marginTop: 30, |
|||
borderColor: colors.black_alpha, |
|||
borderWidth: 1, |
|||
padding: 15, |
|||
borderRadius: 5, |
|||
backgroundColor: colors.black_alpha |
|||
}, |
|||
text: { |
|||
color: colors.white, |
|||
fontSize: 20, |
|||
textAlign: "center", |
|||
fontWeight: "600", |
|||
paddingVertical: 10 |
|||
}, |
|||
textBig: { |
|||
color: colors.white, |
|||
fontSize: 24, |
|||
textAlign: "center", |
|||
fontWeight: "500", |
|||
paddingBottom: 10, |
|||
textShadowColor: 'rgba(0, 0, 0, 0.75)', |
|||
textShadowOffset: {width: -1, height: 1}, |
|||
textShadowRadius: 10 |
|||
}, |
|||
bg: { |
|||
width: "100%", |
|||
height: "100%" |
|||
} |
|||
}) |
|||
|
|||
class Recap extends React.Component { |
|||
|
|||
componentDidMount() { |
|||
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) |
|||
} |
|||
|
|||
componentWillUnmount() { |
|||
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton) |
|||
} |
|||
|
|||
handleBackButton = () => { |
|||
|
|||
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() { |
|||
|
|||
const questions = this.props.navigation.getParam("wrongAnswers", []) |
|||
|
|||
return ( |
|||
<View style={styles.container} > |
|||
<View style={styles.headerContainer} > |
|||
<Image source={header} style={styles.header} resizeMode="contain" /> |
|||
</View> |
|||
|
|||
<Text style={styles.textBig}>{texts.recapTitle}</Text> |
|||
|
|||
<ScrollView> |
|||
<SafeAreaView style={styles.safearea}> |
|||
{questions.map( (question, index) => ( |
|||
<View style={styles.box} key={question.id}> |
|||
<Text style={styles.text}>{question.text}</Text> |
|||
|
|||
<ButtonContainer> |
|||
{question.answers.map( (answer, index) => ( |
|||
<Button |
|||
key={answer.id} |
|||
text={answer.text} |
|||
colorize={{id: answer.id, clicked: question.clicked, answered: true, isCorrect: answer.correct}} |
|||
/> |
|||
))} |
|||
</ButtonContainer> |
|||
</View> |
|||
))} |
|||
|
|||
<View style={styles.button}> |
|||
<Button |
|||
text={texts.restart} |
|||
onPress={() => {this.handleBackButton()} |
|||
} |
|||
/> |
|||
</View> |
|||
</SafeAreaView> |
|||
</ScrollView> |
|||
|
|||
</View> |
|||
|
|||
) |
|||
} |
|||
} |
|||
|
|||
export default Recap |