refactor(navigation): Simplify adaptive back nav and state#3860
Conversation
…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>
There was a problem hiding this comment.
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
BackHandlerimplementations withBackNavigationBehavior.PopUntilScaffoldValueChangefor streamlined back navigation - Removed the redundant
navigateToMessagescallback fromMessageScreenas 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
NodeDetailScreenAPI by makingnodeIda 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.
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Codecov Report❌ Patch coverage is 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. |
|
Hi! |
This refactors the adaptive list-detail screens for Contacts and Nodes to simplify navigation logic and improve state management.
BackHandlerimplementations withBackNavigationBehavior.PopUntilScaffoldValueChangefrom Material 3 Adaptive Navigation. This streamlines back navigation, ensuring a consistent user experience.navigateToMessagescallback fromMessageScreenas it was redundant in the list-detail layout, simplifying the composable's API.key(id)around the detail pane content in bothAdaptiveContactsScreenandAdaptiveNodeListScreen. This ensures that composables likeMessageScreenandNodeDetailScreenare correctly recomposed with fresh state when the selected item changes.overrideNodeIdfromNodeDetailScreenand the now-unusedNodeDetailScreenWrapper, making thenodeIda direct, non-nullable parameter. TheLaunchedEffectnow directly observes thisnodeId.