feat: enhance map navigation and waypoint handling (#4814)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-03-16 08:48:00 -05:00 committed by GitHub
parent 802aa09aab
commit 5edb8abd05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 95 additions and 16 deletions

View file

@ -88,6 +88,7 @@ private fun ContactsEntryContent(
val requestChannelSet by uiViewModel.requestChannelSet.collectAsStateWithLifecycle()
val contactsViewModel = koinViewModel<ContactsViewModel>()
val messageViewModel = koinViewModel<MessageViewModel>()
initialContactKey?.let { messageViewModel.setContactKey(it) }
AdaptiveContactsScreen(
backStack = backStack,

View file

@ -26,12 +26,13 @@ import org.meshtastic.feature.map.MapScreen
import org.meshtastic.feature.map.SharedMapViewModel
fun EntryProviderScope<NavKey>.mapGraph(backStack: NavBackStack<NavKey>) {
entry<MapRoutes.Map> {
entry<MapRoutes.Map> { args ->
val viewModel = koinViewModel<SharedMapViewModel>()
MapScreen(
viewModel = viewModel,
onClickNodeChip = { backStack.add(NodesRoutes.NodeDetailGraph(it)) },
navigateToNodeDetails = { backStack.add(NodesRoutes.NodeDetailGraph(it)) },
waypointId = args.waypointId,
)
}
}

View file

@ -111,6 +111,7 @@ fun EntryProviderScope<NavKey>.nodeDetailGraph(
entry<NodeDetailRoutes.NodeMap> { args ->
val vm = koinViewModel<NodeMapViewModel>()
vm.setDestNum(args.destNum)
NodeMapScreen(vm, onNavigateUp = { backStack.removeLastOrNull() })
}

View file

@ -299,24 +299,36 @@ fun MainScreen(uIViewModel: UIViewModel = koinViewModel(), scanModel: ScannerVie
TopLevelDestination.Nodes -> {
val onNodesList = currentKey is NodesRoutes.Nodes
if (!onNodesList) {
backStack.clear()
backStack.add(destination.route)
if (backStack.isNotEmpty()) {
backStack[0] = destination.route
while (backStack.size > 1) backStack.removeAt(backStack.lastIndex)
} else {
backStack.add(destination.route)
}
}
uIViewModel.emitScrollToTopEvent(ScrollToTopEvent.NodesTabPressed)
}
TopLevelDestination.Conversations -> {
val onConversationsList = currentKey is ContactsRoutes.Contacts
if (!onConversationsList) {
backStack.clear()
backStack.add(destination.route)
if (backStack.isNotEmpty()) {
backStack[0] = destination.route
while (backStack.size > 1) backStack.removeAt(backStack.lastIndex)
} else {
backStack.add(destination.route)
}
}
uIViewModel.emitScrollToTopEvent(ScrollToTopEvent.ConversationsTabPressed)
}
else -> Unit
}
} else {
backStack.clear()
backStack.add(destination.route)
if (backStack.isNotEmpty()) {
backStack[0] = destination.route
while (backStack.size > 1) backStack.removeAt(backStack.lastIndex)
} else {
backStack.add(destination.route)
}
}
},
)

View file

@ -66,7 +66,8 @@ fun AdaptiveNodeListScreen(
val currentKey = backStack.lastOrNull()
val isNodesRoute = currentKey is NodesRoutes.Nodes || currentKey is NodesRoutes.NodesGraph
val previousKey = if (backStack.size > 1) backStack[backStack.size - 2] else null
val isFromDifferentGraph = previousKey !is NodesRoutes.NodesGraph && previousKey !is NodesRoutes.Nodes
val isFromDifferentGraph =
previousKey != null && previousKey !is NodesRoutes.NodesGraph && previousKey !is NodesRoutes.Nodes
if (isFromDifferentGraph && !isNodesRoute) {
// Navigate back via NavController to return to the previous screen