Updated on 2026-08-14

This commit is contained in:
Tangem 2022-04-20 11:50:23 +03:00
commit 35e9a10063
3 changed files with 62 additions and 20 deletions

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.tokens.ui.compose
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
@ -71,6 +72,7 @@ fun CollapsedCurrencyItem(
if (contract.address == currency.symbol) {
BlockchainNetworkItem(
blockchain = Blockchain.fromNetworkId(contract.networkId),
isMainNetwork = true,
addedBlockchains = addedBlockchains
)
} else {
@ -95,6 +97,7 @@ fun CollapsedCurrencyItem(
} else {
BlockchainNetworkItem(
blockchain = blockchain,
isMainNetwork = false,
addedBlockchains = addedBlockchains
)
}
@ -114,18 +117,39 @@ fun CollapsedCurrencyItem(
@Composable
fun BlockchainNetworkItem(
blockchain: Blockchain?,
isMainNetwork: Boolean,
addedBlockchains: List<Blockchain>
) {
val added = addedBlockchains.contains(blockchain)
val icon =
if (added) blockchain?.getRoundIconRes() else blockchain?.getGreyedOutIconRes()
if (icon != null) {
Image(
painter = painterResource(id = icon),
contentDescription = null,
Modifier
.size(20.dp)
)
Box(Modifier
.size(20.dp)) {
Image(
painter = painterResource(id = icon),
contentDescription = null,
Modifier
.size(20.dp)
)
if (isMainNetwork) {
Box(
modifier = Modifier
.align(Alignment.TopEnd)
.size(7.dp)
.clip(CircleShape)
.background(Color.White)
) {
Box(
modifier = Modifier
.align(Alignment.Center)
.size(5.dp)
.clip(CircleShape)
.background(Color(0xFF1ACE80))
)
}
}
}
Spacer(modifier = Modifier.size(5.dp))
}
}

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.tokens.ui.compose
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
@ -53,17 +54,36 @@ fun NetworkItem(
interactionSource = remember { MutableInteractionSource() }
)
) {
SubcomposeAsyncImage(
model = if (added) blockchain.getRoundIconRes() else blockchain.getGreyedOutIconRes(),
contentDescription = blockchain.fullName,
loading = { CurrencyPlaceholderIcon(blockchain.id) },
error = { CurrencyPlaceholderIcon(blockchain.id) },
modifier = Modifier
.clip(CircleShape)
.padding(start = 8.dp, top = 16.dp, bottom = 16.dp, end = 6.dp)
.size(20.dp)
.align(Alignment.CenterVertically)
)
Box(modifier = Modifier
.align(Alignment.CenterVertically)
.padding(start = 8.dp, top = 16.dp, bottom = 16.dp, end = 6.dp)
) {
SubcomposeAsyncImage(
model = if (added) blockchain.getRoundIconRes() else blockchain.getGreyedOutIconRes(),
contentDescription = blockchain.fullName,
loading = { CurrencyPlaceholderIcon(blockchain.id) },
error = { CurrencyPlaceholderIcon(blockchain.id) },
modifier = Modifier
.size(20.dp)
)
if (isBlockchain) {
Box(
modifier = Modifier
.align(Alignment.TopEnd)
.size(7.dp)
.clip(CircleShape)
.background(Color.White)
) {
Box(
modifier = Modifier
.align(Alignment.Center)
.size(5.dp)
.clip(CircleShape)
.background(Color(0xFF1ACE80))
)
}
}
}
Row(
modifier = Modifier
.fillMaxHeight()

View file

@ -54,9 +54,7 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
override fun onStart() {
super.onStart()
store.subscribe(this) { state ->
state.skipRepeats { oldState, newState ->
oldState.walletState == newState.walletState
}.select { it.walletState }
state.select { it.walletState }
}
}