UX: Update header background color in mobile app webview

Sends the updated value when switching color schemes.
This commit is contained in:
Penar Musaraj 2020-08-07 16:13:22 -04:00
parent 89209985c8
commit 31e9e0c41b
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
1 changed files with 13 additions and 7 deletions

View File

@ -8,13 +8,19 @@ export default {
initialize() {
if (isAppWebview()) {
later(() => {
const header = document.querySelectorAll(".d-header")[0];
if (header) {
const styles = window.getComputedStyle(header);
postRNWebviewMessage("headerBg", styles.backgroundColor);
}
}, 500);
window
.matchMedia("(prefers-color-scheme: dark)")
.addListener(this.updateAppBackground);
this.updateAppBackground();
}
},
updateAppBackground() {
later(() => {
const header = document.querySelectorAll(".d-header")[0];
if (header) {
const styles = window.getComputedStyle(header);
postRNWebviewMessage("headerBg", styles.backgroundColor);
}
}, 500);
}
};