import React from "react" import { View, ScrollView, StatusBar, BackHandler, StyleSheet, Dimensions, ImageBackground, AsyncStorage } from "react-native" 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" import testQuestions from "../data/test" import { Button, ButtonContainer } from "../components/Button" import { RowItem } from "../components/RowItem" import { colors, texts} from "../components/Variables" const bgImage = require("../assets/bg.jpg") const screen = Dimensions.get("window") const styles = StyleSheet.create({ bg: { flex: 1, width: "100%", height: "100%" }, }) /* this.props.navigation.navigate("Quiz", { title: "TEST", questions: testQuestions, color: colors.blue })}/> */ class QuizIndex extends React.Component { state = { storeWrongAnswers: [], randomQuestions: false, excludeDelta: false } componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) AsyncStorage.getItem('storeWrongAnswers').then((value) => { this.setState( (state) => { return { storeWrongAnswers: JSON.parse(value) } }) }).done() AsyncStorage.getItem('setupData').then((value) => { this.setState( (state) => { return { randomQuestions: JSON.parse(value).randomQuestions, excludeDelta: JSON.parse(value).excludeDelta } }) }).done() } componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton) } handleBackButton = () => { this.props.navigation.navigate("Splash") return true } render() { return ( !item.delta).length : aerodynamicsQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.aerodynamics, questions: aerodynamicsQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : firstAidQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.first_aid, questions: firstAidQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : flightSafetyQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.flight_safety, questions: flightSafetyQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : instrumentsQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.instruments, questions: instrumentsQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : legislationQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.legislation, questions: legislationQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : materialsQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.materials, questions: materialsQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : meteorologyQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.meteorology, questions: meteorologyQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : physiopathologyQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.physiopathology, questions: physiopathologyQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> !item.delta).length : pilotingTechniquesQuestions.length} textColor={colors.white} onPress={()=> this.props.navigation.navigate("Quiz", { title: texts.piloting_techniques, questions: pilotingTechniquesQuestions.filter(item => !item.delta), randomQuestions: this.state.randomQuestions, color: colors.blue }) }/> ) } } export default QuizIndex