From c2d061b1fdec536a329ce3b43007e99573d79ee5 Mon Sep 17 00:00:00 2001 From: "Harry S (Macbook)" Date: Wed, 27 Mar 2024 21:11:33 +0000 Subject: [PATCH] Make details 24volume currency as it is currency --- .../coinwatch/ui/screen/DetailsScreenTest.kt | 22 +++++++++---------- .../data/mapper/CoinDetailsMapper.kt | 4 ++-- .../shorthouse/coinwatch/model/CoinDetails.kt | 2 +- .../DetailsUiStatePreviewProvider.kt | 6 ++--- .../details/component/MarketStatsCard.kt | 6 ++--- app/src/main/res/values/strings.xml | 2 +- .../data/mapper/CoinDetailsMapperTest.kt | 16 +++++++------- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/app/src/androidTest/java/dev/shorthouse/coinwatch/ui/screen/DetailsScreenTest.kt b/app/src/androidTest/java/dev/shorthouse/coinwatch/ui/screen/DetailsScreenTest.kt index 29d4b3aa..b4cb3a0e 100644 --- a/app/src/androidTest/java/dev/shorthouse/coinwatch/ui/screen/DetailsScreenTest.kt +++ b/app/src/androidTest/java/dev/shorthouse/coinwatch/ui/screen/DetailsScreenTest.kt @@ -105,7 +105,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -170,8 +170,8 @@ class DetailsScreenTest { onNodeWithText("2").assertIsDisplayed() onNodeWithText("Market Cap").assertIsDisplayed() onNodeWithText("$225,722,901,094.00").assertIsDisplayed() - onNodeWithText("Volume 24h").assertIsDisplayed() - onNodeWithText("6,627,669,115").assertIsDisplayed() + onNodeWithText("Volume (24h)").assertIsDisplayed() + onNodeWithText("$6,627,669,115.00").assertIsDisplayed() onNodeWithText("Circulating Supply").assertIsDisplayed() onNodeWithText("120,186,525").assertIsDisplayed() onNodeWithText("All Time High").assertIsDisplayed() @@ -196,7 +196,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -250,7 +250,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -306,7 +306,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -366,7 +366,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -409,7 +409,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -454,7 +454,7 @@ class DetailsScreenTest { currentPrice = Price("1879.14", currency = currency), marketCap = Price("225722901094", currency = currency), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6627669115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -519,8 +519,8 @@ class DetailsScreenTest { onNodeWithText("2").assertIsDisplayed() onNodeWithText("Market Cap").assertIsDisplayed() onNodeWithText("£225,722,901,094.00").assertIsDisplayed() - onNodeWithText("Volume 24h").assertIsDisplayed() - onNodeWithText("6,627,669,115").assertIsDisplayed() + onNodeWithText("Volume (24h)").assertIsDisplayed() + onNodeWithText("$6,627,669,115.00").assertIsDisplayed() onNodeWithText("Circulating Supply").assertIsDisplayed() onNodeWithText("120,186,525").assertIsDisplayed() onNodeWithText("All Time High ($)").assertIsDisplayed() diff --git a/app/src/main/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapper.kt b/app/src/main/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapper.kt index e5faa366..1d8964bc 100644 --- a/app/src/main/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapper.kt +++ b/app/src/main/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapper.kt @@ -32,9 +32,9 @@ class CoinDetailsMapper @Inject constructor() { currentPrice = Price(coinDetails?.currentPrice, currency = currency), marketCap = Price(coinDetails?.marketCap, currency = currency), marketCapRank = coinDetails?.marketCapRank.orEmpty(), - volume24h = formatNumberOrEmpty(coinDetails?.volume24h), + volume24h = Price(coinDetails?.volume24h, currency = currency), circulatingSupply = formatNumberOrEmpty(coinDetails?.supply?.circulatingSupply), - // API only support ATH in USD + // API only supports ATH in USD allTimeHigh = Price(coinDetails?.allTimeHigh?.price, currency = Currency.USD), allTimeHighDate = epochToDateOrEmpty(coinDetails?.allTimeHigh?.timestamp), listedDate = epochToDateOrEmpty(coinDetails?.listedAt) diff --git a/app/src/main/java/dev/shorthouse/coinwatch/model/CoinDetails.kt b/app/src/main/java/dev/shorthouse/coinwatch/model/CoinDetails.kt index ee33fef1..ed47f0e8 100644 --- a/app/src/main/java/dev/shorthouse/coinwatch/model/CoinDetails.kt +++ b/app/src/main/java/dev/shorthouse/coinwatch/model/CoinDetails.kt @@ -8,7 +8,7 @@ data class CoinDetails( val currentPrice: Price, val marketCap: Price, val marketCapRank: String, - val volume24h: String, + val volume24h: Price, val circulatingSupply: String, val allTimeHigh: Price, val allTimeHighDate: String, diff --git a/app/src/main/java/dev/shorthouse/coinwatch/ui/previewdata/DetailsUiStatePreviewProvider.kt b/app/src/main/java/dev/shorthouse/coinwatch/ui/previewdata/DetailsUiStatePreviewProvider.kt index 65228cd6..7faf3bcf 100644 --- a/app/src/main/java/dev/shorthouse/coinwatch/ui/previewdata/DetailsUiStatePreviewProvider.kt +++ b/app/src/main/java/dev/shorthouse/coinwatch/ui/previewdata/DetailsUiStatePreviewProvider.kt @@ -7,8 +7,8 @@ import dev.shorthouse.coinwatch.model.Percentage import dev.shorthouse.coinwatch.model.Price import dev.shorthouse.coinwatch.ui.model.ChartPeriod import dev.shorthouse.coinwatch.ui.screen.details.DetailsUiState -import java.math.BigDecimal import kotlinx.collections.immutable.persistentListOf +import java.math.BigDecimal class DetailsUiStatePreviewProvider : PreviewParameterProvider { override val values = sequenceOf( @@ -21,7 +21,7 @@ class DetailsUiStatePreviewProvider : PreviewParameterProvider { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6,627,669,115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -159,7 +159,7 @@ class DetailsUiStatePreviewProvider : PreviewParameterProvider { BigDecimal("1737.76"), BigDecimal("1739.52"), BigDecimal("1742.98"), - BigDecimal("1738.36") // ktlint-disable argument-list-wrapping + BigDecimal("1738.36") ), minPrice = Price("1632.46"), maxPrice = Price("1922.83"), diff --git a/app/src/main/java/dev/shorthouse/coinwatch/ui/screen/details/component/MarketStatsCard.kt b/app/src/main/java/dev/shorthouse/coinwatch/ui/screen/details/component/MarketStatsCard.kt index 8b712cda..09a27c03 100644 --- a/app/src/main/java/dev/shorthouse/coinwatch/ui/screen/details/component/MarketStatsCard.kt +++ b/app/src/main/java/dev/shorthouse/coinwatch/ui/screen/details/component/MarketStatsCard.kt @@ -51,7 +51,7 @@ fun MarketStatsCard( ), CoinDetailsListItem( nameId = R.string.list_item_volume_24h, - value = coinDetails.volume24h + value = coinDetails.volume24h.formattedAmount ), CoinDetailsListItem( nameId = R.string.list_item_circulating_supply, @@ -115,7 +115,7 @@ private fun MarketStatsCardPreview() { currentPrice = Price("1879.14"), marketCap = Price("225722901094"), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6,627,669,115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26"), allTimeHighDate = "10 Nov 2021", @@ -138,7 +138,7 @@ private fun MarketStatsCardPreviewNotDollar() { currentPrice = Price("1879.14", currency = Currency.GBP), marketCap = Price("225722901094", currency = Currency.GBP), marketCapRank = "2", - volume24h = "6,627,669,115", + volume24h = Price("6,627,669,115"), circulatingSupply = "120,186,525", allTimeHigh = Price("4878.26", currency = Currency.USD), allTimeHighDate = "10 Nov 2021", diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 50311ce9..511956f4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,7 +26,7 @@ All Time High All Time High ($) All Time High Date - Volume 24h + Volume (24h) Listed Date No favourite coins Tap the diff --git a/app/src/test/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapperTest.kt b/app/src/test/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapperTest.kt index 7e7fdcb2..2a8bb1b4 100644 --- a/app/src/test/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapperTest.kt +++ b/app/src/test/java/dev/shorthouse/coinwatch/data/mapper/CoinDetailsMapperTest.kt @@ -33,7 +33,7 @@ class CoinDetailsMapperTest { currentPrice = Price(null), marketCap = Price(null), marketCapRank = "", - volume24h = "", + volume24h = Price(null), circulatingSupply = "", allTimeHigh = Price(null), allTimeHighDate = "", @@ -67,7 +67,7 @@ class CoinDetailsMapperTest { currentPrice = Price(null), marketCap = Price(null), marketCapRank = "", - volume24h = "", + volume24h = Price(null), circulatingSupply = "", allTimeHigh = Price(null), allTimeHighDate = "", @@ -113,7 +113,7 @@ class CoinDetailsMapperTest { currentPrice = Price(null), marketCap = Price(null), marketCapRank = "", - volume24h = "", + volume24h = Price(null), circulatingSupply = "", allTimeHigh = Price(null), allTimeHighDate = "", @@ -164,7 +164,7 @@ class CoinDetailsMapperTest { currentPrice = Price("29490.954785191607"), marketCap = Price("515076089546.27606"), marketCapRank = "1", - volume24h = "", + volume24h = Price("abcdefg"), circulatingSupply = "", allTimeHigh = Price("68763.41083248306"), allTimeHighDate = "10 Nov 2021", @@ -215,7 +215,7 @@ class CoinDetailsMapperTest { currentPrice = Price("29490.954785191607"), marketCap = Price("515076089546.27606"), marketCapRank = "1", - volume24h = "9,294,621,082.274", + volume24h = Price("9294621082.273935"), circulatingSupply = "19,508,368", allTimeHigh = Price("68763.41083248306"), allTimeHighDate = "", @@ -266,7 +266,7 @@ class CoinDetailsMapperTest { currentPrice = Price("29490.954785191607"), marketCap = Price("515076089546.27606"), marketCapRank = "1", - volume24h = "9,294,621,082.274", + volume24h = Price("9294621082.273935"), circulatingSupply = "19,508,368", allTimeHigh = Price("68763.41083248306"), allTimeHighDate = "10 Nov 2021", @@ -319,7 +319,7 @@ class CoinDetailsMapperTest { currentPrice = Price("29490.954785191607", currency = currency), marketCap = Price("515076089546.27606", currency = currency), marketCapRank = "1", - volume24h = "9,294,621,082.274", + volume24h = Price("9294621082.273935", currency = currency), circulatingSupply = "19,508,368", allTimeHigh = Price("68763.41083248306", currency = Currency.USD), allTimeHighDate = "10 Nov 2021", @@ -372,7 +372,7 @@ class CoinDetailsMapperTest { currentPrice = Price("29490.954785191607", currency = currency), marketCap = Price("515076089546.27606", currency = currency), marketCapRank = "1", - volume24h = "9,294,621,082.274", + volume24h = Price("9294621082.273935", currency = currency), circulatingSupply = "19,508,368", allTimeHigh = Price("68763.41083248306", currency = Currency.USD), allTimeHighDate = "10 Nov 2021",