UX: Send background color to iPad app too

Previously, we were only updating mobile devices.
This commit is contained in:
Penar Musaraj 2020-06-11 23:20:25 -04:00
parent b2c94cc8ea
commit f57ecf22e0
No known key found for this signature in database
GPG Key ID: E390435D881FF0F7
2 changed files with 20 additions and 11 deletions

View File

@ -1,7 +1,5 @@
import { later } from "@ember/runloop";
import Mobile from "discourse/lib/mobile";
import { setResolverOption } from "discourse-common/resolver";
import { isAppWebview, postRNWebviewMessage } from "discourse/lib/utilities";
// Initializes the `Mobile` helper object.
export default {
@ -16,14 +14,5 @@ export default {
site.set("isMobileDevice", Mobile.isMobileDevice);
setResolverOption("mobileView", Mobile.mobileView);
if (isAppWebview()) {
later(() => {
postRNWebviewMessage(
"headerBg",
$(".d-header").css("background-color")
);
}, 500);
}
}
};

View File

@ -0,0 +1,20 @@
import { later } from "@ember/runloop";
import { isAppWebview, postRNWebviewMessage } from "discourse/lib/utilities";
// Send bg color to webview so iOS status bar matches site theme
export default {
name: "webview-background",
after: "inject-objects",
initialize() {
if (isAppWebview()) {
later(() => {
const header = document.querySelectorAll(".d-header")[0];
if (header) {
const styles = window.getComputedStyle(header);
postRNWebviewMessage("headerBg", styles.backgroundColor);
}
}, 500);
}
}
};