mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-16 11:10:00 +00:00
wip
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user