Skip to content

Commit

Permalink
Fixed: getting single point zero&not getting comma seperator
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-nirali-s committed Jan 22, 2025
1 parent a6dbd4c commit 1ebff4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Data/Data/Extension/Double+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public extension Double {
let amount: String
let formatter = NumberFormatter()
formatter.locale = Locale.current
formatter.numberStyle = .decimal // Added decimal which includes comma separator
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2

if let formattedAmount = formatter.string(from: NSNumber(value: self)) {
amount = formattedAmount.hasPrefix("-") ? String(formattedAmount.dropFirst()) : formattedAmount
Expand Down
6 changes: 2 additions & 4 deletions Splito/UI/Home/Groups/Group/GroupExpenseListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,14 @@ private struct GroupExpenseHeaderOverallView: View {

var oweAmountText: String {
owedAmounts.map { (currency, amount) in
let currencySymbol = Currency.getCurrencyFromCode(currency).symbol
return "\(currencySymbol) \(abs(amount))"
return amount.formattedCurrency(currency)
}
.joined(separator: " + ")
}

var oweToYouAmountText: String {
owedToYouAmounts.map { (currency, amount) in
let currencySymbol = Currency.getCurrencyFromCode(currency).symbol
return "\(currencySymbol) \(abs(amount))"
return amount.formattedCurrency(currency)
}
.joined(separator: " + ")
}
Expand Down
6 changes: 2 additions & 4 deletions Splito/UI/Home/Groups/GroupListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,14 @@ private struct GroupListHeaderView: View {

var oweAmountText: String {
owedAmounts.map { (currency, amount) in
let currencySymbol = Currency.getCurrencyFromCode(currency).symbol
return "\(currencySymbol) \(abs(amount))"
return amount.formattedCurrency(currency)
}
.joined(separator: " + ")
}

var oweToYouAmountText: String {
owedToYouAmounts.map { (currency, amount) in
let currencySymbol = Currency.getCurrencyFromCode(currency).symbol
return "\(currencySymbol) \(abs(amount))"
return amount.formattedCurrency(currency)
}
.joined(separator: " + ")
}
Expand Down

0 comments on commit 1ebff4e

Please sign in to comment.