Fix log screen search input and always show toolbar actions
- Fix search TextField cursor issue by immediately updating searchQuery in uiState, keeping debounce only for log filtering - Always show toolbar buttons regardless of log list empty state
This commit is contained in:
@@ -525,13 +525,10 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show actions only for Log screen and when logs are not empty
|
|
||||||
if (currentScreen == Screen.Log && logViewModel != null) {
|
if (currentScreen == Screen.Log && logViewModel != null) {
|
||||||
val logUiState by logViewModel.uiState.collectAsState()
|
val logUiState by logViewModel.uiState.collectAsState()
|
||||||
|
|
||||||
// Only show toolbar actions if logs are not empty and not in selection mode
|
if (!logUiState.isSelectionMode) {
|
||||||
if (logUiState.logs.isNotEmpty() && !logUiState.isSelectionMode) {
|
|
||||||
// Pause/Resume button
|
|
||||||
IconButton(onClick = { logViewModel.togglePause() }) {
|
IconButton(onClick = { logViewModel.togglePause() }) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector =
|
imageVector =
|
||||||
@@ -551,7 +548,6 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search button
|
|
||||||
IconButton(onClick = { logViewModel.toggleSearch() }) {
|
IconButton(onClick = { logViewModel.toggleSearch() }) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector =
|
imageVector =
|
||||||
@@ -577,7 +573,6 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options menu button
|
|
||||||
IconButton(onClick = { logViewModel.toggleOptionsMenu() }) {
|
IconButton(onClick = { logViewModel.toggleOptionsMenu() }) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.MoreVert,
|
imageVector = Icons.Default.MoreVert,
|
||||||
@@ -585,7 +580,7 @@ class ComposeActivity : ComponentActivity(), ServiceConnection.Callback {
|
|||||||
tint = MaterialTheme.colorScheme.onSurface,
|
tint = MaterialTheme.colorScheme.onSurface,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} // End of logs.isNotEmpty() check
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
colors = TopAppBarDefaults.topAppBarColors(),
|
colors = TopAppBarDefaults.topAppBarColors(),
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ class LogViewModel : ViewModel(), CommandClient.Handler {
|
|||||||
_searchQueryInternal
|
_searchQueryInternal
|
||||||
.debounce(300)
|
.debounce(300)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.collect { query ->
|
.collect { _ ->
|
||||||
_uiState.update { it.copy(searchQuery = query) }
|
|
||||||
updateDisplayedLogs()
|
updateDisplayedLogs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,6 +200,7 @@ class LogViewModel : ViewModel(), CommandClient.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateSearchQuery(query: String) {
|
fun updateSearchQuery(query: String) {
|
||||||
|
_uiState.update { it.copy(searchQuery = query) }
|
||||||
_searchQueryInternal.value = query
|
_searchQueryInternal.value = query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user