From e7200a532f90a8b5307065274d4c0ec9c4242235 Mon Sep 17 00:00:00 2001 From: Dslak Date: Sat, 13 Sep 2025 01:29:39 +0200 Subject: [PATCH] WIP update --- node_modules/.yarn-integrity | 10 + vds-app/App/components/Banner.js | 6 +- vds-app/App/index.js | 131 ++---- vds-app/App/screens/Exam.js | 348 ++++++-------- vds-app/App/screens/Quiz.js | 321 ++++++------- vds-app/App/screens/Recap.js | 202 +++----- vds-app/App/screens/Results.js | 280 +++-------- vds-app/App/screens/ResultsTrueFalse.js | 248 +++------- vds-app/App/screens/Splash.js | 320 ++++++------- vds-app/App/screens/TrueFalse.js | 216 ++++----- vds-app/android/.gitignore | 16 + vds-app/android/app/build.gradle | 182 ++++++++ vds-app/android/app/debug.keystore | Bin 0 -> 2257 bytes vds-app/android/app/proguard-rules.pro | 14 + .../android/app/src/debug/AndroidManifest.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 32 ++ .../java/com/dslak/vdsquiz/MainActivity.kt | 61 +++ .../java/com/dslak/vdsquiz/MainApplication.kt | 56 +++ .../res/drawable-hdpi/splashscreen_logo.png | Bin 0 -> 18925 bytes .../res/drawable-mdpi/splashscreen_logo.png | Bin 0 -> 11193 bytes .../res/drawable-xhdpi/splashscreen_logo.png | Bin 0 -> 27283 bytes .../res/drawable-xxhdpi/splashscreen_logo.png | Bin 0 -> 44926 bytes .../drawable-xxxhdpi/splashscreen_logo.png | Bin 0 -> 62830 bytes .../res/drawable/ic_launcher_background.xml | 6 + .../res/drawable/rn_edit_text_material.xml | 37 ++ .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 7115 bytes .../mipmap-hdpi/ic_launcher_foreground.webp | Bin 0 -> 20190 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 4004 bytes .../mipmap-mdpi/ic_launcher_foreground.webp | Bin 0 -> 12167 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 10144 bytes .../mipmap-xhdpi/ic_launcher_foreground.webp | Bin 0 -> 28726 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 17792 bytes .../mipmap-xxhdpi/ic_launcher_foreground.webp | Bin 0 -> 46960 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 24610 bytes .../ic_launcher_foreground.webp | Bin 0 -> 69649 bytes .../app/src/main/res/values-night/colors.xml | 1 + .../app/src/main/res/values/colors.xml | 6 + .../app/src/main/res/values/strings.xml | 5 + .../app/src/main/res/values/styles.xml | 11 + vds-app/android/build.gradle | 24 + vds-app/android/gradle.properties | 69 +++ .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43764 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + vds-app/android/gradlew | 251 ++++++++++ vds-app/android/gradlew.bat | 94 ++++ vds-app/android/settings.gradle | 39 ++ vds-app/app.json | 13 +- vds-app/ios/.gitignore | 30 ++ vds-app/ios/.xcode.env | 11 + vds-app/ios/Podfile | 52 +++ vds-app/ios/Podfile.properties.json | 6 + vds-app/ios/VDSQuiz.xcodeproj/project.pbxproj | 436 ++++++++++++++++++ .../xcshareddata/xcschemes/VDSQuiz.xcscheme | 88 ++++ vds-app/ios/VDSQuiz/AppDelegate.swift | 70 +++ .../App-Icon-1024x1024@1x.png | Bin 0 -> 147594 bytes .../AppIcon.appiconset/Contents.json | 14 + .../ios/VDSQuiz/Images.xcassets/Contents.json | 6 + .../Contents.json | 20 + .../SplashScreenLegacy.imageset/Contents.json | 23 + .../SplashScreenLegacy.imageset/image.png | Bin 0 -> 236374 bytes .../SplashScreenLegacy.imageset/image@2x.png | Bin 0 -> 236374 bytes .../SplashScreenLegacy.imageset/image@3x.png | Bin 0 -> 236374 bytes vds-app/ios/VDSQuiz/Info.plist | 80 ++++ vds-app/ios/VDSQuiz/SplashScreen.storyboard | 48 ++ vds-app/ios/VDSQuiz/Supporting/Expo.plist | 14 + vds-app/ios/VDSQuiz/VDSQuiz-Bridging-Header.h | 3 + vds-app/ios/VDSQuiz/VDSQuiz.entitlements | 5 + vds-app/package.json | 55 ++- yarn.lock | 18 - 69 files changed, 2606 insertions(+), 1386 deletions(-) create mode 100644 node_modules/.yarn-integrity create mode 100644 vds-app/android/.gitignore create mode 100644 vds-app/android/app/build.gradle create mode 100644 vds-app/android/app/debug.keystore create mode 100644 vds-app/android/app/proguard-rules.pro create mode 100644 vds-app/android/app/src/debug/AndroidManifest.xml create mode 100644 vds-app/android/app/src/main/AndroidManifest.xml create mode 100644 vds-app/android/app/src/main/java/com/dslak/vdsquiz/MainActivity.kt create mode 100644 vds-app/android/app/src/main/java/com/dslak/vdsquiz/MainApplication.kt create mode 100644 vds-app/android/app/src/main/res/drawable-hdpi/splashscreen_logo.png create mode 100644 vds-app/android/app/src/main/res/drawable-mdpi/splashscreen_logo.png create mode 100644 vds-app/android/app/src/main/res/drawable-xhdpi/splashscreen_logo.png create mode 100644 vds-app/android/app/src/main/res/drawable-xxhdpi/splashscreen_logo.png create mode 100644 vds-app/android/app/src/main/res/drawable-xxxhdpi/splashscreen_logo.png create mode 100644 vds-app/android/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 vds-app/android/app/src/main/res/drawable/rn_edit_text_material.xml create mode 100644 vds-app/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 vds-app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp create mode 100644 vds-app/android/app/src/main/res/values-night/colors.xml create mode 100644 vds-app/android/app/src/main/res/values/colors.xml create mode 100644 vds-app/android/app/src/main/res/values/strings.xml create mode 100644 vds-app/android/app/src/main/res/values/styles.xml create mode 100644 vds-app/android/build.gradle create mode 100644 vds-app/android/gradle.properties create mode 100644 vds-app/android/gradle/wrapper/gradle-wrapper.jar create mode 100644 vds-app/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 vds-app/android/gradlew create mode 100644 vds-app/android/gradlew.bat create mode 100644 vds-app/android/settings.gradle create mode 100644 vds-app/ios/.gitignore create mode 100644 vds-app/ios/.xcode.env create mode 100644 vds-app/ios/Podfile create mode 100644 vds-app/ios/Podfile.properties.json create mode 100644 vds-app/ios/VDSQuiz.xcodeproj/project.pbxproj create mode 100644 vds-app/ios/VDSQuiz.xcodeproj/xcshareddata/xcschemes/VDSQuiz.xcscheme create mode 100644 vds-app/ios/VDSQuiz/AppDelegate.swift create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/Contents.json create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/SplashScreenBackground.colorset/Contents.json create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/SplashScreenLegacy.imageset/Contents.json create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/SplashScreenLegacy.imageset/image.png create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/SplashScreenLegacy.imageset/image@2x.png create mode 100644 vds-app/ios/VDSQuiz/Images.xcassets/SplashScreenLegacy.imageset/image@3x.png create mode 100644 vds-app/ios/VDSQuiz/Info.plist create mode 100644 vds-app/ios/VDSQuiz/SplashScreen.storyboard create mode 100644 vds-app/ios/VDSQuiz/Supporting/Expo.plist create mode 100644 vds-app/ios/VDSQuiz/VDSQuiz-Bridging-Header.h create mode 100644 vds-app/ios/VDSQuiz/VDSQuiz.entitlements diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity new file mode 100644 index 0000000..fe703d0 --- /dev/null +++ b/node_modules/.yarn-integrity @@ -0,0 +1,10 @@ +{ + "systemParams": "linux-x64-137", + "modulesFolders": [], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/vds-app/App/components/Banner.js b/vds-app/App/components/Banner.js index 4afb78a..993b636 100644 --- a/vds-app/App/components/Banner.js +++ b/vds-app/App/components/Banner.js @@ -2,8 +2,8 @@ import React from "react" import { View, StyleSheet, StatusBar, Text, Dimensions } from "react-native" import { colors, texts, credentials } from "./Variables" -import { BannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads' -const adUnitId = __DEV__ ? TestIds.INTERSTITIAL : 'ca-app-pub-4145771316565790/1848957462' +// import { BannerAd, BannerAdSize, TestIds } from 'react-native-google-mobile-ads' +// const adUnitId = __DEV__ ? TestIds.INTERSTITIAL : 'ca-app-pub-4145771316565790/1848957462' const screen = Dimensions.get("window") @@ -26,7 +26,7 @@ export const Banner = () => { if(__DEV__) { banner = DEV BANNER } else { - banner = + banner = BANNER // } return ( diff --git a/vds-app/App/index.js b/vds-app/App/index.js index 617da30..9774627 100644 --- a/vds-app/App/index.js +++ b/vds-app/App/index.js @@ -1,94 +1,43 @@ -import 'react-native-gesture-handler' -import { createAppContainer } from "react-navigation" -import { createStackNavigator } from "react-navigation-stack" +import 'react-native-gesture-handler'; +import * as React from 'react'; +import { NavigationContainer } from '@react-navigation/native'; +import { createNativeStackNavigator } from '@react-navigation/native-stack'; -import Splash from "./screens/Splash" -import QuizIndex from "./screens/QuizIndex" -import Quiz from "./screens/Quiz" -import TrueFalse from "./screens/TrueFalse" -import Exam from "./screens/Exam" -import Results from "./screens/Results" -import ResultsTrueFalse from "./screens/ResultsTrueFalse" -import Recap from "./screens/Recap" -import RecapTrueFalse from "./screens/RecapTrueFalse" -import Info from "./screens/Info" -import Setup from "./screens/Setup" -import Dictionary from "./screens/Dictionary" -import { colors, texts} from "./components/Variables" +import Splash from "./screens/Splash"; +import QuizIndex from "./screens/QuizIndex"; +import Quiz from "./screens/Quiz"; +import TrueFalse from "./screens/TrueFalse"; +import Exam from "./screens/Exam"; +import Results from "./screens/Results"; +import ResultsTrueFalse from "./screens/ResultsTrueFalse"; +import Recap from "./screens/Recap"; +import RecapTrueFalse from "./screens/RecapTrueFalse"; +import Info from "./screens/Info"; +import Setup from "./screens/Setup"; +import Dictionary from "./screens/Dictionary"; -const MainStack = createStackNavigator({ - Splash: { - screen: Splash, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - RecapTrueFalse: { - screen: RecapTrueFalse, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Recap: { - screen: Recap, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Results: { - screen: Results, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - ResultsTrueFalse: { - screen: ResultsTrueFalse, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Info: { - screen: Info, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Dictionary: { - screen: Dictionary, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - QuizIndex: { - screen: QuizIndex, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Quiz: { - screen: Quiz, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - TrueFalse: { - screen: TrueFalse, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Exam: { - screen: Exam, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - }, - Setup: { - screen: Setup, - navigationOptions: ({ navigation }) => ({ - headerShown: false - }) - } -}) +const Stack = createNativeStackNavigator(); -export default createAppContainer(MainStack) +export default function App() { + return ( + + + + + + + + + + + + + + + + + ); +} diff --git a/vds-app/App/screens/Exam.js b/vds-app/App/screens/Exam.js index 27e5a01..ee4ce36 100644 --- a/vds-app/App/screens/Exam.js +++ b/vds-app/App/screens/Exam.js @@ -1,20 +1,20 @@ -import React from "react" -import { View, ScrollView, StyleSheet, StatusBar, Text, ImageBackground, BackHandler } from "react-native" -import SafeAreaView from 'react-native-safe-area-view' -import AsyncStorage from '@react-native-async-storage/async-storage' - -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" +import React from "react"; +import { View, ScrollView, StyleSheet, StatusBar, Text, ImageBackground, BackHandler } from "react-native"; +import SafeAreaView from 'react-native-safe-area-view'; +import AsyncStorage from '@react-native-async-storage/async-storage'; + +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 allQuestions = { aerodynamics: aerodynamicsQuestions, @@ -26,107 +26,93 @@ const allQuestions = { meteorology: meteorologyQuestions, physiopathology: physiopathologyQuestions, pilotingTechniques: pilotingTechniquesQuestions -} +}; -const bgImage = require("../assets/bg.jpg") +const bgImage = require("../assets/bg.jpg"); const styles = StyleSheet.create({ - container: { - flex: 1 - }, - text: { - color: colors.white, - fontSize: 20, - textAlign: "center", - fontWeight: "600", - paddingTop: 5, - paddingBottom: 20 - }, - textCode: { - color: colors.white, - fontSize: 12, - textAlign: "center", - fontWeight: "500", - paddingTop: 20, - paddingBottom: 0 - }, - timer: { - color: colors.white, - fontSize: 30, - textAlign: "center", - fontWeight: "600", - paddingVertical: 10, - marginTop: 30, - backgroundColor: colors.white_alpha, - borderRadius: 10, - textShadowColor: 'rgba(0, 0, 0, 0.45)', - textShadowOffset: {width: -1, height: 1}, - textShadowRadius: 2 - }, - safearea: { - flex: 1, - marginTop: 20, - paddingHorizontal: 20, - justifyContent: "space-between" - }, - bg: { - width: "100%", - height: "100%" - }, -}) - -let interval = null -const maxTime = 1800 + container: { flex: 1 }, + text: { color: colors.white, fontSize: 20, textAlign: "center", fontWeight: "600", paddingTop: 5, paddingBottom: 20 }, + textCode: { color: colors.white, fontSize: 12, textAlign: "center", fontWeight: "500", paddingTop: 20, paddingBottom: 0 }, + timer: { color: colors.white, fontSize: 30, textAlign: "center", fontWeight: "600", paddingVertical: 10, marginTop: 30, backgroundColor: colors.white_alpha, borderRadius: 10, textShadowColor: 'rgba(0, 0, 0, 0.45)', textShadowOffset: { width: -1, height: 1 }, textShadowRadius: 2 }, + safearea: { flex: 1, marginTop: 20, paddingHorizontal: 20, justifyContent: "space-between" }, + bg: { width: "100%", height: "100%" } +}); -class Exam extends React.Component { +const MAX_TIME = 1800; // 30 minutes - state = { - correctCount: 0, - pointsCount: 0, - totalPoints: 0, - wrongCount: 0, - wrongAnswers: [], - totalCount: this.props.navigation.getParam("questions", []).length, - availableIds: this.props.navigation.getParam("questions", []).map(a => a.id), - activeQuestionId: this.props.navigation.getParam("questions", [])[ - Math.floor(Math.random() * this.props.navigation.getParam("questions", []).length) - ].id, - answered: false, - answerCorrect: false, - results: false, - timer: maxTime +class Exam extends React.Component { + constructor(props) { + super(props); + const { questions = [] } = props.route.params || {}; + + this.state = { + correctCount: 0, + wrongCount: 0, + pointsCount: 0, + totalPoints: 0, + wrongAnswers: [], + totalCount: questions.length, + availableIds: questions.map(q => q.id), + activeQuestionId: questions.length ? questions[Math.floor(Math.random() * questions.length)].id : null, + answered: false, + answerCorrect: false, + results: false, + timer: MAX_TIME, + clickedId: null + }; + + this.interval = null; } componentDidMount() { - BackHandler.addEventListener('hardwareBackPress', this.handleBackButton) + // BackHandler subscription + this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackButton); + + // Start timer + this.startTimer(); } componentWillUnmount() { - BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton) + this.backHandler?.remove(); + if (this.interval) clearInterval(this.interval); } - handleBackButton = () => { + startTimer = () => { + this.interval = setInterval(() => { + this.setState(prev => { + if (prev.timer <= 1) { + clearInterval(this.interval); + this.showResults(); + return { timer: 0, results: true }; + } + return { timer: prev.timer - 1 }; + }); + }, 1000); + } - let tmpQuestions = [] + handleBackButton = () => { + let tmpQuestions = []; AsyncStorage.getItem('setupData').then((value) => { - let setupData = JSON.parse(value) - examScheme.forEach( (elem) => { - let currentSection = setupData.excludeDelta ? allQuestions[elem.section].filter(item => !item.delta) : allQuestions[elem.section] - for(let i=0; i index != currentIndex) - } - }) + const setupData = JSON.parse(value) || {}; - this.props.navigation.navigate("Splash", { - examQuestions: tmpQuestions - }) + examScheme.forEach(elem => { + let currentSection = setupData.excludeDelta + ? allQuestions[elem.section].filter(item => !item.delta) + : 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((_, index) => index !== currentIndex); + } + }); - return true + this.props.navigation.navigate("Splash", { examQuestions: tmpQuestions }); + }); - }) + return true; } showResults = () => { @@ -140,125 +126,87 @@ class Exam extends React.Component { totalPoints: this.state.totalPoints, wrongAnswers: this.state.wrongAnswers } - }) + }); } answer = (correct, id, question) => { - this.setState( - state => { - const nextState = { answered: true, clickedId: id, totalPoints: state.totalPoints + parseInt(question.points)} - - if (correct) { - nextState.correctCount = state.correctCount + 1 - nextState.pointsCount = state.pointsCount + parseInt(question.points) - nextState.answerCorrect = true - } else { - nextState.wrongCount = state.wrongCount + 1 - nextState.answerCorrect = false - nextState.wrongAnswers = state.wrongAnswers - nextState.wrongAnswers.push( - { question: question.question, - id: question.id, - clicked: id, - answers: question.answers - } - ) - } - return nextState - }, - () => { - if(this.state.timer > 1 || (this.state.correctCount+this.state.wrongCount) < this.state.totalCount) { - setTimeout(() => this.nextQuestion(), correct ? 750 : 3500) - } + this.setState(prev => { + const nextState = { + answered: true, + clickedId: id, + totalPoints: prev.totalPoints + parseInt(question.points) + }; + + if (correct) { + nextState.correctCount = prev.correctCount + 1; + nextState.pointsCount = prev.pointsCount + parseInt(question.points); + nextState.answerCorrect = true; + } else { + nextState.wrongCount = prev.wrongCount + 1; + nextState.answerCorrect = false; + nextState.wrongAnswers = [...prev.wrongAnswers, { + question: question.question, + id: question.id, + clicked: id, + answers: question.answers + }]; } - ) + return nextState; + }, () => setTimeout(() => this.nextQuestion(), correct ? 750 : 3500)); } nextQuestion = () => { + const { availableIds, activeQuestionId, correctCount, wrongCount, totalCount } = this.state; + const updatedIndexes = availableIds.filter(id => id !== activeQuestionId); - const updatedIndexes = this.state.availableIds.filter( item => item != this.state.activeQuestionId) - const nextId = updatedIndexes[Math.floor(Math.random() * updatedIndexes.length)] - let resultsShow = (this.state.timer <= 1 || (this.state.correctCount+this.state.wrongCount) == this.state.totalCount) ? true : false - - if (!updatedIndexes.length) { - - clearInterval(interval) - this.showResults() - - } else { - this.setState( (state) => { - return { - availableIds: updatedIndexes, - activeQuestionId: nextId, - answered: false, - results: resultsShow - } - }) + if (!updatedIndexes.length || (correctCount + wrongCount) === totalCount) { + clearInterval(this.interval); + this.showResults(); + return; } - } - componentWillUnmount(){ - clearInterval(interval) + const nextId = updatedIndexes[Math.floor(Math.random() * updatedIndexes.length)]; + this.setState({ availableIds: updatedIndexes, activeQuestionId: nextId, answered: false, results: false, clickedId: null }); } render() { - const questions = this.props.navigation.getParam("questions", []) - const question = questions.filter(item => item.id == this.state.activeQuestionId)[0] || questions[0] - - if(this.state.timer==maxTime) { - interval = setInterval( () => { - this.setState( (state) => { - return { - timer: this.state.timer-1, - results: this.state.timer <= 1 || false - } - }) - }, 1000) - } - - if(this.state.timer < 1 || (this.state.correctCount+this.state.wrongCount) == this.state.totalCount) { - clearInterval(interval) - setTimeout ( () => { - this.showResults() - }, 1000) - } + const { availableIds, activeQuestionId, results, correctCount, wrongCount, totalCount, clickedId } = this.state; + const questions = this.props.route.params?.questions || []; + const question = questions.find(q => q.id === activeQuestionId) || questions[0]; return ( - - - - {!this.state.results ? - - {new Date(this.state.timer * 1000).toISOString().substr(11, 8)} - - {question.id} - {question.question} - - - {question.answers.map(answer => ( -