@capgo/inappbrowser 7.6.8 → 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,6 +368,16 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
368
368
  return
369
369
  }
370
370
 
371
+ if self.bridge?.statusBarVisible == true {
372
+ let subviews = self.bridge?.webView?.superview?.subviews
373
+ if let emptyStatusBarIndex = subviews?.firstIndex(where: { $0.subviews.isEmpty }) {
374
+ if let emptyStatusBar = subviews?[emptyStatusBarIndex] {
375
+ webViewController.capacitorStatusBar = emptyStatusBar
376
+ emptyStatusBar.removeFromSuperview()
377
+ }
378
+ }
379
+ }
380
+
371
381
  webViewController.source = .remote(url)
372
382
  webViewController.leftNavigationBarItemTypes = []
373
383
 
@@ -484,6 +494,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
484
494
  self.navigationWebViewController?.navigationBar.setValue(true, forKey: "hidesShadow")
485
495
  self.navigationWebViewController?.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
486
496
 
497
+ // Handle web view background color
498
+ webViewController.view.backgroundColor = backgroundColor
499
+
487
500
  // Handle toolbar color
488
501
  if let toolbarColor = call.getString("toolbarColor"), self.isHexColorCode(toolbarColor) {
489
502
  // If specific color provided, use it
@@ -682,6 +695,16 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
682
695
  return
683
696
  }
684
697
 
698
+ if self.bridge?.statusBarVisible == true {
699
+ let subviews = self.bridge?.webView?.superview?.subviews
700
+ if let emptyStatusBarIndex = subviews?.firstIndex(where: { $0.subviews.isEmpty }) {
701
+ if let emptyStatusBar = subviews?[emptyStatusBarIndex] {
702
+ webViewController.capacitorStatusBar = emptyStatusBar
703
+ emptyStatusBar.removeFromSuperview()
704
+ }
705
+ }
706
+ }
707
+
685
708
  webViewController.source = .remote(url)
686
709
  webViewController.leftNavigationBarItemTypes = [.back, .forward, .reload]
687
710
  webViewController.capBrowserPlugin = self
@@ -112,6 +112,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
112
112
  var viewWasPresented = false
113
113
  var preventDeeplink: Bool = false
114
114
  var blankNavigationTab: Bool = false
115
+ var capacitorStatusBar: UIView?
115
116
 
116
117
  internal var preShowSemaphore: DispatchSemaphore?
117
118
  internal var preShowError: String?
@@ -276,9 +277,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
276
277
  // Check if custom image is provided
277
278
  if let image = activityBarButtonItemImage {
278
279
  let button = UIBarButtonItem(image: image.withRenderingMode(.alwaysTemplate),
279
- style: .plain,
280
- target: self,
281
- action: #selector(activityDidClick(sender:)))
280
+ style: .plain,
281
+ target: self,
282
+ action: #selector(activityDidClick(sender:)))
282
283
 
283
284
  // Apply tint from navigation bar or from tintColor property
284
285
  if let tintColor = self.tintColor ?? self.navigationController?.navigationBar.tintColor {
@@ -290,8 +291,8 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
290
291
  } else {
291
292
  // Use system share icon
292
293
  let button = UIBarButtonItem(barButtonSystemItem: .action,
293
- target: self,
294
- action: #selector(activityDidClick(sender:)))
294
+ target: self,
295
+ action: #selector(activityDidClick(sender:)))
295
296
 
296
297
  // Apply tint from navigation bar or from tintColor property
297
298
  if let tintColor = self.tintColor ?? self.navigationController?.navigationBar.tintColor {
@@ -343,6 +344,15 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
343
344
  webView?.removeObserver(self, forKeyPath: #keyPath(WKWebView.url))
344
345
  }
345
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
+
346
356
  override open func viewDidLoad() {
347
357
  super.viewDidLoad()
348
358
  if self.webView == nil {
@@ -394,9 +404,9 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
394
404
 
395
405
  // Create a properly tinted button
396
406
  let buttonItem = UIBarButtonItem(image: buttonNearDoneIcon?.withRenderingMode(.alwaysTemplate),
397
- style: .plain,
398
- target: self,
399
- action: #selector(buttonNearDoneDidClick))
407
+ style: .plain,
408
+ target: self,
409
+ action: #selector(buttonNearDoneDidClick))
400
410
  buttonItem.tintColor = tintColor
401
411
 
402
412
  // Add it to right items
@@ -434,7 +444,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
434
444
  // Method to send a message from Swift to JavaScript
435
445
  open func postMessageToJS(message: [String: Any]) {
436
446
  if let jsonData = try? JSONSerialization.data(withJSONObject: message, options: []),
437
- let jsonString = String(data: jsonData, encoding: .utf8) {
447
+ let jsonString = String(data: jsonData, encoding: .utf8) {
438
448
  let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
439
449
  DispatchQueue.main.async {
440
450
  self.webView?.evaluateJavaScript(script, completionHandler: nil)
@@ -1361,8 +1371,8 @@ extension WKWebViewController: WKNavigationDelegate {
1361
1371
 
1362
1372
  public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
1363
1373
  if let credentials = credentials,
1364
- challenge.protectionSpace.receivesCredentialSecurely,
1365
- 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) {
1366
1376
  let urlCredential = URLCredential(user: credentials.username, password: credentials.password, persistence: .none)
1367
1377
  completionHandler(.useCredential, urlCredential)
1368
1378
  } else if let bypassedSSLHosts = bypassedSSLHosts, bypassedSSLHosts.contains(challenge.protectionSpace.host) {
@@ -1374,8 +1384,8 @@ extension WKWebViewController: WKNavigationDelegate {
1374
1384
  return
1375
1385
  }
1376
1386
  /* allows to open links with self-signed certificates
1377
- Follow Apple's guidelines https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication
1378
- */
1387
+ Follow Apple's guidelines https://developer.apple.com/documentation/foundation/url_loading_system/handling_an_authentication_challenge/performing_manual_server_trust_authentication
1388
+ */
1379
1389
  guard let serverTrust = challenge.protectionSpace.serverTrust else {
1380
1390
  completionHandler(.useCredential, nil)
1381
1391
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.6.8",
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",