Skip to content

UI-20 :: Fix Lack of MCap In Coin Item#85

Open
essy16 wants to merge 3 commits into
RyanKoech:devfrom
essy16:ui/20
Open

UI-20 :: Fix Lack of MCap In Coin Item#85
essy16 wants to merge 3 commits into
RyanKoech:devfrom
essy16:ui/20

Conversation

@essy16
Copy link
Copy Markdown
Contributor

@essy16 essy16 commented Jul 26, 2023

@RyanKoech please review


val coinMarketCapString = context.getString(
(R.string.coin_market_cap), df.format(value), "")
return " $coinMarketCapString"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need these return statements inside. It is all being handled in the outside return statement in the begin of this if else chain. Refer to the original implementation. The only change should be in line 94:

fun getFormattedMarketCap(context: Context, value : Long) : String {
val million = 1_000_000
val billion = 1_000_000_000
val trillion = 1_000_000_000_000
val quadrillion = 1_000_000_000_000_000
val quintillion = 1_000_000_000_000_000_000
return if(value < million) {
val df = DecimalFormat("#,###.##")
context.getString(R.string.coin_market_cap, df.format(value), "")
}else if(value < billion){
context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / million.toDouble()),
context.getString(R.string.symbol_million)
)
}else if(value < trillion){
context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / billion.toDouble()),
context.getString(R.string.symbol_billion)
)
}else if(value < quadrillion){
context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / trillion.toDouble()),
context.getString(R.string.symbol_trillion)
)
}else if(value < quintillion){
context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / quadrillion.toDouble()),
context.getString(R.string.symbol_quadrillion)
)
}else {
context.getString(R.string.symbol_quintillion_fallback, "$")
}
}

color = getChangeColor(coin.change)
)
Spacer(modifier = Modifier.weight(1.0f))
Text(text = "MCap", style = MaterialTheme.typography.body2)
Copy link
Copy Markdown
Owner

@RyanKoech RyanKoech Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this product 2 MCap in the Coin Item composable? Kindly run to verify your changes.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMG_20230727_164701.jpg

Kindly delete the text composable

@essy16 essy16 closed this Oct 14, 2023
@RyanKoech RyanKoech reopened this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants