From cab42670755334ea8035a38bdf8bee8d3d592369 Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Sat, 6 Aug 2022 13:50:28 -0500 Subject: [PATCH] game screen navigation --- squarenotsquare/src/screens/Game.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/squarenotsquare/src/screens/Game.js b/squarenotsquare/src/screens/Game.js index f605b9e..c584b75 100644 --- a/squarenotsquare/src/screens/Game.js +++ b/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){