@capgo/capacitor-native-navigation 8.2.6 → 8.2.7

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.addObserver(
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 {
@@ -554,6 +573,68 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
554
573
  }
555
574
  }
556
575
 
576
+ @objc private func handleKeyboardFrameChange() {
577
+ DispatchQueue.main.async {
578
+ self.layoutChrome()
579
+ }
580
+ }
581
+
582
+ @objc private func handleKeyboardDidHide() {
583
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
584
+ self.refreshChromeAfterKeyboardDismiss()
585
+ }
586
+ }
587
+
588
+ @objc private func handleReduceTransparencyChange() {
589
+ DispatchQueue.main.async {
590
+ self.refreshTabBarBackgroundIfNeeded()
591
+ self.layoutChrome()
592
+ self.updateInsetsAndNotify()
593
+ }
594
+ }
595
+
596
+ private func refreshChromeAfterKeyboardDismiss() {
597
+ layoutChrome()
598
+ refreshTabBarBackgroundIfNeeded()
599
+ updateInsetsAndNotify()
600
+ }
601
+
602
+ private func refreshTabBarBackgroundIfNeeded() {
603
+ guard tabbarVisible else {
604
+ return
605
+ }
606
+
607
+ tabBarController?.view.setNeedsLayout()
608
+ tabBarController?.view.layoutIfNeeded()
609
+
610
+ if let tabBar = tabBar {
611
+ tabBar.isTranslucent = !prefersOpaqueTabBarBackground()
612
+ let standardAppearance = tabBar.standardAppearance
613
+ tabBar.standardAppearance = standardAppearance
614
+ if #available(iOS 15.0, *) {
615
+ let scrollEdgeAppearance = tabBar.scrollEdgeAppearance ?? standardAppearance
616
+ tabBar.scrollEdgeAppearance = scrollEdgeAppearance
617
+ }
618
+ tabBar.items?.forEach { item in
619
+ item.standardAppearance = standardAppearance
620
+ if #available(iOS 15.0, *) {
621
+ item.scrollEdgeAppearance = tabBar.scrollEdgeAppearance
622
+ }
623
+ }
624
+ tabBar.setNeedsLayout()
625
+ tabBar.layoutIfNeeded()
626
+ }
627
+
628
+ tabContainer?.setNeedsLayout()
629
+ tabContainer?.layoutIfNeeded()
630
+ floatingTabBar?.setNeedsLayout()
631
+ floatingTabBar?.layoutIfNeeded()
632
+ }
633
+
634
+ private func prefersOpaqueTabBarBackground() -> Bool {
635
+ UIAccessibility.isReduceTransparencyEnabled
636
+ }
637
+
557
638
  private func ensureNavBar() -> UINavigationBar {
558
639
  if let navBar = navBar {
559
640
  return navBar
@@ -1314,6 +1395,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
1314
1395
  applyTabBarColorOptions(scrollEdgeAppearance, tabBar: tabBar, options: call)
1315
1396
  applyTabBarBadgeOptions(scrollEdgeAppearance, options: call)
1316
1397
 
1398
+ tabBar.isTranslucent = !prefersOpaqueTabBarBackground()
1317
1399
  tabBar.standardAppearance = standardAppearance
1318
1400
  if #available(iOS 15.0, *) {
1319
1401
  tabBar.scrollEdgeAppearance = scrollEdgeAppearance
@@ -1341,6 +1423,10 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
1341
1423
 
1342
1424
  private func configureTabBarBackground(_ appearance: UITabBarAppearance, options call: CAPPluginCall) {
1343
1425
  appearance.configureWithDefaultBackground()
1426
+ if prefersOpaqueTabBarBackground() {
1427
+ tabEffectView?.isHidden = true
1428
+ return
1429
+ }
1344
1430
  if let effect = blurEffect(from: call.getString("blurEffect"), fallback: nil) {
1345
1431
  appearance.configureWithTransparentBackground()
1346
1432
  appearance.backgroundColor = .clear
@@ -1356,7 +1442,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
1356
1442
  }
1357
1443
 
1358
1444
  private func configureSystemTabBarScrollEdgeBackground(_ appearance: UITabBarAppearance, options call: CAPPluginCall) {
1359
- if call.getBool("disableTransparentOnScrollEdge", false) {
1445
+ if call.getBool("disableTransparentOnScrollEdge", false) || prefersOpaqueTabBarBackground() {
1360
1446
  configureSystemTabBarStandardBackground(appearance)
1361
1447
  } else {
1362
1448
  appearance.configureWithTransparentBackground()
@@ -1409,7 +1495,7 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
1409
1495
  let backgroundTint = colorValue(colors?["background"])
1410
1496
  let backgroundColor = (backgroundTint ?? .systemBackground).withAlphaComponent(tabbarStyle.shape == .curve ? 0.96 : 0.46)
1411
1497
 
1412
- if tabbarStyle.shape == .curve {
1498
+ if tabbarStyle.shape == .curve || prefersOpaqueTabBarBackground() {
1413
1499
  tabEffectView?.isHidden = true
1414
1500
  } else if let effect = blurEffect(from: call.getString("blurEffect"), fallback: .systemChromeMaterial) {
1415
1501
  tabEffectView?.effect = effect
@@ -1419,7 +1505,8 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
1419
1505
  tabEffectView?.isHidden = true
1420
1506
  }
1421
1507
 
1422
- tabBar.backgroundFillColor = backgroundColor
1508
+ let opaqueBackground = backgroundTint ?? .systemBackground
1509
+ tabBar.backgroundFillColor = prefersOpaqueTabBarBackground() ? opaqueBackground : backgroundColor
1423
1510
  if let color = colorValue(colors?["tint"]) {
1424
1511
  tabBar.selectedTintColor = color
1425
1512
  }
@@ -1598,6 +1685,11 @@ public class NativeNavigationPlugin: CAPPlugin, CAPBridgedPlugin, UITabBarContro
1598
1685
  let width = rootView.bounds.width
1599
1686
  let height = rootView.bounds.height
1600
1687
 
1688
+ if let container = systemTabRootContainer {
1689
+ container.frame = rootView.bounds
1690
+ webView?.frame = container.bounds
1691
+ }
1692
+
1601
1693
  if let container = navContainer {
1602
1694
  container.frame = CGRect(x: 0, y: 0, width: width, height: safeInsets.top + navbarHeight)
1603
1695
  navBlurView?.frame = container.bounds
@@ -2344,7 +2436,7 @@ final class NativeNavigationTabController: UITabBarController {
2344
2436
  super.viewDidLoad()
2345
2437
  view.backgroundColor = .systemBackground
2346
2438
  view.isOpaque = true
2347
- tabBar.isTranslucent = true
2439
+ tabBar.isTranslucent = !UIAccessibility.isReduceTransparencyEnabled
2348
2440
  }
2349
2441
  }
2350
2442
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-navigation",
3
- "version": "8.2.6",
3
+ "version": "8.2.7",
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",