Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show rate 0 change in grey color #7544

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ import io.horizontalsystems.bankwallet.ui.compose.components.CellMultilineClear
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.RateColor
import io.horizontalsystems.bankwallet.ui.compose.components.RateText
import io.horizontalsystems.bankwallet.ui.compose.components.body_leah
import io.horizontalsystems.bankwallet.ui.compose.components.diffColor
import io.horizontalsystems.bankwallet.ui.compose.components.diffText
import io.horizontalsystems.bankwallet.ui.extensions.RotatingCircleProgressView
import io.horizontalsystems.core.helpers.HudHelper

Expand Down Expand Up @@ -265,8 +265,8 @@ fun BalanceCardCex(
)
Text(
modifier = Modifier.padding(start = 4.dp),
text = RateText(viewItem.diff),
color = RateColor(viewItem.diff),
text = diffText(viewItem.diff),
color = diffColor(viewItem.diff),
style = ComposeAppTheme.typography.subhead2,
maxLines = 1,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.CellMultilineClear
import io.horizontalsystems.bankwallet.ui.compose.components.CoinImage
import io.horizontalsystems.bankwallet.ui.compose.components.HsIconButton
import io.horizontalsystems.bankwallet.ui.compose.components.RateColor
import io.horizontalsystems.bankwallet.ui.compose.components.RateText
import io.horizontalsystems.bankwallet.ui.compose.components.body_leah
import io.horizontalsystems.bankwallet.ui.compose.components.diffColor
import io.horizontalsystems.bankwallet.ui.compose.components.diffText
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.extensions.RotatingCircleProgressView
import io.horizontalsystems.core.helpers.HudHelper
Expand Down Expand Up @@ -209,8 +209,8 @@ fun BalanceCardInner(
)
Text(
modifier = Modifier.padding(start = 4.dp),
text = RateText(viewItem.diff),
color = RateColor(viewItem.diff),
text = diffText(viewItem.diff),
color = diffColor(viewItem.diff),
style = ComposeAppTheme.typography.subhead2,
maxLines = 1,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ package io.horizontalsystems.bankwallet.modules.nft.collection.overview

import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
Expand All @@ -19,13 +26,22 @@ import androidx.compose.ui.unit.dp
import coil.compose.rememberAsyncImagePainter
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.entities.ViewState
import io.horizontalsystems.bankwallet.modules.coin.overview.ui.Loading
import io.horizontalsystems.bankwallet.modules.coin.overview.ui.About
import io.horizontalsystems.bankwallet.modules.coin.overview.ui.Contracts
import io.horizontalsystems.bankwallet.modules.coin.overview.ui.Loading
import io.horizontalsystems.bankwallet.modules.nft.ui.CellLink
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.HSSwipeRefresh
import io.horizontalsystems.bankwallet.ui.compose.components.*
import io.horizontalsystems.bankwallet.ui.compose.components.CellFooter
import io.horizontalsystems.bankwallet.ui.compose.components.CellSingleLineClear
import io.horizontalsystems.bankwallet.ui.compose.components.CellSingleLineLawrenceSection
import io.horizontalsystems.bankwallet.ui.compose.components.ListErrorView
import io.horizontalsystems.bankwallet.ui.compose.components.body_leah
import io.horizontalsystems.bankwallet.ui.compose.components.caption_grey
import io.horizontalsystems.bankwallet.ui.compose.components.diffColor
import io.horizontalsystems.bankwallet.ui.compose.components.diffText
import io.horizontalsystems.bankwallet.ui.compose.components.subhead1_leah
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey

@Composable
fun NftCollectionOverviewScreen(
Expand Down Expand Up @@ -260,8 +276,8 @@ private fun Stats(collection: NftCollectionOverviewViewItem) {
)
Spacer(modifier = Modifier.weight(1f))
Text(
text = RateText(collection.oneDayVolumeDiff),
color = RateColor(collection.oneDayVolumeDiff),
text = diffText(collection.oneDayVolumeDiff),
color = diffColor(collection.oneDayVolumeDiff),
style = ComposeAppTheme.typography.subhead1,
maxLines = 1,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ fun CategoryCard(
) {
marketData.diff?.let { diff ->
Text(
text = RateText(diff),
color = RateColor(diff),
text = diffText(diff),
color = diffColor(diff),
style = ComposeAppTheme.typography.caption,
maxLines = 1,
modifier = Modifier.padding(start = 6.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
Expand All @@ -25,25 +26,27 @@ import io.horizontalsystems.marketkit.models.Token
import java.math.BigDecimal

@Composable
fun RateColor(diff: BigDecimal?) =
if ((diff ?: BigDecimal.ZERO) >= BigDecimal.ZERO) ComposeAppTheme.colors.remus else ComposeAppTheme.colors.lucian

@Composable
fun diffColor(value: BigDecimal) =
if (value.signum() >= 0) {
ComposeAppTheme.colors.remus
} else {
ComposeAppTheme.colors.lucian
fun diffColor(value: BigDecimal?) : Color {
val diff = value ?: BigDecimal.ZERO
return when {
diff.signum() == 0 -> ComposeAppTheme.colors.grey
diff.signum() >= 0 -> ComposeAppTheme.colors.remus
else -> ComposeAppTheme.colors.lucian
}
}

@Composable
fun formatValueAsDiff(value: Value): String =
App.numberFormatter.formatValueAsDiff(value)

@Composable
fun RateText(diff: BigDecimal?): String {
fun diffText(diff: BigDecimal?): String {
if (diff == null) return ""
val sign = if (diff >= BigDecimal.ZERO) "+" else "-"
val sign = when {
diff == BigDecimal.ZERO -> ""
diff >= BigDecimal.ZERO -> "+"
else -> "-"
}
return App.numberFormatter.format(diff.abs(), 0, 2, sign, "%")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ fun MarketDataValueComponent(marketDataValue: MarketDataValue?) {
}
is MarketDataValue.Diff -> {
Text(
text = RateText(marketDataValue.value),
color = RateColor(marketDataValue.value),
text = diffText(marketDataValue.value),
color = diffColor(marketDataValue.value),
style = ComposeAppTheme.typography.subhead2,
maxLines = 1,
)
Expand Down
Loading