Added settings to choose desired UI theme.

This commit is contained in:
morpheus65535 2023-06-15 06:32:36 -04:00
parent 304ad160e0
commit 2511c310f1
5 changed files with 41 additions and 3 deletions

View File

@ -52,6 +52,7 @@ defaults = {
'movie_default_enabled': 'False',
'movie_default_profile': '',
'page_size': '25',
'theme': 'auto',
'page_size_manual_search': '10',
'minimum_score_movie': '70',
'use_embedded_subs': 'True',

View File

@ -1,3 +1,4 @@
import { useSystemSettings } from "@/apis/hooks";
import {
ColorScheme,
ColorSchemeProvider,
@ -34,7 +35,19 @@ const theme: MantineThemeOverride = {
};
function useAutoColorScheme() {
const preferredColorScheme = useColorScheme();
const settings = useSystemSettings();
const settingsColorScheme = settings.data?.general.theme;
let preferredColorScheme: ColorScheme = useColorScheme();
switch (settingsColorScheme) {
case "light":
preferredColorScheme = "light" as ColorScheme;
break;
case "dark":
preferredColorScheme = "dark" as ColorScheme;
break;
}
const [colorScheme, setColorScheme] = useState(preferredColorScheme);
// automatically switch dark/light theme

View File

@ -1,12 +1,12 @@
import { uiPageSizeKey } from "@/utilities/storage";
import { FunctionComponent } from "react";
import { Layout, Section, Selector } from "../components";
import { pageSizeOptions } from "./options";
import { colorSchemeOptions, pageSizeOptions } from "./options";
const SettingsUIView: FunctionComponent = () => {
return (
<Layout name="Interface">
<Section header="UI">
<Section header="List View">
<Selector
label="Page Size"
options={pageSizeOptions}
@ -14,6 +14,14 @@ const SettingsUIView: FunctionComponent = () => {
defaultValue={50}
></Selector>
</Section>
<Section header="Style">
<Selector
label="Theme"
options={colorSchemeOptions}
settingKey="settings-general-theme"
defaultValue={"auto"}
></Selector>
</Section>
</Layout>
);
};

View File

@ -26,3 +26,18 @@ export const pageSizeOptions: SelectorOption<number>[] = [
value: 1000,
},
];
export const colorSchemeOptions: SelectorOption<string>[] = [
{
label: "Auto",
value: "auto",
},
{
label: "Light",
value: "light",
},
{
label: "Dark",
value: "dark",
},
];

View File

@ -57,6 +57,7 @@ declare namespace Settings {
path_mappings: [string, string][];
path_mappings_movie: [string, string][];
page_size: number;
theme: string;
port: number;
upgrade_subs: boolean;
postprocessing_cmd?: string;