Updated on 2026-08-14
This commit is contained in:
parent
1b0f395ea9
commit
5a3d70202a
3 changed files with 11 additions and 17 deletions
|
|
@ -10,7 +10,7 @@ sealed class CurrencyListItem {
|
|||
data class BlockchainListItem(val blockchain: Blockchain) : CurrencyListItem()
|
||||
data class TitleListItem(
|
||||
@StringRes val titleResId: Int,
|
||||
val isContentShown: Boolean = true,
|
||||
var isContentShown: Boolean = true,
|
||||
val blockchain: Blockchain? = null,
|
||||
) : CurrencyListItem()
|
||||
|
||||
|
|
@ -57,13 +57,10 @@ fun List<CurrencyListItem>.addTokensForBlockchain(
|
|||
return this.toMutableList().apply { addAll(indexToInsert, tokensToAdd) }
|
||||
}
|
||||
|
||||
fun List<CurrencyListItem>.toggleHeaderContentShownValue(
|
||||
blockchain: Blockchain
|
||||
): List<CurrencyListItem> {
|
||||
val indexOfTitle = indexOfFirst {
|
||||
it is CurrencyListItem.TitleListItem && it.blockchain == blockchain
|
||||
fun List<CurrencyListItem>.toggleHeaderContentShownValue(blockchain: Blockchain) {
|
||||
map {
|
||||
if (it is CurrencyListItem.TitleListItem && it.blockchain == blockchain) {
|
||||
it.isContentShown = !it.isContentShown
|
||||
}
|
||||
}
|
||||
val title = this[indexOfTitle] as CurrencyListItem.TitleListItem
|
||||
val updatedTitle = title.copy(isContentShown = !title.isContentShown)
|
||||
return this.toMutableList().apply { set(indexOfTitle, updatedTitle) }
|
||||
}
|
||||
|
|
@ -33,12 +33,12 @@ private fun internalReduce(action: Action, state: AppState): TokensState {
|
|||
if (action.isShown) {
|
||||
val shownCurrencies = tokensState.shownCurrencies
|
||||
.removeTokensForBlockchain(action.blockchain)
|
||||
.toggleHeaderContentShownValue(action.blockchain)
|
||||
shownCurrencies.toggleHeaderContentShownValue(action.blockchain)
|
||||
tokensState.copy(shownCurrencies = shownCurrencies)
|
||||
} else {
|
||||
val shownCurrencies = tokensState.shownCurrencies
|
||||
.addTokensForBlockchain(action.blockchain, tokensState.currencies)
|
||||
.toggleHeaderContentShownValue(action.blockchain)
|
||||
shownCurrencies.toggleHeaderContentShownValue(action.blockchain)
|
||||
tokensState.copy(shownCurrencies = shownCurrencies)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,17 +164,14 @@ class CurrenciesAdapter : ListAdapter<CurrencyListItem, RecyclerView.ViewHolder>
|
|||
|
||||
if (title.blockchain != null) {
|
||||
view.cl_subtitle_container.setOnClickListener {
|
||||
val rotation = if (title.isContentShown) -90f else 0f
|
||||
store.dispatch(TokensAction.ToggleShowTokensForBlockchain(
|
||||
title.isContentShown, title.blockchain
|
||||
))
|
||||
view.iv_toggle_sublist_visibility.animate().rotation(rotation)
|
||||
}
|
||||
view.iv_toggle_sublist_visibility.show()
|
||||
val imageRes = if (title.isContentShown) {
|
||||
R.drawable.ic_arrow_angle_down
|
||||
} else {
|
||||
R.drawable.ic_arrow_angle_right
|
||||
}
|
||||
view.iv_toggle_sublist_visibility.setImageResource(imageRes)
|
||||
view.iv_toggle_sublist_visibility.setImageResource(R.drawable.ic_arrow_angle_down)
|
||||
} else {
|
||||
view.iv_toggle_sublist_visibility.hide()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue