Skip to content

Commit

Permalink
Zen Mode
Browse files Browse the repository at this point in the history
Activate in settings
If activated skola goes into fullscreen during learning
quick dirty implementation...
  • Loading branch information
h16nning committed Feb 6, 2024
1 parent f0381cf commit 284fc6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/learning/LearnView/LearnView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ import LearnViewFooter from "./LearnViewFooter";
import LearnViewHeader, { stopwatchResult } from "./LearnViewHeader";
import LearnViewCurrentCardStateIndicator from "../LearnViewCurrentCardStateIndicator/LearnViewCurrentCardStateIndicator";
import { useLearning } from "../../../logic/learn";
import { useDebouncedValue } from "@mantine/hooks";
import { useDebouncedValue, useFullscreen } from "@mantine/hooks";
import { useNavigate } from "react-router-dom";
import { useSetting } from "../../../logic/Settings";

function LearnView() {
const { toggle, fullscreen } = useFullscreen();
const [useZenMode] = useSetting("useZenMode");

const navigate = useNavigate();
const [deck, isReady, params] = useDeckFromUrl();
const [cardSet, setCardSet] = useState<Card<CardType>[] | null>(null);
Expand All @@ -32,6 +36,9 @@ function LearnView() {
>(undefined);

useEffect(() => {
if (useZenMode && !fullscreen) {
toggle();
}
getCardsOf(deck).then((cards) => setCardSet(cards ?? null));
}, [deck]);

Expand Down Expand Up @@ -65,6 +72,9 @@ function LearnView() {
useEffect(() => {
if (controller.learningIsFinished) {
stopwatchResult.pause();
if (fullscreen) {
toggle();
}
}
}, [controller.learningIsFinished]);

Expand Down
5 changes: 5 additions & 0 deletions src/components/settings/GeneralSettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export default function GeneralSettingsView() {
settingsKey="developerMode"
inputType={"switch"}
/>
<SettingsInput
label={"Zen Mode"}
settingsKey="useZenMode"
inputType={"switch"}
/>
</Stack>
</>
);
Expand Down
2 changes: 2 additions & 0 deletions src/logic/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface SettingsValues {
showListOptionInEditor: boolean;
showCodeOptionInEditor: boolean;
showLinkOptionInEditor: boolean;
useZenMode: boolean;
}

export const defaultSettings: SettingsValues = {
Expand All @@ -29,6 +30,7 @@ export const defaultSettings: SettingsValues = {
showListOptionInEditor: true,
showCodeOptionInEditor: true,
showLinkOptionInEditor: true,
useZenMode: false,
};

export function useSetting<T extends keyof SettingsValues>(
Expand Down

0 comments on commit 284fc6c

Please sign in to comment.