Updated on 2026-08-14
This commit is contained in:
parent
9c53805c51
commit
36c84f0483
4 changed files with 11 additions and 22 deletions
|
|
@ -246,6 +246,7 @@ private fun TopBar(
|
|||
horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing8),
|
||||
) {
|
||||
RoundedActionButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
config = ActionButtonConfig(
|
||||
text = TextReference.Res(id = R.string.organize_tokens_sort_by_balance),
|
||||
iconResId = R.drawable.ic_sort_24,
|
||||
|
|
@ -253,10 +254,10 @@ private fun TopBar(
|
|||
onClick = config.onSortClick,
|
||||
dimContent = config.isSortedByBalance,
|
||||
),
|
||||
modifier = Modifier.weight(1f),
|
||||
color = TangemTheme.colors.background.primary,
|
||||
)
|
||||
RoundedActionButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
config = ActionButtonConfig(
|
||||
text = TextReference.Res(
|
||||
id = if (config.isGrouped) {
|
||||
|
|
@ -265,11 +266,10 @@ private fun TopBar(
|
|||
R.string.organize_tokens_group
|
||||
},
|
||||
),
|
||||
enabled = config.isEnabled,
|
||||
iconResId = R.drawable.ic_group_24,
|
||||
enabled = config.isEnabled,
|
||||
onClick = config.onGroupClick,
|
||||
),
|
||||
modifier = Modifier.weight(1f),
|
||||
color = TangemTheme.colors.background.primary,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ import com.tangem.feature.wallet.presentation.organizetokens.utils.dnd.DragAndDr
|
|||
import com.tangem.feature.wallet.presentation.router.InnerWalletRouter
|
||||
import com.tangem.feature.wallet.presentation.router.WalletRoute
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
|
|
@ -40,7 +38,6 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase,
|
||||
private val analyticsEventsHandler: AnalyticsEventHandler,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
savedStateHandle: SavedStateHandle,
|
||||
) : ViewModel(), DefaultLifecycleObserver, OrganizeTokensIntents {
|
||||
|
||||
|
|
@ -95,7 +92,7 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
|
||||
analyticsEventsHandler.send(PortfolioOrganizeTokensAnalyticsEvent.ByBalance)
|
||||
|
||||
viewModelScope.launch(dispatchers.default) {
|
||||
viewModelScope.launch {
|
||||
toggleTokenListSortingUseCase(list).fold(
|
||||
ifLeft = stateHolder::updateStateWithError,
|
||||
ifRight = {
|
||||
|
|
@ -111,7 +108,7 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
|
||||
analyticsEventsHandler.send(PortfolioOrganizeTokensAnalyticsEvent.Group)
|
||||
|
||||
viewModelScope.launch(dispatchers.default) {
|
||||
viewModelScope.launch {
|
||||
toggleTokenListGroupingUseCase(list).fold(
|
||||
ifLeft = stateHolder::updateStateWithError,
|
||||
ifRight = {
|
||||
|
|
@ -123,7 +120,7 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onApplyClick() {
|
||||
viewModelScope.launch(dispatchers.default) {
|
||||
viewModelScope.launch {
|
||||
stateHolder.updateStateToDisplayProgress()
|
||||
|
||||
val listState = uiState.value.itemsState
|
||||
|
|
@ -147,8 +144,8 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
result.fold(
|
||||
ifLeft = stateHolder::updateStateWithError,
|
||||
ifRight = {
|
||||
router.popBackStack()
|
||||
stateHolder.updateStateToHideProgress()
|
||||
withContext(dispatchers.main) { router.popBackStack() }
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
@ -161,7 +158,7 @@ internal class OrganizeTokensViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun bootstrapTokenList() {
|
||||
viewModelScope.launch(dispatchers.default) {
|
||||
viewModelScope.launch {
|
||||
val tokenList = getTokenList() ?: return@launch
|
||||
|
||||
stateHolder.updateStateWithTokenList(tokenList)
|
||||
|
|
|
|||
|
|
@ -16,15 +16,7 @@ internal sealed class OrganizeTokensListState {
|
|||
override val items: PersistentList<DraggableItem>,
|
||||
) : OrganizeTokensListState()
|
||||
|
||||
object Empty : OrganizeTokensListState() {
|
||||
data object Empty : OrganizeTokensListState() {
|
||||
override val items: PersistentList<DraggableItem> = persistentListOf()
|
||||
}
|
||||
|
||||
fun copySealed(items: PersistentList<DraggableItem> = this.items): OrganizeTokensListState {
|
||||
return when (this) {
|
||||
is GroupedByNetwork -> copy(items = items)
|
||||
is Ungrouped -> copy(items = items)
|
||||
is Empty -> Empty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -167,9 +167,9 @@ internal class DragAndDropAdapter(
|
|||
|
||||
sealed class Type {
|
||||
|
||||
object Start : Type()
|
||||
data object Start : Type()
|
||||
|
||||
object Dragged : Type()
|
||||
data object Dragged : Type()
|
||||
|
||||
data class End(val isItemsOrderChanged: Boolean) : Type()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue