diff --git a/src/App.js b/src/App.js index 69ef7fe..c9d1481 100644 --- a/src/App.js +++ b/src/App.js @@ -89,6 +89,7 @@ function App() { ); const [volume, setVolume] = useStorage("volume", "on"); const [notifications, setNotifications] = useStorage("notifications", "on"); + const [focusMode, setFocusMode] = useStorage("focusMode", "off"); useEffect(() => { return firebase.auth().onAuthStateChanged((user) => { @@ -162,6 +163,8 @@ function App() { setVolume, notifications, setNotifications, + focusMode, + setFocusMode, layoutOrientation, setLayoutOrientation, cardOrientation, diff --git a/src/components/Navbar.js b/src/components/Navbar.js index e5d8ec5..adb4315 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -115,6 +115,10 @@ function Navbar() { ); } + function handleChangeFocusMode() { + settings.setFocusMode((focusMode) => (focusMode === "on" ? "off" : "on")); + } + useKeydown((event) => { if (getModifierState(event) === "Control") { if (event.key === "s") { @@ -221,6 +225,14 @@ function Navbar() { {settings.notifications === "on" ? "Disable" : "Enable"}{" "} notifications + { + handleChangeFocusMode(); + handleCloseMenu(); + }} + > + {settings.focusMode === "on" ? "Disable" : "Enable"} focus mode + { handleChangeTheme(); diff --git a/src/pages/GamePage.js b/src/pages/GamePage.js index 076a3b7..29775a2 100644 --- a/src/pages/GamePage.js +++ b/src/pages/GamePage.js @@ -111,7 +111,7 @@ function ensureConnected() { function GamePage({ match }) { const user = useContext(UserContext); - const { volume, notifications } = useContext(SettingsContext); + const { volume, notifications, focusMode } = useContext(SettingsContext); const gameId = match.params.id; const nextGameId = useMemo(() => getNextGameId(gameId), [gameId]); const classes = useStyles(); @@ -432,16 +432,18 @@ function GamePage({ match }) { - - - + {(focusMode !== "on" || gameEnded) && ( + + + + )} @@ -510,21 +512,23 @@ function GamePage({ match }) { - - 0 - ? history[history.length - 1].time - : 0 - } - /> - + {(focusMode !== "on" || gameEnded) && ( + + 0 + ? history[history.length - 1].time + : 0 + } + /> + + )} {game.enableHint && (