This commit is contained in:
spaced4ndy
2026-08-14 18:05:08 +04:00
parent bb912a7129
commit 2add2bdc4a
3 changed files with 15 additions and 2 deletions
+12 -1
View File
@@ -80,7 +80,7 @@ final class BadgeStore: ObservableObject {
switch state {
case .notLoaded, .loading: return .loading
case .loaded, .failed:
if let p = products[badgeProductId(level, period)] { return .price(p.displayPrice) }
if let p = products[badgeProductId(level, period)] { return .price(compactPrice(p)) }
return .unavailable
}
}
@@ -155,6 +155,17 @@ final class BadgeStore: ObservableObject {
}
}
// drops the fraction from whole amounts ("$7", not "$7.00") in the product's own currency style;
// Product.displayPrice remains the exact form for views that need the cents
private func compactPrice(_ product: Product) -> String {
var whole = Decimal()
var price = product.price
NSDecimalRound(&whole, &price, 0, .plain)
return whole == product.price
? product.price.formatted(product.priceFormatStyle.precision(.fractionLength(0)))
: product.displayPrice
}
private func storeReceipt(_ jws: String, _ t: Transaction, _ signatureVerified: Bool) -> BadgeStoreReceipt {
var environment: String? = nil
if #available(iOS 16.0, *) { environment = t.environment.rawValue }
@@ -143,11 +143,12 @@ struct BadgesPayView: View {
if let percent = savingsPercent(period) {
Text("Save \(percent)%")
.font(.caption)
.foregroundColor(theme.colors.primary)
.foregroundColor(isSelected ? theme.colors.primary : theme.colors.secondary)
}
}
.multilineTextAlignment(.center)
.padding(.vertical, 30)
.padding(.horizontal, 12)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.background(Color(uiColor: .secondarySystemGroupedBackground))
.clipShape(RoundedRectangle(cornerRadius: 16))
@@ -123,6 +123,7 @@ struct BadgesYourLevelView: View {
.padding(.bottom, 20)
}
.multilineTextAlignment(.center)
.padding(.horizontal, 12)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.background(Color(uiColor: .secondarySystemGroupedBackground))
.clipShape(RoundedRectangle(cornerRadius: 16))