mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Reduces available filter list to only those that will do something. (#2278)
Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
d05485d857
commit
f1f7e32e43
5 changed files with 39 additions and 4 deletions
|
|
@ -167,6 +167,7 @@ internal fun DebugScreen(
|
|||
searchState = searchState,
|
||||
filterTexts = filterTexts,
|
||||
presetFilters = viewModel.presetFilters,
|
||||
logs = filteredLogs,
|
||||
filterMode = filterMode,
|
||||
onFilterModeChange = { filterMode = it }
|
||||
)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import androidx.compose.ui.text.input.ImeAction
|
|||
import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.geeksville.mesh.R
|
||||
import com.geeksville.mesh.model.DebugViewModel.UiMeshLog
|
||||
|
||||
@Composable
|
||||
fun DebugCustomFilterInput(
|
||||
|
|
@ -110,9 +111,17 @@ fun DebugCustomFilterInput(
|
|||
internal fun DebugPresetFilters(
|
||||
presetFilters: List<String>,
|
||||
filterTexts: List<String>,
|
||||
logs: List<UiMeshLog>,
|
||||
onFilterTextsChange: (List<String>) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val availableFilters = presetFilters.filter { filter ->
|
||||
logs.any { log ->
|
||||
log.logMessage.contains(filter, ignoreCase = true) ||
|
||||
log.messageType.contains(filter, ignoreCase = true) ||
|
||||
log.formattedReceivedDate.contains(filter, ignoreCase = true)
|
||||
}
|
||||
}
|
||||
Column(modifier = modifier) {
|
||||
Text(
|
||||
text = "Preset Filters",
|
||||
|
|
@ -126,7 +135,7 @@ internal fun DebugPresetFilters(
|
|||
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(0.dp)
|
||||
) {
|
||||
for (filter in presetFilters) {
|
||||
for (filter in availableFilters) {
|
||||
FilterChip(
|
||||
selected = filter in filterTexts,
|
||||
onClick = {
|
||||
|
|
@ -159,6 +168,7 @@ internal fun DebugFilterBar(
|
|||
customFilterText: String,
|
||||
onCustomFilterTextChange: (String) -> Unit,
|
||||
presetFilters: List<String>,
|
||||
logs: List<UiMeshLog>,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
var showFilterMenu by remember { mutableStateOf(false) }
|
||||
|
|
@ -207,6 +217,7 @@ internal fun DebugFilterBar(
|
|||
DebugPresetFilters(
|
||||
presetFilters = presetFilters,
|
||||
filterTexts = filterTexts,
|
||||
logs = logs,
|
||||
onFilterTextsChange = onFilterTextsChange
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import com.geeksville.mesh.R
|
|||
import com.geeksville.mesh.model.DebugViewModel
|
||||
import com.geeksville.mesh.model.LogSearchManager.SearchMatch
|
||||
import com.geeksville.mesh.model.LogSearchManager.SearchState
|
||||
import com.geeksville.mesh.model.DebugViewModel.UiMeshLog
|
||||
import com.geeksville.mesh.ui.common.theme.AppTheme
|
||||
|
||||
@Composable
|
||||
|
|
@ -158,6 +159,7 @@ internal fun DebugSearchState(
|
|||
searchState: SearchState,
|
||||
filterTexts: List<String>,
|
||||
presetFilters: List<String>,
|
||||
logs: List<UiMeshLog>,
|
||||
onSearchTextChange: (String) -> Unit,
|
||||
onNextMatch: () -> Unit,
|
||||
onPreviousMatch: () -> Unit,
|
||||
|
|
@ -195,7 +197,8 @@ internal fun DebugSearchState(
|
|||
onFilterTextsChange = onFilterTextsChange,
|
||||
customFilterText = customFilterText,
|
||||
onCustomFilterTextChange = { customFilterText = it },
|
||||
presetFilters = presetFilters
|
||||
presetFilters = presetFilters,
|
||||
logs = logs
|
||||
)
|
||||
}
|
||||
DebugActiveFilters(
|
||||
|
|
@ -213,6 +216,7 @@ fun DebugSearchStateviewModelDefaults(
|
|||
searchState: SearchState,
|
||||
filterTexts: List<String>,
|
||||
presetFilters: List<String>,
|
||||
logs: List<UiMeshLog>,
|
||||
filterMode: FilterMode,
|
||||
onFilterModeChange: (FilterMode) -> Unit,
|
||||
) {
|
||||
|
|
@ -222,6 +226,7 @@ fun DebugSearchStateviewModelDefaults(
|
|||
searchState = searchState,
|
||||
filterTexts = filterTexts,
|
||||
presetFilters = presetFilters,
|
||||
logs = logs,
|
||||
onSearchTextChange = viewModel.searchManager::setSearchText,
|
||||
onNextMatch = viewModel.searchManager::goToNextMatch,
|
||||
onPreviousMatch = viewModel.searchManager::goToPreviousMatch,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue