Updated on 2026-08-14
This commit is contained in:
parent
1706a25d1a
commit
25a8807f60
7 changed files with 60 additions and 9 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ internal data class ManageTokensListState(
|
|||
val uiBatches: List<Batch<Int, List<CurrencyItemUM>>> = mutableListOf(),
|
||||
val currencyBatches: List<Batch<Int, List<ManagedCryptoCurrency>>> = mutableListOf(),
|
||||
val canEditItems: Boolean = true,
|
||||
val searchQuery: String? = null,
|
||||
) {
|
||||
|
||||
fun batchIndexByCurrencyId(currencyId: ManagedCryptoCurrency.ID): Int {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue