Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Consolidate Themes into ThemeController. Remove hardcoded themes in view #3304

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
Copyright 2019 New Vector Ltd
Copyright 2019 The Matrix.org Foundation C.I.C.
Copyright 2019 Michael Telatynski <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -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";
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
const PlatformPeg = require("../../../../../PlatformPeg");
const MatrixClientPeg = require("../../../../../MatrixClientPeg");
const sdk = require('../../../../..');
Expand Down Expand Up @@ -160,8 +162,9 @@ export default class GeneralUserSettingsTab extends React.Component {
<span className="mx_SettingsTab_subheading">{_t("Theme")}</span>
<Field id="theme" label={_t("Theme")} element="select"
value={this.state.theme} onChange={this._onThemeChange}>
<option value="light">{_t("Light theme")}</option>
<option value="dark">{_t("Dark theme")}</option>
{Object.entries(SUPPORTED_THEMES).map(([theme, text]) => {
return <option key={theme} value={theme}>{_t(text)}</option>;
})}
</Field>
<SettingsFlag name="useCompactLayout" level={SettingLevel.ACCOUNT} />
</div>
Expand Down
12 changes: 7 additions & 5 deletions src/settings/controllers/ThemeController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
Copyright 2019 New Vector Ltd
Copyright 2019 Michael Telatynski <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -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";
}

Expand Down