From 73ce7a72036f05346fcc6581e83cda80d56f4882 Mon Sep 17 00:00:00 2001 From: andresmr Date: Fri, 16 Feb 2024 10:38:41 +0100 Subject: [PATCH] [ANDROAPP-5800] enable disable search button on empty parameters --- .../org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt | 1 + .../searchTrackEntity/searchparameters/SearchParametersScreen.kt | 1 + .../searchparameters/model/SearchParametersUiState.kt | 1 + 3 files changed, 3 insertions(+) diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt index 5d3f03c54b7..8d7d84451a0 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt @@ -269,6 +269,7 @@ class SearchTEIViewModel( ), ) } + uiState = uiState.copy(searchEnabled = queryData.isNotEmpty()) } fun fetchListResults(onPagedListReady: (Flow>?) -> Unit) { diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt index bdbc4aaf641..2ad3b9241ed 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt @@ -201,6 +201,7 @@ fun SearchParametersScreen( } Button( + enabled = uiState.searchEnabled, modifier = Modifier .fillMaxWidth() .padding(16.dp, 8.dp, 16.dp, 8.dp) diff --git a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/model/SearchParametersUiState.kt b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/model/SearchParametersUiState.kt index 9e12fee398d..1798f5fab7a 100644 --- a/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/model/SearchParametersUiState.kt +++ b/app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/model/SearchParametersUiState.kt @@ -8,6 +8,7 @@ data class SearchParametersUiState( val items: List = listOf(), val minAttributesMessage: String? = null, private val _shouldShowMinAttributeWarning: MutableSharedFlow = MutableSharedFlow(), + val searchEnabled: Boolean = false, ) { val shouldShowMinAttributeWarning: SharedFlow = _shouldShowMinAttributeWarning