From 7bdac85a2a9f353f784320bf241378616a1a0323 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 12 Aug 2019 14:24:12 +0100
Subject: [PATCH] Break themes out into a separate file
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../tabs/user/GeneralUserSettingsTab.js | 4 ++--
src/i18n/strings/en_EN.json | 4 ++--
src/settings/controllers/ThemeController.js | 11 +++------
src/themes.js | 24 +++++++++++++++++++
4 files changed, 31 insertions(+), 12 deletions(-)
create mode 100644 src/themes.js
diff --git a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
index 5fbc8deb35..4326a4f39e 100644
--- a/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
+++ b/src/components/views/settings/tabs/user/GeneralUserSettingsTab.js
@@ -27,7 +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";
+import {THEMES} from "../../../../../themes";
const PlatformPeg = require("../../../../../PlatformPeg");
const MatrixClientPeg = require("../../../../../MatrixClientPeg");
const sdk = require('../../../../..');
@@ -162,7 +162,7 @@ export default class GeneralUserSettingsTab extends React.Component {
{_t("Theme")}
- {Object.entries(SUPPORTED_THEMES).map(([theme, text]) => {
+ {Object.entries(THEMES).map(([theme, text]) => {
return ;
})}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 8173051c30..714e597c7a 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -251,6 +251,8 @@
"%(widgetName)s widget modified by %(senderName)s": "%(widgetName)s widget modified by %(senderName)s",
"%(widgetName)s widget added by %(senderName)s": "%(widgetName)s widget added by %(senderName)s",
"%(widgetName)s widget removed by %(senderName)s": "%(widgetName)s widget removed by %(senderName)s",
+ "Light theme": "Light theme",
+ "Dark theme": "Dark theme",
"%(displayName)s is typing …": "%(displayName)s is typing …",
"%(names)s and %(count)s others are typing …|other": "%(names)s and %(count)s others are typing …",
"%(names)s and %(count)s others are typing …|one": "%(names)s and one other is typing …",
@@ -548,8 +550,6 @@
"Set a new account password...": "Set a new account password...",
"Language and region": "Language and region",
"Theme": "Theme",
- "Light theme": "Light theme",
- "Dark theme": "Dark theme",
"Account management": "Account management",
"Deactivating your account is a permanent action - be careful!": "Deactivating your account is a permanent action - be careful!",
"Deactivate Account": "Deactivate Account",
diff --git a/src/settings/controllers/ThemeController.js b/src/settings/controllers/ThemeController.js
index fd35f79622..da20521873 100644
--- a/src/settings/controllers/ThemeController.js
+++ b/src/settings/controllers/ThemeController.js
@@ -16,18 +16,13 @@ limitations under the License.
*/
import SettingController from "./SettingController";
-import {_td} from "../../languageHandler";
-
-export const SUPPORTED_THEMES = {
- "light": _td("Light theme"),
- "dark": _td("Dark theme"),
-};
+import {DEFAULT_THEME, THEMES} from "../../themes";
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[calculatedValue]) {
- return "light";
+ if (!THEMES[calculatedValue]) {
+ return DEFAULT_THEME;
}
return null; // no override
diff --git a/src/themes.js b/src/themes.js
new file mode 100644
index 0000000000..1896333844
--- /dev/null
+++ b/src/themes.js
@@ -0,0 +1,24 @@
+/*
+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.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import {_td} from "./languageHandler";
+
+export const DEFAULT_THEME = "light";
+
+export const THEMES = {
+ "light": _td("Light theme"),
+ "dark": _td("Dark theme"),
+};