@capgo/capacitor-native-navigation 8.0.13 → 8.0.15

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.
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'CapgoNativeNavigation'
6
+ s.name = 'CapgoCapacitorNativeNavigation'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.license = package['license']
package/Package.swift CHANGED
@@ -2,11 +2,11 @@
2
2
  import PackageDescription
3
3
 
4
4
  let package = Package(
5
- name: "CapgoNativeNavigation",
5
+ name: "CapgoCapacitorNativeNavigation",
6
6
  platforms: [.iOS(.v15)],
7
7
  products: [
8
8
  .library(
9
- name: "CapgoNativeNavigation",
9
+ name: "CapgoCapacitorNativeNavigation",
10
10
  targets: ["NativeNavigationPlugin"])
11
11
  ],
12
12
  dependencies: [
@@ -553,7 +553,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
553
553
 
554
554
  if let parent = bridge?.viewController {
555
555
  parent.addChild(controller)
556
- parent.view.addSubview(controller.view)
556
+ insertSystemTabControllerView(controller.view, in: parent.view)
557
557
  controller.didMove(toParent: parent)
558
558
  }
559
559
 
@@ -633,6 +633,43 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
633
633
  originalWebViewAutoresizingMask = webView.autoresizingMask
634
634
  }
635
635
 
636
+ private func insertSystemTabControllerView(_ controllerView: UIView, in parentView: UIView) {
637
+ guard let webView = webView else {
638
+ parentView.addSubview(controllerView)
639
+ return
640
+ }
641
+
642
+ captureOriginalWebViewPlacementIfNeeded(webView)
643
+ let insertionIndex = systemTabControllerInsertionIndex(in: parentView, for: webView)
644
+ parentView.insertSubview(controllerView, at: insertionIndex)
645
+ }
646
+
647
+ private func systemTabControllerInsertionIndex(in parentView: UIView, for webView: UIView) -> Int {
648
+ if let directChild = directChild(of: parentView, containing: webView),
649
+ let index = parentView.subviews.firstIndex(of: directChild) {
650
+ return min(index, parentView.subviews.count)
651
+ }
652
+
653
+ if let originalWebViewSuperview = originalWebViewSuperview,
654
+ originalWebViewSuperview === parentView {
655
+ return min(originalWebViewIndex ?? parentView.subviews.count, parentView.subviews.count)
656
+ }
657
+
658
+ return parentView.subviews.count
659
+ }
660
+
661
+ private func directChild(of ancestor: UIView, containing descendant: UIView) -> UIView? {
662
+ var current: UIView? = descendant
663
+ while let view = current, let superview = view.superview {
664
+ if superview === ancestor {
665
+ return view
666
+ }
667
+ current = superview
668
+ }
669
+
670
+ return nil
671
+ }
672
+
636
673
  private func hostWebViewInSelectedSystemTab() {
637
674
  guard usesSystemLiquidGlass,
638
675
  let webView = webView,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-navigation",
3
- "version": "8.0.13",
3
+ "version": "8.0.15",
4
4
  "description": "Capacitor plugin for native navbar, tabbar, and route transition chrome over a WebView.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -14,7 +14,7 @@
14
14
  "ios/Sources",
15
15
  "ios/Tests",
16
16
  "Package.swift",
17
- "CapgoNativeNavigation.podspec"
17
+ "CapgoCapacitorNativeNavigation.podspec"
18
18
  ],
19
19
  "author": "Martin Donadieu <martin@capgo.app>",
20
20
  "license": "MPL-2.0",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "scripts": {
37
37
  "verify": "bun run verify:ios && bun run verify:android && bun run verify:web",
38
- "verify:ios": "xcodebuild -scheme CapgoNativeNavigation -destination generic/platform=iOS",
38
+ "verify:ios": "xcodebuild -scheme CapgoCapacitorNativeNavigation -destination generic/platform=iOS",
39
39
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
40
40
  "verify:web": "bun run build",
41
41
  "lint": "bun run eslint && bun run prettier -- --check && bun run swiftlint -- lint",