From 83a204d1e415af114a1fe7d27e57cf1529e75b1a Mon Sep 17 00:00:00 2001 From: Shreyash16b Date: Fri, 14 Nov 2025 19:09:02 +0530 Subject: [PATCH 1/3] Empty screen on empty search --- .../core/designsystem/component/MifosOutlinedTextField.kt | 2 +- .../kotlin/com/mifos/feature/search/SearchViewModel.kt | 6 ++++++ .../kotlin/com/mifos/feature/search/components/SearchBox.kt | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosOutlinedTextField.kt b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosOutlinedTextField.kt index e4bcf207b4f..0ab8a7f21c8 100644 --- a/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosOutlinedTextField.kt +++ b/core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosOutlinedTextField.kt @@ -208,7 +208,7 @@ fun MifosOutlinedTextField( prefix = prefix, suffix = suffix, supportingText = { - if (errorText != null) { + if (errorText != null && isError) { Text( modifier = Modifier.testTag(errorTextTag), text = errorText, diff --git a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt index 029ff46f09c..f262a8e139f 100644 --- a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt +++ b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt @@ -93,6 +93,7 @@ class SearchViewModel( searchJob?.cancel() if (state.value.searchText.isNotEmpty()) { + state.value = state.value.copy(showEmptyError = false) searchJob = searchRepository.searchResources( query = state.value.searchText, resources = state.value.selectedFilter?.value, @@ -124,6 +125,10 @@ class SearchViewModel( } .launchIn(viewModelScope) } + else{ + state.value = state.value.copy(showEmptyError = true) + searchResultState.update { SearchResultState.Empty() } + } } } @@ -138,6 +143,7 @@ data class SearchScreenState( val searchText: String = "", val selectedFilter: FilterOption? = null, val exactMatch: Boolean? = null, + val showEmptyError: Boolean = false, ) sealed interface SearchScreenEvent { diff --git a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt index e69d07d8e2c..9f4d8e97752 100644 --- a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt +++ b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt @@ -117,6 +117,8 @@ internal fun SearchBox( onEvent(SearchScreenEvent.ClearSearchText) }, maxLines = 1, + isError = state.showEmptyError, + errorText = "Please enter Name or Account Number or External ID to search" ) // Search Button @@ -182,6 +184,7 @@ internal fun SearchBox( } } + @DevicePreview @Composable private fun SearchBoxPreview() { From 529650070e2cc991d74d8275d3ae8c83f8801f35 Mon Sep 17 00:00:00 2001 From: Shreyash16b Date: Sat, 15 Nov 2025 17:46:53 +0530 Subject: [PATCH 2/3] Use string resource --- .../composeResources/values/feature_search_strings.xml | 1 + .../kotlin/com/mifos/feature/search/components/SearchBox.kt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/feature/search/src/commonMain/composeResources/values/feature_search_strings.xml b/feature/search/src/commonMain/composeResources/values/feature_search_strings.xml index a545ab7a61b..50c94369dd2 100644 --- a/feature/search/src/commonMain/composeResources/values/feature_search_strings.xml +++ b/feature/search/src/commonMain/composeResources/values/feature_search_strings.xml @@ -15,6 +15,7 @@ No results found for entered query No Search Query Entered! Exact Match + Please enter Name or Account Number or External ID to search Clients clients diff --git a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt index 9f4d8e97752..7e596f8dbeb 100644 --- a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt +++ b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt @@ -10,6 +10,7 @@ package com.mifos.feature.search.components import androidclient.feature.search.generated.resources.Res +import androidclient.feature.search.generated.resources.feature_search_empty_input_field import androidclient.feature.search.generated.resources.feature_search_exact_match import androidclient.feature.search.generated.resources.feature_search_search_hint import androidclient.feature.search.generated.resources.feature_search_title @@ -118,7 +119,7 @@ internal fun SearchBox( }, maxLines = 1, isError = state.showEmptyError, - errorText = "Please enter Name or Account Number or External ID to search" + errorText = if(state.showEmptyError) stringResource(Res.string.feature_search_empty_input_field) else null ) // Search Button From c3b1d010399d93dba71700dc4724cd3ad9b1cf36 Mon Sep 17 00:00:00 2001 From: Shreyash16b Date: Sat, 15 Nov 2025 17:51:57 +0530 Subject: [PATCH 3/3] run ci-prepush.sh --- ci-prepush.sh | 0 .../kotlin/com/mifos/feature/search/SearchViewModel.kt | 3 +-- .../kotlin/com/mifos/feature/search/components/SearchBox.kt | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) mode change 100644 => 100755 ci-prepush.sh diff --git a/ci-prepush.sh b/ci-prepush.sh old mode 100644 new mode 100755 diff --git a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt index f262a8e139f..6f570bbfd2e 100644 --- a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt +++ b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/SearchViewModel.kt @@ -124,8 +124,7 @@ class SearchViewModel( } } .launchIn(viewModelScope) - } - else{ + } else { state.value = state.value.copy(showEmptyError = true) searchResultState.update { SearchResultState.Empty() } } diff --git a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt index 7e596f8dbeb..88da02d10f2 100644 --- a/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt +++ b/feature/search/src/commonMain/kotlin/com/mifos/feature/search/components/SearchBox.kt @@ -119,7 +119,7 @@ internal fun SearchBox( }, maxLines = 1, isError = state.showEmptyError, - errorText = if(state.showEmptyError) stringResource(Res.string.feature_search_empty_input_field) else null + errorText = if (state.showEmptyError) stringResource(Res.string.feature_search_empty_input_field) else null, ) // Search Button @@ -185,7 +185,6 @@ internal fun SearchBox( } } - @DevicePreview @Composable private fun SearchBoxPreview() {