mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Added map filter + small waypoint fix (#2065)
Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
67b7ccfe06
commit
e7657c4763
3 changed files with 177 additions and 10 deletions
|
|
@ -278,6 +278,11 @@ class UIViewModel @Inject constructor(
|
|||
private val onlyOnline = MutableStateFlow(preferences.getBoolean("only-online", false))
|
||||
private val onlyDirect = MutableStateFlow(preferences.getBoolean("only-direct", false))
|
||||
|
||||
private val onlyFavorites = MutableStateFlow(preferences.getBoolean("only-favorites", false))
|
||||
private val showWaypointsOnMap = MutableStateFlow(preferences.getBoolean("show-waypoints-on-map", true))
|
||||
private val showPrecisionCircleOnMap =
|
||||
MutableStateFlow(preferences.getBoolean("show-precision-circle-on-map", true))
|
||||
|
||||
fun setSortOption(sort: NodeSortOption) {
|
||||
nodeSortOption.value = sort
|
||||
}
|
||||
|
|
@ -302,6 +307,21 @@ class UIViewModel @Inject constructor(
|
|||
preferences.edit { putBoolean("only-direct", onlyDirect.value) }
|
||||
}
|
||||
|
||||
fun setOnlyFavorites(value: Boolean) {
|
||||
onlyFavorites.value = value
|
||||
preferences.edit { putBoolean("only-favorites", onlyFavorites.value) }
|
||||
}
|
||||
|
||||
fun setShowWaypointsOnMap(value: Boolean) {
|
||||
showWaypointsOnMap.value = value
|
||||
preferences.edit { putBoolean("show-waypoints-on-map", value) }
|
||||
}
|
||||
|
||||
fun setShowPrecisionCircleOnMap(value: Boolean) {
|
||||
showPrecisionCircleOnMap.value = value
|
||||
preferences.edit { putBoolean("show-precision-circle-on-map", value) }
|
||||
}
|
||||
|
||||
data class NodeFilterState(
|
||||
val filterText: String,
|
||||
val includeUnknown: Boolean,
|
||||
|
|
@ -365,6 +385,24 @@ class UIViewModel @Inject constructor(
|
|||
initialValue = emptyList(),
|
||||
)
|
||||
|
||||
data class MapFilterState(
|
||||
val onlyFavorites: Boolean,
|
||||
val showWaypoints: Boolean,
|
||||
val showPrecisionCircle: Boolean,
|
||||
)
|
||||
|
||||
val mapFilterStateFlow: StateFlow<MapFilterState> = combine(
|
||||
onlyFavorites,
|
||||
showWaypointsOnMap,
|
||||
showPrecisionCircleOnMap,
|
||||
) { favoritesOnly, showWaypoints, showPrecisionCircle ->
|
||||
MapFilterState(favoritesOnly, showWaypoints, showPrecisionCircle)
|
||||
}.stateIn(
|
||||
scope = viewModelScope,
|
||||
started = SharingStarted.WhileSubscribed(5_000),
|
||||
initialValue = MapFilterState(false, true, true)
|
||||
)
|
||||
|
||||
// hardware info about our local device (can be null)
|
||||
val myNodeInfo: StateFlow<MyNodeEntity?> get() = nodeDB.myNodeInfo
|
||||
val ourNodeInfo: StateFlow<Node?> get() = nodeDB.ourNodeInfo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue