@capgo/capacitor-inappbrowser 8.7.0-beta.pr596.340.1 → 8.7.0-beta.pr598.346.1

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.
@@ -190,16 +190,11 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
190
190
  }
191
191
  }
192
192
 
193
- private func dismissNavigationControllerIfPresented(_ navigationController: UINavigationController?, completion: (() -> Void)? = nil) {
194
- guard let navigationController else {
195
- completion?()
196
- return
197
- }
198
- guard navigationController.presentingViewController != nil else {
199
- completion?()
193
+ private func dismissNavigationControllerIfPresented(_ navigationController: UINavigationController?) {
194
+ guard let navigationController, navigationController.presentingViewController != nil else {
200
195
  return
201
196
  }
202
- navigationController.dismiss(animated: false, completion: completion)
197
+ navigationController.dismiss(animated: false)
203
198
  }
204
199
 
205
200
  private func unregisterWebView(id: String) {
@@ -451,6 +446,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
451
446
  }
452
447
 
453
448
  dismissActiveKeyboard()
449
+ dismissNavigationControllerIfPresented(navigationController)
454
450
  navigationController.view.removeFromSuperview()
455
451
  if transparentBackground {
456
452
  makeHostWebViewTransparent(for: id)
@@ -1606,16 +1602,14 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
1606
1602
  }
1607
1603
 
1608
1604
  let transparentBackground = call.getBool("transparentBackground", true)
1609
- self.dismissNavigationControllerIfPresented(navigationController) {
1610
- webViewController.isLayeredBehind = true
1611
- webViewController.transparentHostBackground = transparentBackground
1612
- guard self.sendNavigationControllerToBack(id: resolvedId, transparentBackground: transparentBackground) else {
1613
- call.reject("Failed to send webview to back")
1614
- return
1615
- }
1616
- self.setActiveWebView(id: resolvedId, webView: webViewController, navigationController: navigationController)
1617
- call.resolve()
1605
+ webViewController.isLayeredBehind = true
1606
+ webViewController.transparentHostBackground = transparentBackground
1607
+ guard self.sendNavigationControllerToBack(id: resolvedId, transparentBackground: transparentBackground) else {
1608
+ call.reject("Failed to send webview to back")
1609
+ return
1618
1610
  }
1611
+ self.setActiveWebView(id: resolvedId, webView: webViewController, navigationController: navigationController)
1612
+ call.resolve()
1619
1613
  }
1620
1614
  }
1621
1615
 
@@ -756,40 +756,62 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
756
756
  return windowScene?.statusBarManager?.statusBarFrame.height ?? 0
757
757
  }
758
758
 
759
- // Make status bar background with colored view underneath
760
- open func setupStatusBarBackground(color: UIColor) {
761
- // Remove any existing status bar view
762
- statusBarBackgroundView?.removeFromSuperview()
759
+ private func applyNavigationBarBackground(color: UIColor) {
760
+ guard let navigationBar = navigationController?.navigationBar else {
761
+ return
762
+ }
763
763
 
764
- // Create a new view to cover both status bar and navigation bar
765
- statusBarBackgroundView = UIView()
764
+ navigationBar.backgroundColor = color
765
+ navigationBar.barTintColor = color
766
+ navigationBar.isTranslucent = false
767
+ navigationBar.setBackgroundImage(UIImage(), for: .default)
768
+ navigationBar.shadowImage = UIImage()
769
+ navigationBar.setValue(true, forKey: "hidesShadow")
766
770
 
767
- if let navView = navigationController?.view {
768
- // Add to back of view hierarchy
769
- navView.insertSubview(statusBarBackgroundView!, at: 0)
770
- statusBarBackgroundView?.translatesAutoresizingMaskIntoConstraints = false
771
+ if #available(iOS 13.0, *) {
772
+ let appearance = UINavigationBarAppearance()
773
+ appearance.configureWithOpaqueBackground()
774
+ appearance.backgroundColor = color
775
+ appearance.backgroundEffect = nil
776
+ appearance.shadowColor = .clear
777
+ appearance.shadowImage = UIImage()
771
778
 
772
- // Calculate total height - status bar + navigation bar
773
- let navBarHeight = navigationController?.navigationBar.frame.height ?? 44
774
- let totalHeight = (navigationController?.view.safeAreaInsets.top ?? CGFloat(0)) + navBarHeight
779
+ if let titleTextAttributes = navigationBar.titleTextAttributes {
780
+ appearance.titleTextAttributes = titleTextAttributes
781
+ }
782
+ if let largeTitleTextAttributes = navigationBar.largeTitleTextAttributes {
783
+ appearance.largeTitleTextAttributes = largeTitleTextAttributes
784
+ }
775
785
 
776
- // Position from top of screen to bottom of navigation bar
777
- NSLayoutConstraint.activate([
778
- statusBarBackgroundView!.topAnchor.constraint(equalTo: navView.topAnchor),
779
- statusBarBackgroundView!.leadingAnchor.constraint(equalTo: navView.leadingAnchor),
780
- statusBarBackgroundView!.trailingAnchor.constraint(equalTo: navView.trailingAnchor),
781
- statusBarBackgroundView!.heightAnchor.constraint(equalToConstant: totalHeight)
782
- ])
786
+ navigationBar.standardAppearance = appearance
787
+ navigationBar.compactAppearance = appearance
788
+ navigationBar.scrollEdgeAppearance = appearance
789
+ navigationBar.compactScrollEdgeAppearance = appearance
790
+ }
791
+ }
783
792
 
784
- // Set background color
785
- statusBarBackgroundView?.backgroundColor = color
793
+ // Make status bar background with colored view underneath
794
+ open func setupStatusBarBackground(color: UIColor) {
795
+ statusBarBackgroundView?.removeFromSuperview()
796
+ statusBarBackgroundView = UIView()
786
797
 
787
- // Make navigation bar transparent to show our view underneath
788
- navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
789
- navigationController?.navigationBar.shadowImage = UIImage()
790
- navigationController?.navigationBar.isTranslucent = true
791
- navigationController?.navigationBar.isTranslucent = true
798
+ guard let navController = navigationController,
799
+ let navView = navController.view,
800
+ let statusBarBackgroundView else {
801
+ return
792
802
  }
803
+ navView.insertSubview(statusBarBackgroundView, at: 0)
804
+ statusBarBackgroundView.translatesAutoresizingMaskIntoConstraints = false
805
+ statusBarBackgroundView.backgroundColor = color
806
+
807
+ NSLayoutConstraint.activate([
808
+ statusBarBackgroundView.topAnchor.constraint(equalTo: navView.topAnchor),
809
+ statusBarBackgroundView.leadingAnchor.constraint(equalTo: navView.leadingAnchor),
810
+ statusBarBackgroundView.trailingAnchor.constraint(equalTo: navView.trailingAnchor),
811
+ statusBarBackgroundView.bottomAnchor.constraint(equalTo: navController.navigationBar.bottomAnchor, constant: 1)
812
+ ])
813
+
814
+ applyNavigationBarBackground(color: color)
793
815
  }
794
816
 
795
817
  // Override to use our custom status bar style
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-inappbrowser",
3
- "version": "8.7.0-beta.pr596.340.1",
3
+ "version": "8.7.0-beta.pr598.346.1",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",