|  | @ -1,9 +1,9 @@ | 
		
	
		
			
				|  |  | import React from "react" |  |  | import React from "react" | 
		
	
		
			
				|  |  | import { View, ScrollView, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, ImageBackground, BackHandler, AsyncStorage } from "react-native" |  |  |  | 
		
	
		
			
				|  |  |  |  |  | import { View, ScrollView, Picker, StyleSheet, StatusBar, Text, SafeAreaView, Dimensions, ImageBackground, BackHandler, AsyncStorage } from "react-native" | 
		
	
		
			
				|  |  | import { AdMobBanner } from "expo-ads-admob" |  |  | import { AdMobBanner } from "expo-ads-admob" | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | import { Button, ButtonContainer } from "../components/Button" |  |  | import { Button, ButtonContainer } from "../components/Button" | 
		
	
		
			
				|  |  | import { colors, credentials } from "../components/Variables" |  |  |  | 
		
	
		
			
				|  |  |  |  |  | import { texts, colors, credentials } from "../components/Variables" | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | const bgImage = require("../assets/bg.jpg") |  |  | const bgImage = require("../assets/bg.jpg") | 
		
	
		
			
				|  |  | const screen = Dimensions.get("window") |  |  | const screen = Dimensions.get("window") | 
		
	
	
		
			
				|  | @ -47,6 +47,20 @@ const styles = StyleSheet.create({ | 
		
	
		
			
				|  |  |     width: "100%", |  |  |     width: "100%", | 
		
	
		
			
				|  |  |     height: "100%" |  |  |     height: "100%" | 
		
	
		
			
				|  |  |   }, |  |  |   }, | 
		
	
		
			
				|  |  |  |  |  |   dropdown: { | 
		
	
		
			
				|  |  |  |  |  |     color: colors.white, | 
		
	
		
			
				|  |  |  |  |  |     fontSize: 16, | 
		
	
		
			
				|  |  |  |  |  |     width: "100%", | 
		
	
		
			
				|  |  |  |  |  |     textAlign: "center", | 
		
	
		
			
				|  |  |  |  |  |     fontWeight: "600", | 
		
	
		
			
				|  |  |  |  |  |     backgroundColor: 'transparent', | 
		
	
		
			
				|  |  |  |  |  |   }, | 
		
	
		
			
				|  |  |  |  |  |   dropdownItem: { | 
		
	
		
			
				|  |  |  |  |  |     color: colors.white, | 
		
	
		
			
				|  |  |  |  |  |     fontSize: 20, | 
		
	
		
			
				|  |  |  |  |  |     textAlign: "center", | 
		
	
		
			
				|  |  |  |  |  |     fontWeight: "600" | 
		
	
		
			
				|  |  |  |  |  |   }, | 
		
	
		
			
				|  |  |   bannerContainer: { |  |  |   bannerContainer: { | 
		
	
		
			
				|  |  |     flex: 1, |  |  |     flex: 1, | 
		
	
		
			
				|  |  |     alignItems: "center", |  |  |     alignItems: "center", | 
		
	
	
		
			
				|  | @ -70,11 +84,12 @@ class Quiz extends React.Component { | 
		
	
		
			
				|  |  |     totalPoints: 0, |  |  |     totalPoints: 0, | 
		
	
		
			
				|  |  |     totalCount: this.props.navigation.getParam("questions", []).length, |  |  |     totalCount: this.props.navigation.getParam("questions", []).length, | 
		
	
		
			
				|  |  |     availableIds: this.props.navigation.getParam("questions", []).map(a => a.id), |  |  |     availableIds: this.props.navigation.getParam("questions", []).map(a => a.id), | 
		
	
		
			
				|  |  |  |  |  |     availableQuestions: this.props.navigation.getParam("questions", []), | 
		
	
		
			
				|  |  |     activeQuestionId: this.props.navigation.getParam("questions", [])[ |  |  |     activeQuestionId: this.props.navigation.getParam("questions", [])[ | 
		
	
		
			
				|  |  |                         this.props.navigation.getParam("randomQuestions") ? |  |  |                         this.props.navigation.getParam("randomQuestions") ? | 
		
	
		
			
				|  |  |                           Math.floor(Math.random() * this.props.navigation.getParam("questions", []).length) : 0 |  |  |                           Math.floor(Math.random() * this.props.navigation.getParam("questions", []).length) : 0 | 
		
	
		
			
				|  |  |                       ].id, |  |  |                       ].id, | 
		
	
		
			
				|  |  | 
 |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     minIndex: 0, | 
		
	
		
			
				|  |  |     answered: false, |  |  |     answered: false, | 
		
	
		
			
				|  |  |     answerCorrect: false, |  |  |     answerCorrect: false, | 
		
	
		
			
				|  |  |     results: false, |  |  |     results: false, | 
		
	
	
		
			
				|  | @ -139,7 +154,10 @@ class Quiz extends React.Component { | 
		
	
		
			
				|  |  |   nextQuestion = () => { |  |  |   nextQuestion = () => { | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     const updatedIndexes = this.state.availableIds.filter( item => item != this.state.activeQuestionId) |  |  |     const updatedIndexes = this.state.availableIds.filter( item => item != this.state.activeQuestionId) | 
		
	
		
			
				|  |  |     const nextId = this.props.navigation.getParam("randomQuestions") ? updatedIndexes[Math.floor(Math.random() * updatedIndexes.length)] : updatedIndexes[0] |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     const updatedQuestions = this.state.availableQuestions.filter( item => updatedIndexes.indexOf(item.id) > -1) | 
		
	
		
			
				|  |  |  |  |  |     const nextId = this.props.navigation.getParam("randomQuestions") ? | 
		
	
		
			
				|  |  |  |  |  |                     updatedIndexes[Math.floor(Math.random() * updatedIndexes.length)] : | 
		
	
		
			
				|  |  |  |  |  |                     updatedIndexes[this.state.minIndex] | 
		
	
		
			
				|  |  |     let resultsShow = (this.state.timer <= 1 || (this.state.correctCount+this.state.wrongCount) == this.state.totalCount) ? true : false |  |  |     let resultsShow = (this.state.timer <= 1 || (this.state.correctCount+this.state.wrongCount) == this.state.totalCount) ? true : false | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     if (!updatedIndexes.length) { |  |  |     if (!updatedIndexes.length) { | 
		
	
	
		
			
				|  | @ -157,9 +175,12 @@ class Quiz extends React.Component { | 
		
	
		
			
				|  |  |       }) |  |  |       }) | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     } else { |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |       this.setState( (state) => { |  |  |       this.setState( (state) => { | 
		
	
		
			
				|  |  |         return { |  |  |         return { | 
		
	
		
			
				|  |  |           availableIds: updatedIndexes, |  |  |           availableIds: updatedIndexes, | 
		
	
		
			
				|  |  |  |  |  |           availableQuestions: updatedQuestions, | 
		
	
		
			
				|  |  |  |  |  |           minIndex: this.state.minIndex >= updatedIndexes.length - 1 ? 0 : this.state.minIndex, | 
		
	
		
			
				|  |  |           activeQuestionId: nextId, |  |  |           activeQuestionId: nextId, | 
		
	
		
			
				|  |  |           answered: false, |  |  |           answered: false, | 
		
	
		
			
				|  |  |           results: resultsShow |  |  |           results: resultsShow | 
		
	
	
		
			
				|  | @ -168,6 +189,17 @@ class Quiz extends React.Component { | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |   jumpTo = (questionId, itemIndex) => { | 
		
	
		
			
				|  |  |  |  |  |     if(itemIndex) { | 
		
	
		
			
				|  |  |  |  |  |       this.setState( (state) => { | 
		
	
		
			
				|  |  |  |  |  |         return { | 
		
	
		
			
				|  |  |  |  |  |           activeQuestionId: questionId, | 
		
	
		
			
				|  |  |  |  |  |           minIndex: itemIndex-1 | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |       }) | 
		
	
		
			
				|  |  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |   render() { |  |  |   render() { | 
		
	
		
			
				|  |  |     const questions = this.props.navigation.getParam("questions", []) |  |  |     const questions = this.props.navigation.getParam("questions", []) | 
		
	
		
			
				|  |  |     const question = questions.filter(item => item.id == this.state.activeQuestionId)[0] || questions[0] |  |  |     const question = questions.filter(item => item.id == this.state.activeQuestionId)[0] || questions[0] | 
		
	
	
		
			
				|  | @ -198,10 +230,27 @@ class Quiz extends React.Component { | 
		
	
		
			
				|  |  |                 <Text style={styles.text}> |  |  |                 <Text style={styles.text}> | 
		
	
		
			
				|  |  |                   {`${this.state.correctCount+this.state.wrongCount}/${this.state.totalCount}`} |  |  |                   {`${this.state.correctCount+this.state.wrongCount}/${this.state.totalCount}`} | 
		
	
		
			
				|  |  |                 </Text> |  |  |                 </Text> | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |                 <Picker | 
		
	
		
			
				|  |  |  |  |  |                   label={texts.goToQuestion} | 
		
	
		
			
				|  |  |  |  |  |                   style={styles.dropdown} | 
		
	
		
			
				|  |  |  |  |  |                   itemStyle={styles.dropdownItem} | 
		
	
		
			
				|  |  |  |  |  |                   onValueChange={(itemValue, itemIndex) => this.jumpTo(itemValue, itemIndex)} | 
		
	
		
			
				|  |  |  |  |  |                 > | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |                   <Picker.Item key={`itemPlaceholder`} label={texts.goToQuestion} value={0} /> | 
		
	
		
			
				|  |  |  |  |  |                   {this.state.availableQuestions.map( (item, index) => ( | 
		
	
		
			
				|  |  |  |  |  |                     <Picker.Item key={`item${item.id}`} label={`${item.id} - ${item.question}`} value={item.id} /> | 
		
	
		
			
				|  |  |  |  |  |                   ))} | 
		
	
		
			
				|  |  |  |  |  |                 </Picker> | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |               </SafeAreaView> |  |  |               </SafeAreaView> | 
		
	
		
			
				|  |  |               : <SafeAreaView></SafeAreaView>} |  |  |               : <SafeAreaView></SafeAreaView>} | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |             </ScrollView> |  |  |             </ScrollView> | 
		
	
		
			
				|  |  |           </View> |  |  |           </View> | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |         </View> |  |  |         </View> | 
		
	
		
			
				|  |  |         <View style={styles.bannerContainer}> |  |  |         <View style={styles.bannerContainer}> | 
		
	
		
			
				|  |  |           <AdMobBanner |  |  |           <AdMobBanner | 
		
	
	
		
			
				|  | 
 |