@capgo/inappbrowser 7.6.9 → 7.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -450,6 +450,7 @@ public class InAppBrowserPlugin
450
450
  options.setTitle(call.getString("title", ""));
451
451
  }
452
452
  options.setToolbarColor(call.getString("toolbarColor", "#ffffff"));
453
+ options.setBackgroundColor(call.getString("backgroundColor", "black"));
453
454
  options.setToolbarTextColor(call.getString("toolbarTextColor"));
454
455
  options.setArrow(Boolean.TRUE.equals(call.getBoolean("showArrow", false)));
455
456
  options.setIgnoreUntrustedSSLError(
@@ -167,6 +167,7 @@ public class Options {
167
167
  private PluginCall pluginCall;
168
168
  private boolean VisibleTitle;
169
169
  private String ToolbarColor;
170
+ private String BackgroundColor;
170
171
  private boolean ShowArrow;
171
172
  private boolean ignoreUntrustedSSLError;
172
173
  private String preShowScript;
@@ -374,6 +375,14 @@ public class Options {
374
375
  this.ToolbarColor = toolbarColor;
375
376
  }
376
377
 
378
+ public String getBackgroundColor() {
379
+ return BackgroundColor;
380
+ }
381
+
382
+ public void setBackgroundColor(String backgroundColor) {
383
+ this.BackgroundColor = backgroundColor;
384
+ }
385
+
377
386
  public String getToolbarTextColor() {
378
387
  return toolbarTextColor;
379
388
  }
@@ -328,6 +328,12 @@ public class WebViewDialog extends Dialog {
328
328
  _webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
329
329
  _webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
330
330
 
331
+ // Set web view background color
332
+ int backgroundColor = _options.getBackgroundColor().equals("white")
333
+ ? Color.WHITE
334
+ : Color.BLACK;
335
+ _webView.setBackgroundColor(backgroundColor);
336
+
331
337
  // Set text zoom if specified in options
332
338
  if (_options.getTextZoom() > 0) {
333
339
  _webView.getSettings().setTextZoom(_options.getTextZoom());
@@ -368,7 +368,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
368
368
  return
369
369
  }
370
370
 
371
- if (self.bridge?.statusBarVisible == true) {
371
+ if self.bridge?.statusBarVisible == true {
372
372
  let subviews = self.bridge?.webView?.superview?.subviews
373
373
  if let emptyStatusBarIndex = subviews?.firstIndex(where: { $0.subviews.isEmpty }) {
374
374
  if let emptyStatusBar = subviews?[emptyStatusBarIndex] {
@@ -494,6 +494,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
494
494
  self.navigationWebViewController?.navigationBar.setValue(true, forKey: "hidesShadow")
495
495
  self.navigationWebViewController?.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
496
496
 
497
+ // Handle web view background color
498
+ webViewController.view.backgroundColor = backgroundColor
499
+
497
500
  // Handle toolbar color
498
501
  if let toolbarColor = call.getString("toolbarColor"), self.isHexColorCode(toolbarColor) {
499
502
  // If specific color provided, use it
@@ -692,7 +695,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
692
695
  return
693
696
  }
694
697
 
695
- if (self.bridge?.statusBarVisible == true) {
698
+ if self.bridge?.statusBarVisible == true {
696
699
  let subviews = self.bridge?.webView?.superview?.subviews
697
700
  if let emptyStatusBarIndex = subviews?.firstIndex(where: { $0.subviews.isEmpty }) {
698
701
  if let emptyStatusBar = subviews?[emptyStatusBarIndex] {
@@ -277,9 +277,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
277
277
  // Check if custom image is provided
278
278
  if let image = activityBarButtonItemImage {
279
279
  let button = UIBarButtonItem(image: image.withRenderingMode(.alwaysTemplate),
280
- style: .plain,
281
- target: self,
282
- action: #selector(activityDidClick(sender:)))
280
+ style: .plain,
281
+ target: self,
282
+ action: #selector(activityDidClick(sender:)))
283
283
 
284
284
  // Apply tint from navigation bar or from tintColor property
285
285
  if let tintColor = self.tintColor ?? self.navigationController?.navigationBar.tintColor {
@@ -291,8 +291,8 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
291
291
  } else {
292
292
  // Use system share icon
293
293
  let button = UIBarButtonItem(barButtonSystemItem: .action,
294
- target: self,
295
- action: #selector(activityDidClick(sender:)))
294
+ target: self,
295
+ action: #selector(activityDidClick(sender:)))
296
296
 
297
297
  // Apply tint from navigation bar or from tintColor property
298
298
  if let tintColor = self.tintColor ?? self.navigationController?.navigationBar.tintColor {
@@ -344,6 +344,15 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
344
344
  webView?.removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
345
345
  }
346
346
 
347
+ override open func viewDidDisappear(_ animated: Bool) {
348
+ super.viewDidDisappear(animated)
349
+
350
+ if let capacitorStatusBar = capacitorStatusBar {
351
+ self.capBrowserPlugin?.bridge?.webView?.superview?.addSubview(capacitorStatusBar)
352
+ self.capBrowserPlugin?.bridge?.webView?.frame.origin.y = capacitorStatusBar.frame.height
353
+ }
354
+ }
355
+
347
356
  override open func viewDidLoad() {
348
357
  super.viewDidLoad()
349
358
  if self.webView == nil {
@@ -395,9 +404,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
395
404
 
396
405
  // Create a properly tinted button
397
406
  let buttonItem = UIBarButtonItem(image: buttonNearDoneIcon?.withRenderingMode(.alwaysTemplate),
398
- style: .plain,
399
- target: self,
400
- action: #selector(buttonNearDoneDidClick))
407
+ style: .plain,
408
+ target: self,
409
+ action: #selector(buttonNearDoneDidClick))
401
410
  buttonItem.tintColor = tintColor
402
411
 
403
412
  // Add it to right items
@@ -435,7 +444,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
435
444
  // Method to send a message from Swift to JavaScript
436
445
  open func postMessageToJS(message: [String: Any]) {
437
446
  if let jsonData = try? JSONSerialization.data(withJSONObject: message, options: []),
438
- let jsonString = String(data: jsonData, encoding: .utf8) {
447
+ let jsonString = String(data: jsonData, encoding: .utf8) {
439
448
  let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
440
449
  DispatchQueue.main.async {
441
450
  self.webView?.evaluateJavaScript(script, completionHandler: nil)
@@ -1180,10 +1189,6 @@ fileprivate extension WKWebViewController {
1180
1189
  self.capBrowserPlugin?.notifyListeners("closeEvent", data: ["url": webView?.url?.absoluteString ?? ""])
1181
1190
  dismiss(animated: true, completion: nil)
1182
1191
  }
1183
- if let capacitorStatusBar = capacitorStatusBar {
1184
- capBrowserPlugin?.bridge?.webView?.addSubview(capacitorStatusBar)
1185
- capBrowserPlugin?.bridge?.webView?.frame.origin.y = capacitorStatusBar.frame.height
1186
- }
1187
1192
  }
1188
1193
 
1189
1194
  @objc func doneDidClick(sender: AnyObject) {
@@ -1366,8 +1371,8 @@ extension WKWebViewController: WKNavigationDelegate {
1366
1371
 
1367
1372
  public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
1368
1373
  if let credentials = credentials,
1369
- challenge.protectionSpace.receivesCredentialSecurely,
1370
- let url = webView.url, challenge.protectionSpace.host == url.host, challenge.protectionSpace.protocol == url.scheme, challenge.protectionSpace.port == url.port ?? (url.scheme == "https" ? 443 : url.scheme == "http" ? 80 : nil) {
1374
+ challenge.protectionSpace.receivesCredentialSecurely,
1375
+ let url = webView.url, challenge.protectionSpace.host == url.host, challenge.protectionSpace.protocol == url.scheme, challenge.protectionSpace.port == url.port ?? (url.scheme == "https" ? 443 : url.scheme == "http" ? 80 : nil) {
1371
1376
  let urlCredential = URLCredential(user: credentials.username, password: credentials.password, persistence: .none)
1372
1377
  completionHandler(.useCredential, urlCredential)
1373
1378
  } else if let bypassedSSLHosts = bypassedSSLHosts, bypassedSSLHosts.contains(challenge.protectionSpace.host) {
@@ -1379,8 +1384,8 @@ extension WKWebViewController: WKNavigationDelegate {
1379
1384
  return
1380
1385
  }
1381
1386
  /* allows to open links with self-signed certificates
1382
- Follow Apple's guidelines https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication
1383
- */
1387
+ Follow Apple's guidelines https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication
1388
+ */
1384
1389
  guard let serverTrust = challenge.protectionSpace.serverTrust else {
1385
1390
  completionHandler(.useCredential, nil)
1386
1391
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.6.9",
3
+ "version": "7.6.12",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",