mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Update header background color in mobile app webview
Sends the updated value when switching color schemes.
This commit is contained in:
parent
89209985c8
commit
31e9e0c41b
@ -8,13 +8,19 @@ export default {
|
|||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
if (isAppWebview()) {
|
if (isAppWebview()) {
|
||||||
later(() => {
|
window
|
||||||
const header = document.querySelectorAll(".d-header")[0];
|
.matchMedia("(prefers-color-scheme: dark)")
|
||||||
if (header) {
|
.addListener(this.updateAppBackground);
|
||||||
const styles = window.getComputedStyle(header);
|
this.updateAppBackground();
|
||||||
postRNWebviewMessage("headerBg", styles.backgroundColor);
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateAppBackground() {
|
||||||
|
later(() => {
|
||||||
|
const header = document.querySelectorAll(".d-header")[0];
|
||||||
|
if (header) {
|
||||||
|
const styles = window.getComputedStyle(header);
|
||||||
|
postRNWebviewMessage("headerBg", styles.backgroundColor);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user