I hereby claim:
- I am hamzabasrai on github.
- I am hamzabasrai (https://keybase.io/hamzabasrai) on keybase.
- I have a public key ASDIjX09oLlcGJObZAiz_nPPZT47BdiBDI4Ezf6V-L_yuwo
To claim this, I am signing this object:
const matchDarkMode = window.matchMedia("(prefers-color-scheme: dark)"); | |
// event listener | |
matchDarkMode.addListener(() => { | |
const isDark = matchDarkMode.matches; | |
}); | |
// one time check | |
const isDark = matchDarkMode.matches; |
html, body { | |
padding: 0; | |
margin: 0; | |
color: #273238; | |
} | |
/* Dark mode */ | |
@media (prefers-color-scheme: dark) { | |
html, body { | |
background-color: black; |
<!-- /ios/App/App/info.plist --> | |
<key>UIUserInterfaceStyle</key> | |
<string>Light</string> |
<!-- res/values-night/styles.xml --> | |
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="navigationBarColor">@android:color/black</color> | |
<color name="navigationIconColor">@android:color/white</color> | |
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar"> | |
<item name="windowActionBar">false</item> | |
<item name="windowNoTitle">true</item> | |
<item name="android:background">@null</item> |
<!-- res/values/styles.xml --> | |
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="navigationBarColor">@android:color/white</color> | |
<color name="navigationIconColor">@android:color/black</color> | |
<!-- Base application theme. --> | |
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar"> | |
<!-- Customize your theme here. --> | |
<item name="colorPrimary">@color/colorPrimary</item> |
public void onResume() { | |
super.onResume(); | |
this.updateDarkMode(this.getResources().getConfiguration()); | |
} |
// Update webview theme | |
private void forceDarkMode(int mode) { | |
// This Dark Mode Strategy sets the css prefers-color-scheme property, | |
// instead of trying to automatically convert pages. (Consistent with iOS) | |
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { | |
WebSettingsCompat.setForceDarkStrategy(this.bridge.getWebView().getSettings(), WebSettingsCompat.DARK_STRATEGY_WEB_THEME_DARKENING_ONLY); | |
} | |
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { | |
WebSettingsCompat.setForceDark(this.bridge.getWebView().getSettings(), mode); | |
} |
@Override | |
public void onConfigurationChanged(Configuration configuration) { | |
super.onConfigurationChanged(configuration); | |
this.updateDarkMode(configuration); | |
} | |
private void updateDarkMode(Configuration configuration) { | |
// read the new night mode value | |
int currentNightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK; |
I hereby claim:
To claim this, I am signing this object:
# Oxide theme for Zsh | |
# | |
# Author: Diki Ananta <diki1aap@gmail.com> | |
# Repository: https://github.com/dikiaap/dotfiles | |
# License: MIT | |
# Prompt: | |
# %F => Color codes | |
# %f => Reset color | |
# %~ => Current path |