@capgo/capacitor-native-navigation 8.4.3 → 8.4.5

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.
@@ -112,7 +112,10 @@ public class NativeNavigationPlugin extends Plugin {
112
112
  public void load() {
113
113
  Activity activity = getActivity();
114
114
  if (activity != null) {
115
- activity.runOnUiThread(this::enableEdgeToEdge);
115
+ activity.runOnUiThread(() -> {
116
+ enableEdgeToEdge();
117
+ watchContentRootBounds();
118
+ });
116
119
  }
117
120
  }
118
121
 
@@ -1852,7 +1855,9 @@ public class NativeNavigationPlugin extends Plugin {
1852
1855
  }
1853
1856
 
1854
1857
  if (tabbarBackdrop != null) {
1855
- int backdropHeight = tabbarVisible ? bottom + dp(tabbarStyle.bottomGap) : 0;
1858
+ // Only the edge-to-edge curve bar extends its surface under the gesture area. A floating
1859
+ // tabbar must leave the page visible below it, or it sits on a solid band.
1860
+ int backdropHeight = tabbarVisible && tabbarStyle.isCurve() ? bottom + dp(tabbarStyle.bottomGap) : 0;
1856
1861
  FrameLayout.LayoutParams backdropParams = new FrameLayout.LayoutParams(
1857
1862
  ViewGroup.LayoutParams.MATCH_PARENT,
1858
1863
  backdropHeight,
@@ -2060,7 +2065,21 @@ public class NativeNavigationPlugin extends Plugin {
2060
2065
  }
2061
2066
  }
2062
2067
 
2068
+ /**
2069
+ * The chrome is laid out inside {@code android.R.id.content}, so it only needs to clear the part of a
2070
+ * system bar that actually overlaps that view. Capacitor's SystemBars plugin (default
2071
+ * {@code insetsHandling: 'css'} without {@code viewport-fit=cover}) pads the decor view by the system bars,
2072
+ * which already moves the content root clear of them; adding the full inset again doubled the gap.
2073
+ */
2063
2074
  private int statusBarInset() {
2075
+ return Math.max(0, rawStatusBarInset() - contentRootTopOffset());
2076
+ }
2077
+
2078
+ private int navigationBarInset() {
2079
+ return Math.max(0, rawNavigationBarInset() - contentRootBottomOffset());
2080
+ }
2081
+
2082
+ private int rawStatusBarInset() {
2064
2083
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
2065
2084
  WindowInsets insets = getActivity().getWindow().getDecorView().getRootWindowInsets();
2066
2085
  if (insets != null) {
@@ -2070,7 +2089,7 @@ public class NativeNavigationPlugin extends Plugin {
2070
2089
  return systemDimension("status_bar_height");
2071
2090
  }
2072
2091
 
2073
- private int navigationBarInset() {
2092
+ private int rawNavigationBarInset() {
2074
2093
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
2075
2094
  WindowInsets insets = getActivity().getWindow().getDecorView().getRootWindowInsets();
2076
2095
  if (insets != null) {
@@ -2080,6 +2099,45 @@ public class NativeNavigationPlugin extends Plugin {
2080
2099
  return systemDimension("navigation_bar_height");
2081
2100
  }
2082
2101
 
2102
+ private int contentRootTopOffset() {
2103
+ FrameLayout root = contentRoot();
2104
+ if (root == null || !root.isLaidOut()) {
2105
+ return 0;
2106
+ }
2107
+ int[] location = new int[2];
2108
+ root.getLocationInWindow(location);
2109
+ return Math.max(0, location[1]);
2110
+ }
2111
+
2112
+ private int contentRootBottomOffset() {
2113
+ FrameLayout root = contentRoot();
2114
+ Activity activity = getActivity();
2115
+ if (root == null || activity == null || !root.isLaidOut()) {
2116
+ return 0;
2117
+ }
2118
+ View decor = activity.getWindow().getDecorView();
2119
+ int[] location = new int[2];
2120
+ root.getLocationInWindow(location);
2121
+ return Math.max(0, decor.getHeight() - (location[1] + root.getHeight()));
2122
+ }
2123
+
2124
+ private void watchContentRootBounds() {
2125
+ FrameLayout root = contentRoot();
2126
+ if (root == null) {
2127
+ return;
2128
+ }
2129
+ // SystemBars can add or drop its decor padding after load (for example once viewport-fit=cover is
2130
+ // detected), which moves the content root without a call into this plugin. Re-run layout when it moves.
2131
+ root.addOnLayoutChangeListener((view, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
2132
+ if (top == oldTop && bottom == oldBottom && left == oldLeft && right == oldRight) {
2133
+ return;
2134
+ }
2135
+ if (navbarVisible || tabbarVisible) {
2136
+ view.post(this::updateInsetsAndNotify);
2137
+ }
2138
+ });
2139
+ }
2140
+
2083
2141
  private int systemDimension(String name) {
2084
2142
  int id = getContext().getResources().getIdentifier(name, "dimen", "android");
2085
2143
  return id == 0 ? 0 : getContext().getResources().getDimensionPixelSize(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-navigation",
3
- "version": "8.4.3",
3
+ "version": "8.4.5",
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",