Skip to content
Open
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 @@ -65,33 +65,48 @@ fun getFormattedMarketCap(context: Context, value : Long) : String {

return if(value < million) {
val df = DecimalFormat("#,###.##")
context.getString(R.string.coin_market_cap, df.format(value), "")
}else if(value < billion){
context.getString(

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, "$")
}
}



}else if(value < billion) {
val coinMarketCapString = context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / million.toDouble()),
context.getString(R.string.symbol_million)
)

return " $coinMarketCapString"
}else if(value < trillion){
context.getString(
val coinMarketCapString = context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / billion.toDouble()),
context.getString(R.string.symbol_billion)
)

return " $coinMarketCapString"
}else if(value < quadrillion){
context.getString(
val coinMarketCapString = context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / trillion.toDouble()),
context.getString(R.string.symbol_trillion)
)
return "$coinMarketCapString "
}else if(value < quintillion){
context.getString(
val coinMarketCapString = context.getString(
R.string.coin_market_cap,
getInFourDecimalPlaces(value.toDouble() / quadrillion.toDouble()),
context.getString(R.string.symbol_quadrillion)
)
return " $coinMarketCapString"

}else {
context.getString(R.string.symbol_quintillion_fallback, "$")
val coinMarketCapString =
context.getString(R.string.symbol_quintillion_fallback_mcap, "$")
return " $coinMarketCapString"

}
}

Expand Down
4 changes: 3 additions & 1 deletion common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<string name="coin_image_content_description">%s Image</string>
<string name="coin_value_change">%s%s%%</string>
<string name="coin_amount_balance">%s%s %s</string>
<string name="coin_market_cap">$%s %s</string>
<string name="coin_market_cap">MCap $%s %s</string>
<string name="coin_total_volume">%s %s</string>
<string name="symbol_million">M</string>
<string name="symbol_billion">Bn</string>
<string name="symbol_trillion">Tr</string>
<string name="symbol_quadrillion">Qdr</string>
<string name="symbol_quintillion_fallback">Over %s1 Qnt</string>
<string name="symbol_quintillion_fallback_mcap">Mcap Over %s1 Qnt</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ fun CoinItem(
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

Spacer(modifier = Modifier.width(5.dp))
Text(
modifier = Modifier
.alpha(0.6f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import com.ryankoech.krypto.feature_home.R
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun CreditCard(
onChangeDisplayCurrency : () -> Unit,
onChangeDisplayCurrency: () -> Unit,
creditCardDetails: CreditCardDetails,
modifier: Modifier = Modifier
) {
Expand Down Expand Up @@ -67,49 +67,61 @@ fun CreditCard(
)
),
) {
Row (Modifier.fillMaxSize()){
Row(Modifier.fillMaxSize()) {
Column(
Modifier
.background(color = Color.Black)
.width(60.dp)
.fillMaxHeight()

) {
) {
Box(
modifier = Modifier
.padding(top = 30.dp, end = 5.dp)
.fillMaxWidth()
) {
Text(
text = "Wallet",
text = stringResource(R.string.wallet),
color = Color.White,
modifier = Modifier.rotate(270f)
)
}
Column(
Modifier.padding(top = 90.dp, start = 18.dp )
Modifier.padding(top = 90.dp, start = 18.dp)


) {
Image(painter = painterResource(id = R.drawable.baseline_circle_white), contentDescription = null,Modifier.size(10.dp))
Image(painter = painterResource(id = R.drawable.baseline_circle_white), contentDescription = null,Modifier.size(10.dp))
Image(painter = painterResource(id = R.drawable.baseline_circle_green), contentDescription = null,Modifier.size(10.dp))
Image(
painter = painterResource(id = R.drawable.baseline_circle_white),
contentDescription = null,
Modifier.size(10.dp)
)
Image(
painter = painterResource(id = R.drawable.baseline_circle_white),
contentDescription = null,
Modifier.size(10.dp)
)
Image(
painter = painterResource(id = R.drawable.baseline_circle_white),
contentDescription = null,
Modifier.size(10.dp)
.background(color = Color.Green),
)

}


}
Box(
Modifier
.width(5.dp)
.fillMaxHeight()
.background(color = Color.White)) {
// Spacer
.background(color = Color.White)
) {
}
Column(
modifier = Modifier
.padding(16.dp)
// .fillMaxSize()
) {

Row {
Expand All @@ -120,10 +132,10 @@ fun CreditCard(
Spacer(modifier = Modifier.weight(1.0f))
Card(
modifier = Modifier
.clickable{
.clickable {
onChangeDisplayCurrency()
},
border = BorderStroke(1.dp,Color.Black),
border = BorderStroke(1.dp, Color.Black),
backgroundColor = teaGreen200,
elevation = 0.dp,
shape = MaterialTheme.shapes.small
Expand All @@ -149,7 +161,11 @@ fun CreditCard(
}

Text(
text = getFormattedBalance(context, creditCardDetails.balance, creditCardDetails.displayCurrency),
text = getFormattedBalance(
context,
creditCardDetails.balance,
creditCardDetails.displayCurrency
),
style = MaterialTheme.typography.h1,
fontSize = 32.sp
)
Expand All @@ -160,7 +176,11 @@ fun CreditCard(
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = pluralStringResource(R.plurals.credit_card_assets, creditCardDetails.count, creditCardDetails.count),
text = pluralStringResource(
R.plurals.credit_card_assets,
creditCardDetails.count,
creditCardDetails.count
),
style = MaterialTheme.typography.h4,
fontSize = 13.sp
)
Expand Down Expand Up @@ -188,7 +208,6 @@ fun CreditCard(
}



@Preview
@Composable
private fun CreditCardPreview() {
Expand Down
2 changes: 2 additions & 0 deletions feature_home/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<string name="home_screen_error_action">Try Again</string>
<string name="home_screen_success_not_data_message">Such emptiness</string>
<string name="home_screen_success_no_data_action">Add Your first Coin</string>
<string name="wallet">Wallet</string>

<plurals name="credit_card_assets">
<item quantity="one">%d Asset</item>
<item quantity="other">%d Assets</item>
Expand Down