-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Adding dark and light theme names to the sponsor request (params to API) #3561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,14 @@ const css_dark = [ | |
| ]; | ||
|
|
||
| const DarkTheme = { | ||
| configEnabled: undefined, | ||
| configSetting: undefined, | ||
| enabled: false, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would duplicate configEnabled
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I'm not sure it does. It looked to me that configEnabled is not binary, so supports the option 'honour the system' so can't be relied upon for stating that dark theme was in fact enabled.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above statement would extract the value or [use] get ConfigStorage
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which means configEnabled is not well named. It should be configSetting or similar. It can't be relied upon as to if it's actually applied or not... sure it'll have a value of two... but does that mean dark theme is active? I don't think it does because the test of isEnabled is not persisted... |
||
| }; | ||
|
|
||
| DarkTheme.isDarkThemeEnabled = function (callback) { | ||
| if (this.configEnabled === 0) { | ||
| if (this.configSetting === 0) { | ||
| callback(true); | ||
| } else if (this.configEnabled === 2) { | ||
| } else if (this.configSetting === 2) { | ||
| if (GUI.isCordova()) { | ||
| cordova.plugins.ThemeDetection.isDarkModeEnabled(function(success) { | ||
| callback(success.value); | ||
|
|
@@ -47,27 +48,28 @@ DarkTheme.apply = function() { | |
| }; | ||
|
|
||
| DarkTheme.autoSet = function() { | ||
| if (this.configEnabled === 2) { | ||
| if (this.configSetting === 2) { | ||
| this.apply(); | ||
| } | ||
| }; | ||
|
|
||
| DarkTheme.setConfig = function (result) { | ||
| if (this.configEnabled !== result) { | ||
| this.configEnabled = result; | ||
| if (this.configSetting !== result) { | ||
| this.configSetting = result; | ||
| this.apply(); | ||
| } | ||
| }; | ||
|
|
||
| DarkTheme.applyDark = function () { | ||
| css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', false)); | ||
| this.enabled = true; | ||
| }; | ||
|
|
||
| DarkTheme.applyNormal = function () { | ||
| css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', true)); | ||
| this.enabled = false; | ||
| }; | ||
|
|
||
|
|
||
| export function setDarkTheme(enabled) { | ||
| DarkTheme.setConfig(enabled); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking for
window.matchMedia('(prefers-color-scheme: dark)').matcheswould doThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll test this.