From 916af736ad2445ad21168c7ae16fe10a8139693a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 11 Aug 2019 03:43:34 +0100 Subject: [PATCH] Consolidate Themes into ThemeController. Remove hardcoded themes in view Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../settings/tabs/user/GeneralUserSettingsTab.js | 7 +++++-- src/settings/controllers/ThemeController.js | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js index a9c010b6b4..5fbc8deb35 100644 --- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js @@ -1,6 +1,7 @@ /* Copyright 2019 New Vector Ltd Copyright 2019 The Matrix.org Foundation C.I.C. +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,6 +27,7 @@ import LanguageDropdown from "../../../elements/LanguageDropdown"; import AccessibleButton from "../../../elements/AccessibleButton"; import DeactivateAccountDialog from "../../../dialogs/DeactivateAccountDialog"; import PropTypes from "prop-types"; +import {SUPPORTED_THEMES} from "../../../../../settings/controllers/ThemeController"; const PlatformPeg = require("../../../../../PlatformPeg"); const MatrixClientPeg = require("../../../../../MatrixClientPeg"); const sdk = require('../../../../..'); @@ -160,8 +162,9 @@ export default class GeneralUserSettingsTab extends React.Component { {_t("Theme")} - - + {Object.entries(SUPPORTED_THEMES).map(([theme, text]) => { + return ; + })} diff --git a/src/settings/controllers/ThemeController.js b/src/settings/controllers/ThemeController.js index 615fc4c192..fd35f79622 100644 --- a/src/settings/controllers/ThemeController.js +++ b/src/settings/controllers/ThemeController.js @@ -1,5 +1,6 @@ /* Copyright 2019 New Vector Ltd +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,16 +16,17 @@ limitations under the License. */ import SettingController from "./SettingController"; +import {_td} from "../../languageHandler"; -const SUPPORTED_THEMES = [ - "light", - "dark", -]; +export const SUPPORTED_THEMES = { + "light": _td("Light theme"), + "dark": _td("Dark theme"), +}; export default class ThemeController extends SettingController { getValueOverride(level, roomId, calculatedValue, calculatedAtLevel) { // Override in case some no longer supported theme is stored here - if (!SUPPORTED_THEMES.includes(calculatedValue)) { + if (!SUPPORTED_THEMES[calculatedValue]) { return "light"; }