Extracted formatQuantity()
This commit is contained in:
parent
fe853f03e9
commit
b518f4c0ee
2 changed files with 4 additions and 1 deletions
|
@ -70,7 +70,7 @@ fun HoldingListItem(holding: Holding, isOddItem: Boolean = false, isNotLastItem:
|
|||
Row(Modifier.weight(1f).padding(end = 6.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
// TODO: set maxLines = 1 and TextOverflow.Ellipsis
|
||||
if (holding.quantity != null) {
|
||||
Text(holding.quantity.toString().replace(".0", "").replace(".", ",") + " Stück, ")
|
||||
Text(formatUtil.formatQuantity(holding.quantity) + " Stück, ")
|
||||
}
|
||||
|
||||
if (holding.averageCostPrice != null) {
|
||||
|
|
|
@ -74,6 +74,9 @@ class FormatUtil {
|
|||
fun formatPercentage(performance: Float): String =
|
||||
(if (performance > 0) "+" else "") + formatToTwoDecimalPlaces(performance.toString()) + " %"
|
||||
|
||||
fun formatQuantity(quantity: Double?): String =
|
||||
quantity.toString().replace(".0", "").replace(".", ",") // TODO: find a better way
|
||||
|
||||
private fun formatToTwoDecimalPlaces(amount: String): String { // TODO: find a better way
|
||||
val parts = amount.split('.')
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue