Browse Source

game screen navigation

pull/8/head
Tim Glasgow 2 years ago
parent
commit
cab4267075
  1. 8
      squarenotsquare/src/screens/Game.js

8
squarenotsquare/src/screens/Game.js

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

Loading…
Cancel
Save