fixed 0.00 places for amounts
This commit is contained in:
parent
c3faee2eb0
commit
e0baafb84d
@ -108,11 +108,6 @@ fun InputAmount(
|
|||||||
modifier = Modifier.align(Alignment.CenterHorizontally)
|
modifier = Modifier.align(Alignment.CenterHorizontally)
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
// Row(
|
|
||||||
// modifier = Modifier.align(Alignment.CenterHorizontally),
|
|
||||||
// verticalAlignment = Alignment.Bottom
|
|
||||||
// ) {
|
|
||||||
Text(
|
Text(
|
||||||
text = formatAmount(amount.ifEmpty { "0" }),
|
text = formatAmount(amount.ifEmpty { "0" }),
|
||||||
color = Color.LegacyRed,
|
color = Color.LegacyRed,
|
||||||
@ -127,12 +122,7 @@ fun InputAmount(
|
|||||||
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
|
modifier = Modifier.padding(end = 10.dp, bottom = 6.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(14.dp))
|
Spacer(modifier = Modifier.height(14.dp))
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = supportingText,
|
text = supportingText,
|
||||||
color = Color.Gray,
|
color = Color.Gray,
|
||||||
@ -141,8 +131,6 @@ fun InputAmount(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//second container
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@ -246,14 +234,15 @@ private fun formatAmount(value: String): String {
|
|||||||
val groupedWholePart = "%,d".format(wholePart.toLongOrNull() ?: 0L)
|
val groupedWholePart = "%,d".format(wholePart.toLongOrNull() ?: 0L)
|
||||||
|
|
||||||
if (!normalized.contains(".")) {
|
if (!normalized.contains(".")) {
|
||||||
return groupedWholePart
|
return "$groupedWholePart.00"
|
||||||
}
|
}
|
||||||
|
|
||||||
val decimalPart = normalized.substringAfter(".", "")
|
val decimalPart = normalized.substringAfter(".", "")
|
||||||
return if (normalized.endsWith(".")) {
|
return if (normalized.endsWith(".")) {
|
||||||
"$groupedWholePart."
|
"$groupedWholePart.00"
|
||||||
} else {
|
} else {
|
||||||
"$groupedWholePart.$decimalPart"
|
val padded = decimalPart.padEnd(2, '0').take(2)
|
||||||
|
"$groupedWholePart.$padded"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -802,7 +802,14 @@ fun AppNavGraph(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun formatAmountForDisplay(amount: String?): String {
|
private fun formatAmountForDisplay(amount: String?): String {
|
||||||
val normalizedAmount = amount.orEmpty()
|
val raw = amount.orEmpty().trim()
|
||||||
val value = normalizedAmount.toLongOrNull() ?: return normalizedAmount.ifBlank { "0" }
|
if (raw.isBlank()) return "0.00"
|
||||||
return "%,d".format(value)
|
if (raw.contains(".")) {
|
||||||
|
val whole = raw.substringBefore(".").ifEmpty { "0" }
|
||||||
|
val decimal = raw.substringAfter(".", "")
|
||||||
|
val grouped = "%,d".format(whole.toLongOrNull() ?: 0L)
|
||||||
|
return "$grouped.${decimal.padEnd(2, '0').take(2)}"
|
||||||
|
}
|
||||||
|
val value = raw.toLongOrNull() ?: return raw
|
||||||
|
return "%,d.00".format(value)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user