diff --git a/.yarn/cache/expo-haptics-npm-12.2.1-6d8fdfb87b-b64d9eb3ad.zip b/.yarn/cache/expo-haptics-npm-12.2.1-6d8fdfb87b-b64d9eb3ad.zip new file mode 100644 index 0000000..579d040 Binary files /dev/null and b/.yarn/cache/expo-haptics-npm-12.2.1-6d8fdfb87b-b64d9eb3ad.zip differ diff --git a/app/game/index.tsx b/app/game/index.tsx index 4d646ea..33e02e5 100644 --- a/app/game/index.tsx +++ b/app/game/index.tsx @@ -1,7 +1,9 @@ +import * as Haptics from 'expo-haptics'; +import { ImpactFeedbackStyle } from 'expo-haptics'; import { useRouter } from 'expo-router'; import { StatusBar } from 'expo-status-bar'; import { useEffect } from 'react'; -import { Alert, View, Text } from 'react-native'; +import { Alert, Text, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { AvailableValues } from '../../components/available-values/available-values'; @@ -21,16 +23,21 @@ export default function Game() { const selectedCell = useAppSelector(appRootSelectedCellSelector); const mistakes = useAppSelector(appRootMistakesSelector); - useEffect(() => { + const handleWin = async () => { if (!hasBlankCells(field)[0]) { + await Haptics.impactAsync(ImpactFeedbackStyle.Heavy); router.push('winner'); } - }, [field]); - useEffect(() => { + }; + const handleLose = async () => { if (mistakes >= MaxMistakesConstant) { + await Haptics.impactAsync(ImpactFeedbackStyle.Heavy); router.push('loser'); } - }, [mistakes]); + }; + + useEffect(() => void handleWin(), [field]); + useEffect(() => void handleLose(), [mistakes]); const handleExit = () => { Alert.alert('Stop current run?', 'All progress will be lost', [ diff --git a/package.json b/package.json index a8b2515..24f71ae 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "expo": "~48.0.15", "expo-constants": "~14.2.1", "expo-font": "~11.1.1", + "expo-haptics": "~12.2.1", "expo-linking": "~4.0.1", "expo-router": "^1.5.3", "expo-splash-screen": "~0.18.2", diff --git a/store/app-root/actions/app-root-select-value.action.ts b/store/app-root/actions/app-root-select-value.action.ts index bee29db..9ab443c 100644 --- a/store/app-root/actions/app-root-select-value.action.ts +++ b/store/app-root/actions/app-root-select-value.action.ts @@ -1,5 +1,6 @@ import { createAsyncThunk } from '@reduxjs/toolkit'; import { isDefined } from '@rnw-community/shared'; +import * as Haptics from 'expo-haptics'; import { BlankCellValueContant } from '../../../constants/blank-cell-value.contant'; import { isCorrectCell } from '../../../utils/field/is-correct-cell.util'; @@ -20,9 +21,13 @@ export const appRootSelectValueAction = createAsyncThunk