Skip to content

Commit

Permalink
Updated the price display a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rK7355608 committed May 23, 2024
1 parent fa31182 commit d658682
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
applicationId = "com.d4rk.cartcalculator"
minSdk = 26
targetSdk = 34
versionCode = 26
versionCode = 27
versionName = "0.0.1"
archivesName = "${applicationId}-v${versionName}"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ fun CartActivityComposable(activity: CartActivity, viewModel: CartViewModel) {
)
Spacer(modifier = Modifier.height(8.dp))
Row {
val locale = LocalContext.current.resources.configuration.locales[0]
Text(
text = viewModel.totalPrice.doubleValue.toString(),
text = String.format(locale, "%.0f", viewModel.totalPrice.doubleValue),
style = MaterialTheme.typography.bodyLarge
)
Spacer(modifier = Modifier.width(4.dp))
Expand Down Expand Up @@ -211,6 +212,7 @@ fun CartItemComposable(
onPlusClick: (ShoppingCartItemsTable) -> Unit,
quantityState: MutableState<Int>,
) {
val locale = LocalContext.current.resources.configuration.locales[0]
Box(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -222,7 +224,10 @@ fun CartItemComposable(
Column {
Text(text = cartItem.name, style = MaterialTheme.typography.bodyLarge)
Row {
Text(text = cartItem.price, style = MaterialTheme.typography.bodyMedium)
Text(
text = String.format(locale, "%.0f", cartItem.price.toDouble()),
style = MaterialTheme.typography.bodyMedium
)
Spacer(modifier = Modifier.width(4.dp))
Text(
text = viewModel.selectedCurrency.value,
Expand Down

0 comments on commit d658682

Please sign in to comment.