|
@ -1,9 +1,11 @@ |
|
|
import React from "react"; |
|
|
import React from "react"; |
|
|
import { Text, TouchableOpacity, View, SafeAreaView } from "react-native"; |
|
|
import { Text, TouchableOpacity, View, SafeAreaView } from "react-native"; |
|
|
import { useState, useEffect, useRef, useMemo } from "react"; |
|
|
import { useState, useEffect, useRef, useMemo } from "react"; |
|
|
|
|
|
import { useDispatch } from "react-redux"; |
|
|
import {genSquareChallenge} from '../libs/Random'; |
|
|
import {genSquareChallenge} from '../libs/Random'; |
|
|
import {shapes} from '../libs/ShapeEnum'; |
|
|
import {shapes} from '../libs/ShapeEnum'; |
|
|
import { styles } from "./styles/AppStyles"; |
|
|
import { styles } from "./styles/AppStyles"; |
|
|
|
|
|
import { squareFinished } from "../redux/actions/UserActions"; |
|
|
import Autoscroll from "../components/Autoscroll"; |
|
|
import Autoscroll from "../components/Autoscroll"; |
|
|
import Fade from "../components/Fade"; |
|
|
import Fade from "../components/Fade"; |
|
|
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'; |
|
|
import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'; |
|
@ -25,6 +27,7 @@ function Game(props){ |
|
|
const [headerText, setHeaderText] = useState('Ready?'); |
|
|
const [headerText, setHeaderText] = useState('Ready?'); |
|
|
const [headerColor, setHeaderColor] = useState(styles.green); |
|
|
const [headerColor, setHeaderColor] = useState(styles.green); |
|
|
const [headerTextColor, setHeaderTextColor] = useState(styles.darkText); |
|
|
const [headerTextColor, setHeaderTextColor] = useState(styles.darkText); |
|
|
|
|
|
const dispatch = useDispatch(); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
let headerTimeout = null; |
|
|
let headerTimeout = null; |
|
@ -64,7 +67,7 @@ function Game(props){ |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
localTimer.current = (headerTimeout); |
|
|
localTimer.current = headerTimeout; |
|
|
|
|
|
|
|
|
return () => { |
|
|
return () => { |
|
|
clearTimeout(localTimer.current); |
|
|
clearTimeout(localTimer.current); |
|
@ -98,6 +101,9 @@ function Game(props){ |
|
|
setHeaderColor(styles.darkGreen); |
|
|
setHeaderColor(styles.darkGreen); |
|
|
setHeaderText((Date.now() - startTime.current) / (1000) + ' s'); |
|
|
setHeaderText((Date.now() - startTime.current) / (1000) + ' s'); |
|
|
setTimerState(4); |
|
|
setTimerState(4); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
dispatch(squareFinished(score.current)); |
|
|
|
|
|
}, 3000); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function generateSquare(pairIndex){ |
|
|
function generateSquare(pairIndex){ |
|
|