@capgo/capacitor-native-navigation 8.2.6 → 8.2.8
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.
|
@@ -85,12 +85,31 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
override public func load() {
|
|
88
|
-
NotificationCenter.default
|
|
88
|
+
let center = NotificationCenter.default
|
|
89
|
+
center.addObserver(
|
|
89
90
|
self,
|
|
90
91
|
selector: #selector(handleLayoutChange),
|
|
91
92
|
name: UIDevice.orientationDidChangeNotification,
|
|
92
93
|
object: nil
|
|
93
94
|
)
|
|
95
|
+
center.addObserver(
|
|
96
|
+
self,
|
|
97
|
+
selector: #selector(handleKeyboardFrameChange),
|
|
98
|
+
name: UIResponder.keyboardWillChangeFrameNotification,
|
|
99
|
+
object: nil
|
|
100
|
+
)
|
|
101
|
+
center.addObserver(
|
|
102
|
+
self,
|
|
103
|
+
selector: #selector(handleKeyboardDidHide),
|
|
104
|
+
name: UIResponder.keyboardDidHideNotification,
|
|
105
|
+
object: nil
|
|
106
|
+
)
|
|
107
|
+
center.addObserver(
|
|
108
|
+
self,
|
|
109
|
+
selector: #selector(handleReduceTransparencyChange),
|
|
110
|
+
name: UIAccessibility.reduceTransparencyStatusDidChangeNotification,
|
|
111
|
+
object: nil
|
|
112
|
+
)
|
|
94
113
|
}
|
|
95
114
|
|
|
96
115
|
deinit {
|
|
@@ -212,8 +231,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
212
231
|
self.applyTabBarAppearance(tabBar: tabBar, options: call)
|
|
213
232
|
if items.isEmpty {
|
|
214
233
|
self.tabbarVisible = false
|
|
215
|
-
self.
|
|
216
|
-
self.tabBarController?.view.isHidden = true
|
|
234
|
+
self.hideSystemTabBarChromeCompletely()
|
|
217
235
|
} else {
|
|
218
236
|
self.showTabBarChrome(tabBar)
|
|
219
237
|
}
|
|
@@ -554,6 +572,68 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
554
572
|
}
|
|
555
573
|
}
|
|
556
574
|
|
|
575
|
+
@objc private func handleKeyboardFrameChange() {
|
|
576
|
+
DispatchQueue.main.async {
|
|
577
|
+
self.layoutChrome()
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
@objc private func handleKeyboardDidHide() {
|
|
582
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
|
583
|
+
self.refreshChromeAfterKeyboardDismiss()
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
@objc private func handleReduceTransparencyChange() {
|
|
588
|
+
DispatchQueue.main.async {
|
|
589
|
+
self.refreshTabBarBackgroundIfNeeded()
|
|
590
|
+
self.layoutChrome()
|
|
591
|
+
self.updateInsetsAndNotify()
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
private func refreshChromeAfterKeyboardDismiss() {
|
|
596
|
+
layoutChrome()
|
|
597
|
+
refreshTabBarBackgroundIfNeeded()
|
|
598
|
+
updateInsetsAndNotify()
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
private func refreshTabBarBackgroundIfNeeded() {
|
|
602
|
+
guard tabbarVisible else {
|
|
603
|
+
return
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
tabBarController?.view.setNeedsLayout()
|
|
607
|
+
tabBarController?.view.layoutIfNeeded()
|
|
608
|
+
|
|
609
|
+
if let tabBar = tabBar {
|
|
610
|
+
tabBar.isTranslucent = !prefersOpaqueTabBarBackground()
|
|
611
|
+
let standardAppearance = tabBar.standardAppearance
|
|
612
|
+
tabBar.standardAppearance = standardAppearance
|
|
613
|
+
if #available(iOS 15.0, *) {
|
|
614
|
+
let scrollEdgeAppearance = tabBar.scrollEdgeAppearance ?? standardAppearance
|
|
615
|
+
tabBar.scrollEdgeAppearance = scrollEdgeAppearance
|
|
616
|
+
}
|
|
617
|
+
tabBar.items?.forEach { item in
|
|
618
|
+
item.standardAppearance = standardAppearance
|
|
619
|
+
if #available(iOS 15.0, *) {
|
|
620
|
+
item.scrollEdgeAppearance = tabBar.scrollEdgeAppearance
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
tabBar.setNeedsLayout()
|
|
624
|
+
tabBar.layoutIfNeeded()
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
tabContainer?.setNeedsLayout()
|
|
628
|
+
tabContainer?.layoutIfNeeded()
|
|
629
|
+
floatingTabBar?.setNeedsLayout()
|
|
630
|
+
floatingTabBar?.layoutIfNeeded()
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
private func prefersOpaqueTabBarBackground() -> Bool {
|
|
634
|
+
UIAccessibility.isReduceTransparencyEnabled
|
|
635
|
+
}
|
|
636
|
+
|
|
557
637
|
private func ensureNavBar() -> UINavigationBar {
|
|
558
638
|
if let navBar = navBar {
|
|
559
639
|
return navBar
|
|
@@ -790,21 +870,46 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
790
870
|
return
|
|
791
871
|
}
|
|
792
872
|
|
|
873
|
+
let tabBar = tabBarController.tabBar
|
|
793
874
|
if #available(iOS 18.0, *) {
|
|
794
875
|
tabBarController.setTabBarHidden(hidden, animated: false)
|
|
795
876
|
} else {
|
|
796
|
-
|
|
877
|
+
tabBar.isHidden = hidden
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
if hidden {
|
|
881
|
+
setTabBarBackgroundSubviewsHidden(true, on: tabBar)
|
|
882
|
+
} else {
|
|
883
|
+
setTabBarBackgroundSubviewsHidden(false, on: tabBar)
|
|
884
|
+
tabBar.setNeedsLayout()
|
|
885
|
+
tabBar.layoutIfNeeded()
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
private func setTabBarBackgroundSubviewsHidden(_ hidden: Bool, on tabBar: UITabBar) {
|
|
890
|
+
tabBar.isHidden = hidden
|
|
891
|
+
tabBar.alpha = hidden ? 0 : 1
|
|
892
|
+
tabBar.isUserInteractionEnabled = !hidden
|
|
893
|
+
tabBar.subviews.forEach { subview in
|
|
894
|
+
subview.isHidden = hidden
|
|
895
|
+
subview.alpha = hidden ? 0 : 1
|
|
797
896
|
}
|
|
798
897
|
}
|
|
799
898
|
|
|
899
|
+
private func hideSystemTabBarChromeCompletely() {
|
|
900
|
+
applySystemTabBarItems([], selectedIndex: nil, animated: false)
|
|
901
|
+
setSystemTabBarHidden(true)
|
|
902
|
+
tabBarController?.view.isHidden = true
|
|
903
|
+
tabContainer?.isHidden = true
|
|
904
|
+
floatingTabBar?.isHidden = true
|
|
905
|
+
}
|
|
906
|
+
|
|
800
907
|
private func hideTabBarChrome() {
|
|
801
908
|
if usesSystemLiquidGlass && tabbarStyle.shape != .curve {
|
|
802
|
-
|
|
803
|
-
tabBarController?.view.isHidden = false
|
|
804
|
-
hostWebViewInSelectedSystemTab()
|
|
909
|
+
hideSystemTabBarChromeCompletely()
|
|
805
910
|
} else {
|
|
806
|
-
|
|
807
|
-
|
|
911
|
+
restoreWebViewFromSystemTabController()
|
|
912
|
+
hideSystemTabBarChromeCompletely()
|
|
808
913
|
tabBar?.isHidden = true
|
|
809
914
|
}
|
|
810
915
|
}
|
|
@@ -1314,6 +1419,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
1314
1419
|
applyTabBarColorOptions(scrollEdgeAppearance, tabBar: tabBar, options: call)
|
|
1315
1420
|
applyTabBarBadgeOptions(scrollEdgeAppearance, options: call)
|
|
1316
1421
|
|
|
1422
|
+
tabBar.isTranslucent = !prefersOpaqueTabBarBackground()
|
|
1317
1423
|
tabBar.standardAppearance = standardAppearance
|
|
1318
1424
|
if #available(iOS 15.0, *) {
|
|
1319
1425
|
tabBar.scrollEdgeAppearance = scrollEdgeAppearance
|
|
@@ -1341,6 +1447,10 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
1341
1447
|
|
|
1342
1448
|
private func configureTabBarBackground(_ appearance: UITabBarAppearance, options call: CAPPluginCall) {
|
|
1343
1449
|
appearance.configureWithDefaultBackground()
|
|
1450
|
+
if prefersOpaqueTabBarBackground() {
|
|
1451
|
+
tabEffectView?.isHidden = true
|
|
1452
|
+
return
|
|
1453
|
+
}
|
|
1344
1454
|
if let effect = blurEffect(from: call.getString("blurEffect"), fallback: nil) {
|
|
1345
1455
|
appearance.configureWithTransparentBackground()
|
|
1346
1456
|
appearance.backgroundColor = .clear
|
|
@@ -1356,7 +1466,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
1356
1466
|
}
|
|
1357
1467
|
|
|
1358
1468
|
private func configureSystemTabBarScrollEdgeBackground(_ appearance: UITabBarAppearance, options call: CAPPluginCall) {
|
|
1359
|
-
if call.getBool("disableTransparentOnScrollEdge", false) {
|
|
1469
|
+
if call.getBool("disableTransparentOnScrollEdge", false) || prefersOpaqueTabBarBackground() {
|
|
1360
1470
|
configureSystemTabBarStandardBackground(appearance)
|
|
1361
1471
|
} else {
|
|
1362
1472
|
appearance.configureWithTransparentBackground()
|
|
@@ -1409,7 +1519,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
1409
1519
|
let backgroundTint = colorValue(colors?["background"])
|
|
1410
1520
|
let backgroundColor = (backgroundTint ?? .systemBackground).withAlphaComponent(tabbarStyle.shape == .curve ? 0.96 : 0.46)
|
|
1411
1521
|
|
|
1412
|
-
if tabbarStyle.shape == .curve {
|
|
1522
|
+
if tabbarStyle.shape == .curve || prefersOpaqueTabBarBackground() {
|
|
1413
1523
|
tabEffectView?.isHidden = true
|
|
1414
1524
|
} else if let effect = blurEffect(from: call.getString("blurEffect"), fallback: .systemChromeMaterial) {
|
|
1415
1525
|
tabEffectView?.effect = effect
|
|
@@ -1419,7 +1529,8 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
1419
1529
|
tabEffectView?.isHidden = true
|
|
1420
1530
|
}
|
|
1421
1531
|
|
|
1422
|
-
|
|
1532
|
+
let opaqueBackground = backgroundTint ?? .systemBackground
|
|
1533
|
+
tabBar.backgroundFillColor = prefersOpaqueTabBarBackground() ? opaqueBackground : backgroundColor
|
|
1423
1534
|
if let color = colorValue(colors?["tint"]) {
|
|
1424
1535
|
tabBar.selectedTintColor = color
|
|
1425
1536
|
}
|
|
@@ -1598,6 +1709,11 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
|
|
|
1598
1709
|
let width = rootView.bounds.width
|
|
1599
1710
|
let height = rootView.bounds.height
|
|
1600
1711
|
|
|
1712
|
+
if let container = systemTabRootContainer {
|
|
1713
|
+
container.frame = rootView.bounds
|
|
1714
|
+
webView?.frame = container.bounds
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1601
1717
|
if let container = navContainer {
|
|
1602
1718
|
container.frame = CGRect(x: 0, y: 0, width: width, height: safeInsets.top + navbarHeight)
|
|
1603
1719
|
navBlurView?.frame = container.bounds
|
|
@@ -2344,7 +2460,7 @@ final class NativeNavigationTabController: UITabBarController {
|
|
|
2344
2460
|
super.viewDidLoad()
|
|
2345
2461
|
view.backgroundColor = .systemBackground
|
|
2346
2462
|
view.isOpaque = true
|
|
2347
|
-
tabBar.isTranslucent =
|
|
2463
|
+
tabBar.isTranslucent = !UIAccessibility.isReduceTransparencyEnabled
|
|
2348
2464
|
}
|
|
2349
2465
|
}
|
|
2350
2466
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-native-navigation",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.8",
|
|
4
4
|
"description": "Capacitor plugin for native navbar, tabbar, safe-area handling, and WebView snapshot transitions.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|