mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Feature: Jump to node info from message (#844)
* Highlight the node in the node list tab when the user taps on the node chip in messages * Represent main tabs as enum for more reliable referencing * Extract tab labels to string resources for easier translation Annotate resource IDs with their corresponding Android types * Index off nodes actually in the adapter since they are sorted * Update viewmodel when tab changes to prevent jumping to other tabs in onResume * Mark strings as non-translatable for now
This commit is contained in:
parent
a88ffbc0fb
commit
2bfda9784f
7 changed files with 167 additions and 37 deletions
|
|
@ -27,6 +27,7 @@ import com.geeksville.mesh.database.PacketRepository
|
|||
import com.geeksville.mesh.repository.datastore.RadioConfigRepository
|
||||
import com.geeksville.mesh.repository.radio.RadioInterfaceService
|
||||
import com.geeksville.mesh.service.MeshService
|
||||
import com.geeksville.mesh.ui.MainTab
|
||||
import com.geeksville.mesh.util.positionToMeter
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
|
@ -138,6 +139,9 @@ class UIViewModel @Inject constructor(
|
|||
private val _quickChatActions = MutableStateFlow<List<QuickChatAction>>(emptyList())
|
||||
val quickChatActions: StateFlow<List<QuickChatAction>> = _quickChatActions
|
||||
|
||||
private val _focusedNode = MutableStateFlow<NodeInfo?>(null)
|
||||
val focusedNode: StateFlow<NodeInfo?> = _focusedNode
|
||||
|
||||
// hardware info about our local device (can be null)
|
||||
val myNodeInfo: StateFlow<MyNodeInfo?> get() = nodeDB.myNodeInfo
|
||||
val ourNodeInfo: StateFlow<NodeInfo?> get() = nodeDB.ourNodeInfo
|
||||
|
|
@ -584,4 +588,16 @@ class UIViewModel @Inject constructor(
|
|||
requestIds.update { it.apply { put(data.requestId, true) } }
|
||||
}
|
||||
}
|
||||
|
||||
private val _currentTab = MutableLiveData(MainTab.MESSAGES)
|
||||
val currentTab: LiveData<MainTab> get() = _currentTab
|
||||
|
||||
fun setCurrentTab(tab: MainTab) {
|
||||
_currentTab.value = tab
|
||||
}
|
||||
|
||||
fun focusUserNode(node: NodeInfo?) {
|
||||
_currentTab.value = MainTab.USERS
|
||||
_focusedNode.value = node
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue