Skip to content

Commit

Permalink
Handle alternative image url for TopPairs
Browse files Browse the repository at this point in the history
  • Loading branch information
omurovch committed May 30, 2024
1 parent d60519b commit ecd3049
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ dependencies {
implementation 'com.github.horizontalsystems:ethereum-kit-android:3d83900'
implementation 'com.github.horizontalsystems:blockchain-fee-rate-kit-android:1d3bd49'
implementation 'com.github.horizontalsystems:binance-chain-kit-android:c1509a2'
implementation 'com.github.horizontalsystems:market-kit-android:cfda444'
implementation 'com.github.horizontalsystems:market-kit-android:872cb04'
implementation 'com.github.horizontalsystems:solana-kit-android:ec238b4'
implementation 'com.github.horizontalsystems:tron-kit-android:dc3dca7'
// Zcash SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.horizontalsystems.bankwallet.modules.market.topnftcollections.TopNftCo
import io.horizontalsystems.bankwallet.modules.market.topplatforms.TopPlatformViewItem
import io.horizontalsystems.bankwallet.ui.compose.Select
import io.horizontalsystems.bankwallet.ui.extensions.MetricData
import io.horizontalsystems.marketkit.models.Coin
import io.horizontalsystems.marketkit.models.TopPair
import java.math.BigDecimal

Expand Down Expand Up @@ -103,8 +104,12 @@ data class TopPairViewItem(
val title: String,
val rank: String,
val name: String,
val base: String,
val baseCoinUid: String?,
val baseCoin: Coin?,
val target: String,
val targetCoinUid: String?,
val targetCoin: Coin?,
val iconUrl: String?,
val tradeUrl: String?,
val volume: BigDecimal,
Expand All @@ -126,8 +131,12 @@ data class TopPairViewItem(
return TopPairViewItem(
title = "${topPair.base}/${topPair.target}",
name = topPair.marketName ?: "",
base = topPair.base,
baseCoinUid = topPair.baseCoinUid,
baseCoin = topPair.baseCoin,
target = topPair.target,
targetCoinUid = topPair.targetCoinUid,
targetCoin = topPair.targetCoin,
iconUrl = topPair.marketLogo,
rank = topPair.rank.toString(),
tradeUrl = topPair.tradeUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.coinIconUrl
import io.horizontalsystems.bankwallet.core.stats.StatEvent
import io.horizontalsystems.bankwallet.core.stats.StatPage
import io.horizontalsystems.bankwallet.core.stats.stat
Expand All @@ -37,6 +36,7 @@ import io.horizontalsystems.bankwallet.modules.market.overview.TopPairViewItem
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.HSSwipeRefresh
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonSecondaryWithIcon
import io.horizontalsystems.bankwallet.ui.compose.components.CoinImage
import io.horizontalsystems.bankwallet.ui.compose.components.HSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.HeaderSorting
import io.horizontalsystems.bankwallet.ui.compose.components.HsImage
Expand Down Expand Up @@ -136,24 +136,37 @@ fun TopPairItem(
.padding(end = 16.dp)
.width(54.dp)
) {
HsImage(
url = item.targetCoinUid?.coinIconUrl,
placeholder = R.drawable.ic_platform_placeholder_32,
modifier = Modifier
.size(32.dp)
.background(ComposeAppTheme.colors.tyler)
.clip(CircleShape)
.align(Alignment.TopEnd)
)
HsImage(
url = item.baseCoinUid?.coinIconUrl,
placeholder = R.drawable.ic_platform_placeholder_32,
modifier = Modifier
.size(32.dp)
.clip(CircleShape)
.background(ComposeAppTheme.colors.tyler)
.align(Alignment.TopStart)
)

val modifier = Modifier
.size(32.dp)
.background(ComposeAppTheme.colors.tyler)
.clip(CircleShape)

if (item.targetCoin!= null) {
CoinImage(
coin = item.targetCoin,
modifier = modifier.align(Alignment.TopEnd)
)
} else {
HsImage(
url = "https://cdn.blocksdecoded.com/fiat-icons/${item.target}@3x.png",
placeholder = R.drawable.ic_platform_placeholder_32,
modifier = modifier.align(Alignment.TopEnd)
)
}

if (item.baseCoin != null) {
CoinImage(
coin = item.baseCoin,
modifier = modifier.align(Alignment.TopStart)
)
} else {
HsImage(
url = "https://cdn.blocksdecoded.com/fiat-icons/${item.base}@3x.png",
placeholder = R.drawable.ic_platform_placeholder_32,
modifier = modifier.align(Alignment.TopStart)
)
}
}

Column(modifier = Modifier.fillMaxWidth()) {
Expand Down

0 comments on commit ecd3049

Please sign in to comment.