diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewManageTokensComponent.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewManageTokensComponent.kt index fae9aafb14..6e5a5917e2 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewManageTokensComponent.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewManageTokensComponent.kt @@ -173,6 +173,7 @@ internal class PreviewManageTokensComponent( ) is CurrencyItemUM.Custom, is CurrencyItemUM.Loading, + is CurrencyItemUM.SearchNothingFound, -> return } @@ -210,6 +211,7 @@ internal class PreviewManageTokensComponent( } is CurrencyItemUM.Custom, is CurrencyItemUM.Loading, + is CurrencyItemUM.SearchNothingFound, -> return } diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/CurrencyItemUM.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/CurrencyItemUM.kt index d81b14e587..be4cbd74e2 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/CurrencyItemUM.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/CurrencyItemUM.kt @@ -48,4 +48,11 @@ internal sealed class CurrencyItemUM { override val symbol: String = "loading" override val icon: CurrencyIconState = CurrencyIconState.Loading } + + data object SearchNothingFound : CurrencyItemUM() { + override val id: ManagedCryptoCurrency.ID = ManagedCryptoCurrency.ID(value = "not found text") + override val name: String = "content not found" + override val symbol: String = "content not found" + override val icon: CurrencyIconState = CurrencyIconState.Loading + } } \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/ManageTokensModel.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/ManageTokensModel.kt index 3c6a9b85bf..0e6780749b 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/ManageTokensModel.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/ManageTokensModel.kt @@ -235,10 +235,12 @@ internal class ManageTokensModel @Inject constructor( }, ) } - is PaginationStatus.EndOfPagination -> state.copySealed( - isInitialBatchLoading = false, - isNextBatchLoading = false, - ) + is PaginationStatus.EndOfPagination -> { + state.copySealed( + isInitialBatchLoading = false, + isNextBatchLoading = false, + ) + } } } } diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/ManageTokensScreen.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/ManageTokensScreen.kt index 6c5489f29b..121259e7ac 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/ManageTokensScreen.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/ManageTokensScreen.kt @@ -13,10 +13,7 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material3.CircularProgressIndicator -import androidx.compose.material3.FabPosition -import androidx.compose.material3.Icon -import androidx.compose.material3.Scaffold +import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember @@ -241,6 +238,9 @@ private fun Currencies( modifier = Modifier.fillMaxWidth(), ) } + is CurrencyItemUM.SearchNothingFound -> { + SearchNothingFoundText(modifier = Modifier.fillParentMaxSize()) + } } } @@ -262,6 +262,20 @@ private fun Currencies( ) } +@Composable +private fun SearchNothingFoundText(modifier: Modifier = Modifier) { + Box( + modifier = modifier, + contentAlignment = Alignment.Center, + ) { + Text( + text = stringResource(R.string.markets_search_token_no_result_title), + style = TangemTheme.typography.caption1, + color = TangemTheme.colors.text.tertiary, + ) + } +} + @Composable private fun ProgressIndicator(modifier: Modifier = Modifier) { Box( diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListManager.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListManager.kt index 2eea0dc190..3c584c503b 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListManager.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListManager.kt @@ -20,6 +20,7 @@ import com.tangem.features.managetokens.component.ManageTokensComponent import com.tangem.features.managetokens.component.ManageTokensSource import com.tangem.features.managetokens.entity.item.CurrencyItemUM import com.tangem.features.managetokens.impl.R +import com.tangem.pagination.Batch import com.tangem.pagination.BatchAction import com.tangem.pagination.BatchListState import com.tangem.pagination.PaginationStatus @@ -119,7 +120,7 @@ internal class ManageTokensListManager @Inject constructor( } suspend fun search(userWalletId: UserWalletId?, query: String) { - state.value = ManageTokensListState() + state.value = ManageTokensListState(searchQuery = query) actionsFlow.emit( BatchAction.Reload( requestParams = ManageTokensListConfig( @@ -140,6 +141,28 @@ internal class ManageTokensListManager @Inject constructor( ) } + // Search nothing found + if ( + state.value.searchQuery.isNullOrEmpty().not() && + batchListState.status is PaginationStatus.EndOfPagination && + batchListState.data.isEmpty() + ) { + state.update { state -> + state.copy( + userWalletId = userWalletId, + currencyBatches = emptyList(), + uiBatches = listOf( + Batch( + key = Int.MAX_VALUE, + data = listOf(CurrencyItemUM.SearchNothingFound), + ), + ), + ) + } + + return + } + state.update { state -> val newBatches = batchListState.data val currentBatches = state.currencyBatches diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListState.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListState.kt index a140122502..08a1d6340a 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListState.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensListState.kt @@ -17,6 +17,7 @@ internal data class ManageTokensListState( val uiBatches: List>> = mutableListOf(), val currencyBatches: List>> = mutableListOf(), val canEditItems: Boolean = true, + val searchQuery: String? = null, ) { fun batchIndexByCurrencyId(currencyId: ManagedCryptoCurrency.ID): Int { diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/ui/CurrencyItemOperations.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/ui/CurrencyItemOperations.kt index dc27478f94..d92b7108d0 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/ui/CurrencyItemOperations.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/ui/CurrencyItemOperations.kt @@ -18,6 +18,7 @@ internal fun CurrencyItemUM.toggleExpanded( return when (this) { is CurrencyItemUM.Custom, is CurrencyItemUM.Loading, + is CurrencyItemUM.SearchNothingFound, -> this is CurrencyItemUM.Basic -> { val isExpanded = networks !is NetworksUM.Expanded @@ -41,6 +42,7 @@ internal fun CurrencyItemUM.update(currency: ManagedCryptoCurrency): CurrencyIte return when (this) { is CurrencyItemUM.Custom, is CurrencyItemUM.Loading, + is CurrencyItemUM.SearchNothingFound, -> this is CurrencyItemUM.Basic -> { if (currency !is ManagedCryptoCurrency.Token) {