mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: enhance map navigation and waypoint handling (#4814)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
802aa09aab
commit
5edb8abd05
15 changed files with 95 additions and 16 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() })
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue