Skip to content
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

api function to detect light or dark user mode #479

Open
AnthonyBall1966 opened this issue Oct 30, 2019 · 0 comments
Open

api function to detect light or dark user mode #479

AnthonyBall1966 opened this issue Oct 30, 2019 · 0 comments

Comments

@AnthonyBall1966
Copy link
Contributor

Here are some notes...

javascript (html5):
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
// dark mode
}

android:
// We load the Night Mode state here
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
this.isNightModeEnabled = mPrefs.getBoolean(“NIGHT_MODE”, false);
}

iOS:
https://schiavo.me/2019/implementing-dark-mode/

MacOS:
UserDefaults=CocoaMessage(0,0,"NSUserDefaults standardUserDefaults")
NSstring=CocoaMessage(0,UserDefaults,"stringForKey:$",@"AppleInterfaceStyle")
If NSstring
string$=PeekS(CocoaMessage(0,NSstring,"UTF8String"),-1,#PB_UTF8)
If string$="Dark"
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
Else
ProcedureReturn #False
EndIf

Wndows (win32/64):
darkResult=RegReadDWord(#HKEY_CURRENT_USER,"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize","AppsUseLightTheme")
If darkResult=0
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant