(iOS) showBackground set webview to white instead of previous color
Describe the bug When showBackground is called, the webview is set to white.
The webview backgroundColor can be set in capacitor.config.js with a custom color.
showBackground should revert to the previous backgroundColor instead of white.
Code Reference
// @capacitor-community/barcode-scanner/ios/Plugin/Plugin.swift
private func showBackground() {
DispatchQueue.main.async {
let javascript = "document.documentElement.style.backgroundColor = ''"
self.bridge?.webView!.evaluateJavaScript(javascript) { (result, error) in
self.bridge?.webView!.isOpaque = true
self.bridge?.webView!.backgroundColor = UIColor.white
self.bridge?.webView!.scrollView.backgroundColor = UIColor.white
}
}
}
// @capacitor/ios/Capacitor/Capacitor/CAPBridgeViewController.swift
// line 294
if let backgroundColor = configuration.backgroundColor {
aWebView.backgroundColor = backgroundColor
aWebView.scrollView.backgroundColor = backgroundColor
} else {
// Use the system background colors if background is not set by user
aWebView.backgroundColor = UIColor.systemBackground
aWebView.scrollView.backgroundColor = UIColor.systemBackground
}
Version Barcode-scanner: 3.0.0 Capacitor-ios: 4.1.0
Additional context
There is an open bug on Capacitor when using a custom color. isOpaque needs to be set to false
I already now about this issue, but thank you for opening it as an issue.
Would it be possible for you to create a PR of your changes for Android and iOS?
Hi @thegnuu, I've created PR #201 to address the iOS issue raised here.
Merged ;) But I missed to close the issue.