From 2add2bdc4a4b9855a8370d5a981ac64e1c686df7 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 14 Aug 2026 18:05:08 +0400 Subject: [PATCH] wip --- apps/ios/Shared/Views/Badges/BadgeStore.swift | 13 ++++++++++++- apps/ios/Shared/Views/Badges/BadgesPayView.swift | 3 ++- .../Shared/Views/Badges/BadgesYourLevelView.swift | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/ios/Shared/Views/Badges/BadgeStore.swift b/apps/ios/Shared/Views/Badges/BadgeStore.swift index da4fe8831b..323fd4e83a 100644 --- a/apps/ios/Shared/Views/Badges/BadgeStore.swift +++ b/apps/ios/Shared/Views/Badges/BadgeStore.swift @@ -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 } diff --git a/apps/ios/Shared/Views/Badges/BadgesPayView.swift b/apps/ios/Shared/Views/Badges/BadgesPayView.swift index 6bc7fce472..34c02244f4 100644 --- a/apps/ios/Shared/Views/Badges/BadgesPayView.swift +++ b/apps/ios/Shared/Views/Badges/BadgesPayView.swift @@ -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)) diff --git a/apps/ios/Shared/Views/Badges/BadgesYourLevelView.swift b/apps/ios/Shared/Views/Badges/BadgesYourLevelView.swift index 153c16e391..eb2396c655 100644 --- a/apps/ios/Shared/Views/Badges/BadgesYourLevelView.swift +++ b/apps/ios/Shared/Views/Badges/BadgesYourLevelView.swift @@ -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))