App.tsx: Hell/Dunkel-State nach theme/useThemeMode.ts
Reiner Umzug von useState + Setter-Wrapper (persistiert in localStorage via themeMode.ts) in einen eigenen Hook. Verhaltensgleich.
This commit is contained in:
+2
-10
@@ -132,11 +132,6 @@ import { TextEditorDialog } from "./ui/TextEditorDialog";
|
|||||||
import { RoomStampEditor } from "./panels/RoomStampEditor";
|
import { RoomStampEditor } from "./panels/RoomStampEditor";
|
||||||
import { defaultRoomStamp } from "./model/roomStamp";
|
import { defaultRoomStamp } from "./model/roomStamp";
|
||||||
import { StatusBar, type RendererMode } from "./ui/StatusBar";
|
import { StatusBar, type RendererMode } from "./ui/StatusBar";
|
||||||
import {
|
|
||||||
type ThemeMode,
|
|
||||||
getStoredThemeMode,
|
|
||||||
setStoredThemeMode,
|
|
||||||
} from "./theme/themeMode";
|
|
||||||
import { getTool } from "./tools/tools";
|
import { getTool } from "./tools/tools";
|
||||||
import { applyAngleConstraint, computeSnap } from "./tools/snapping";
|
import { applyAngleConstraint, computeSnap } from "./tools/snapping";
|
||||||
import {
|
import {
|
||||||
@@ -163,6 +158,7 @@ import type { MenuState } from "./menus/contextMenu";
|
|||||||
import { InlineEditor } from "./views/InlineEditor";
|
import { InlineEditor } from "./views/InlineEditor";
|
||||||
import { Content } from "./views/viewportContent";
|
import { Content } from "./views/viewportContent";
|
||||||
import { useDialogState } from "./state/useDialogState";
|
import { useDialogState } from "./state/useDialogState";
|
||||||
|
import { useThemeModeState } from "./theme/useThemeMode";
|
||||||
import { CommandLine } from "./ui/CommandLine";
|
import { CommandLine } from "./ui/CommandLine";
|
||||||
import type { CommandLineHandle, CommandLineField, CommandLineOption } from "./ui/CommandLine";
|
import type { CommandLineHandle, CommandLineField, CommandLineOption } from "./ui/CommandLine";
|
||||||
import { CommandEngine } from "./commands/engine";
|
import { CommandEngine } from "./commands/engine";
|
||||||
@@ -4267,11 +4263,7 @@ export default function App() {
|
|||||||
|
|
||||||
// Hell/Dunkel (Einstellungen → Darstellung). Standard Hell (styles.css);
|
// Hell/Dunkel (Einstellungen → Darstellung). Standard Hell (styles.css);
|
||||||
// Dunkel ist Opt-in und persistiert in localStorage.
|
// Dunkel ist Opt-in und persistiert in localStorage.
|
||||||
const [themeMode, setThemeModeState] = useState<ThemeMode>(() => getStoredThemeMode());
|
const { themeMode, setThemeMode } = useThemeModeState();
|
||||||
const setThemeMode = (mode: ThemeMode) => {
|
|
||||||
setThemeModeState(mode);
|
|
||||||
setStoredThemeMode(mode);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Einstellungen als eigenes natives Fenster (Tauri) statt Overlay-Dialog —
|
// Einstellungen als eigenes natives Fenster (Tauri) statt Overlay-Dialog —
|
||||||
// hält es (falls offen) synchron zu den betroffenen Feldern, wendet dessen
|
// hält es (falls offen) synchron zu den betroffenen Feldern, wendet dessen
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// React-State-Wrapper um den Hell/Dunkel-Umschalter (Einstellungen →
|
||||||
|
// Darstellung). Standard Hell (styles.css); Dunkel ist Opt-in und
|
||||||
|
// persistiert in localStorage (themeMode.ts).
|
||||||
|
//
|
||||||
|
// Extrahiert aus App.tsx. Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { getStoredThemeMode, setStoredThemeMode } from "./themeMode";
|
||||||
|
import type { ThemeMode } from "./themeMode";
|
||||||
|
|
||||||
|
export function useThemeModeState() {
|
||||||
|
const [themeMode, setThemeModeState] = useState<ThemeMode>(() => getStoredThemeMode());
|
||||||
|
const setThemeMode = (mode: ThemeMode) => {
|
||||||
|
setThemeModeState(mode);
|
||||||
|
setStoredThemeMode(mode);
|
||||||
|
};
|
||||||
|
return { themeMode, setThemeMode };
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user