Skip to content

refactor(navigation): Simplify adaptive back nav and state#3860

Merged
jamesarich merged 2 commits into
mainfrom
fix/list-detail
Nov 30, 2025
Merged

refactor(navigation): Simplify adaptive back nav and state#3860
jamesarich merged 2 commits into
mainfrom
fix/list-detail

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

This refactors the adaptive list-detail screens for Contacts and Nodes to simplify navigation logic and improve state management.

  • Replaced manual BackHandler implementations with BackNavigationBehavior.PopUntilScaffoldValueChange from Material 3 Adaptive Navigation. This streamlines back navigation, ensuring a consistent user experience.
  • Removed the navigateToMessages callback from MessageScreen as it was redundant in the list-detail layout, simplifying the composable's API.
  • Introduced key(id) around the detail pane content in both AdaptiveContactsScreen and AdaptiveNodeListScreen. This ensures that composables like MessageScreen and NodeDetailScreen are correctly recomposed with fresh state when the selected item changes.
  • Eliminated overrideNodeId from NodeDetailScreen and the now-unused NodeDetailScreenWrapper, making the nodeId a direct, non-nullable parameter. The LaunchedEffect now directly observes this nodeId.

…ate handling

This commit refactors the adaptive list-detail screens for Contacts and Nodes to simplify navigation logic and improve state management.

- Replaced manual `BackHandler` implementations with `BackNavigationBehavior.PopUntilScaffoldValueChange` from Material 3 Adaptive Navigation. This streamlines back navigation, ensuring a consistent user experience.
- Removed the `navigateToMessages` callback from `MessageScreen` as it was redundant in the list-detail layout, simplifying the composable's API.
- Introduced `key(id)` around the detail pane content in both `AdaptiveContactsScreen` and `AdaptiveNodeListScreen`. This ensures that composables like `MessageScreen` and `NodeDetailScreen` are correctly recomposed with fresh state when the selected item changes.
- Eliminated `overrideNodeId` from `NodeDetailScreen` and the now-unused `NodeDetailScreenWrapper`, making the `nodeId` a direct, non-nullable parameter. The `LaunchedEffect` now directly observes this `nodeId`.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the adaptive list-detail screens for Contacts and Nodes to simplify navigation logic and improve state management by leveraging Material 3 Adaptive Navigation APIs.

  • Replaced manual BackHandler implementations with BackNavigationBehavior.PopUntilScaffoldValueChange for streamlined back navigation
  • Removed the redundant navigateToMessages callback from MessageScreen as navigation is now handled by the parent adaptive layout
  • Added key() blocks around detail pane content to ensure proper recomposition when selected items change
  • Simplified NodeDetailScreen API by making nodeId a required non-nullable parameter and eliminating the wrapper composable

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
app/src/main/java/com/geeksville/mesh/ui/node/AdaptiveNodeListScreen.kt Replaced manual back handling with Material 3 Adaptive's BackNavigationBehavior, added key() around NodeDetailScreen, and removed NodeDetailScreenWrapper in favor of direct usage
app/src/main/java/com/geeksville/mesh/ui/contact/AdaptiveContactsScreen.kt Replaced manual back handling with BackNavigationBehavior, added key() around MessageScreen, and removed the navigateToMessages parameter since navigation is handled by the parent
feature/node/src/main/kotlin/org/meshtastic/feature/node/detail/NodeDetailScreen.kt Made nodeId a required non-nullable parameter and simplified the LaunchedEffect by removing the conditional overrideNodeId logic
feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/Message.kt Removed the navigateToMessages parameter as it's no longer needed in the adaptive layout context
feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageScreenEvent.kt Removed the unused NavigateToMessages event as navigation between message threads is now handled by the adaptive scaffold

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread app/src/main/java/com/geeksville/mesh/ui/contact/AdaptiveContactsScreen.kt Outdated
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@jamesarich jamesarich added this pull request to the merge queue Nov 30, 2025
Merged via the queue into main with commit ebab2ee Nov 30, 2025
5 checks passed
@jamesarich jamesarich deleted the fix/list-detail branch November 30, 2025 01:35
@codecov

codecov Bot commented Nov 30, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.53%. Comparing base (1d17f40) to head (7065c86).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...eksville/mesh/ui/contact/AdaptiveContactsScreen.kt 0.00% 10 Missing ⚠️
.../geeksville/mesh/ui/node/AdaptiveNodeListScreen.kt 0.00% 10 Missing ⚠️
...meshtastic/feature/node/detail/NodeDetailScreen.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3860   +/-   ##
=====================================
  Coverage   0.53%   0.53%           
=====================================
  Files        390     390           
  Lines      22850   22827   -23     
  Branches    2889    2880    -9     
=====================================
  Hits         122     122           
+ Misses     22707   22684   -23     
  Partials      21      21           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jschollenberger

Copy link
Copy Markdown

Hi!
I just updated to v2.7.8 (29319501). When I am viewing the details of a node then "swipe back" to go back to the node list, the app closes. When viewing a conversation, swiping back takes me to the nodes page. It's driving me crazy! Was that the intent of the change here, or is this a bug? I'm guessing this is the PR which changed that behavior.
Thanks!

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

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants