Skip to content

android: Hide TabBar on pages with hidesBottomBarWhenPushed - #3112

Open
jjyr wants to merge 1 commit into
longbridge:mainfrom
jjyr:android-hides-bottom-bar
Open

jjyr wants to merge 1 commit into
longbridge:mainfrom
jjyr:android-hides-bottom-bar

Conversation

@jjyr

@jjyr jjyr commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Description

NavPage exposes hidesBottomBarWhenPushed as a top-level prop alongside nsh/mobile's cross-platform TabBar, but only the iOS backend implemented it. On Android, screen_config skipped hides_bottom_bar_when_pushed, leaving TabBar visible on pushed detail screens.

This brings the iOS semantics to Android:

  • Encodes c.hides_bottom_bar_when_pushed in crates/nsh-platform-android/src/encode.rs and decodes it in Mounter.screenConfig, syncing it onto ScreenBox before StackBox.reconcile() starts transitions.
  • Adds BottomBarVisibility (mirroring iOS bottom_bar::Visibility) and TabBarComponent.setNavigationHidden(hidden, animated) to slide the bar out/in cleanly while keeping Bar.onLayout bottom insets intact.
  • Updates StackBox and Mounter so TabBar stays hidden while any screen in the visible stack requests it, and background retained tab stacks cannot override the visible stack.

Pairs cleanly with #3109 (TabBar.hidden on Android), which shares BottomBarVisibility.

How to Test

  • Plain-JDK test:
    • javac -d target/java-tests crates/nsh-platform-android/java/com/longbridge/nsh/BottomBarVisibility.java crates/nsh-platform-android/tests/java/com/longbridge/nsh/BottomBarVisibilityTest.java && java -cp target/java-tests com.longbridge.nsh.BottomBarVisibilityTest (ok)
  • Android clippy & runtime build:
    • cargo xtask android --dev --abi arm64-v8a
    • cargo clippy --locked --no-deps -p nsh-platform-android --target aarch64-linux-android --all-features -- -D warnings -A clippy::missing-const-for-thread-local (and --no-default-features; flag needed only for host rustc 1.100.0-beta.5 lint in untouched notifications.rs)
  • cargo test --locked -p nsh-core (1891 unit + 2 integration + 4 doc tests passed)
  • Android API 35 emulator (emulator-5554, arm64-v8a):
    • ./target/debug/nsh test crates/nsh-platform-android/tests/hides-bottom-bar.test.tsx --target android (1 passed)
    • ./target/debug/nsh test crates/nsh-platform-android/tests/scroll-to-late.test.tsx --target android (2 passed)

NavPage's top-level `hidesBottomBarWhenPushed` prop was previously iOS-only
even though `TabBar` works on both iOS and Android: Android did not
encode `hides_bottom_bar_when_pushed` in `screen_config` or track it
in `Mounter` / `StackBox` / `TabBarComponent`.

Match UIKit / iOS semantics on Android:
- Encode `c.hides_bottom_bar_when_pushed` in `encode.rs` and read it in
  `Mounter.screenConfig`, propagating it onto `ScreenBox` before
  `StackBox.reconcile()` so pushed screens apply immediately.
- Hide the visible stack's `TabBarComponent` while any screen in the
  stack requests it, animated with stack transitions, and prevent
  hidden / background retained tab stacks from controlling the bar.
- Track navigation vs app visibility reasons independently in
  `BottomBarVisibility`, matching iOS's `bottom_bar::Visibility`.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant