This commit is contained in:
Trey t
2022-12-23 09:43:48 -06:00
parent 49e3812659
commit 488832b777
9 changed files with 195 additions and 167 deletions

View File

@@ -100,65 +100,77 @@ struct PurchaseButtonView: View {
VStack {
ZStack {
theme.currentTheme.secondaryBGColor
VStack(spacing: 20) {
Text(String(localized: "purchase_view_title"))
.font(.body)
.bold()
.foregroundColor(textColor)
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
if showCountdownTimer {
if let date = Calendar.current.date(byAdding: .day, value: 30, to: firstLaunchDate) {
HStack {
if iapManager.daysLeftBeforeIAP > 0 {
Text(String(localized: "purchase_view_current_subscription_expires_in"))
.font(.body)
.bold()
.foregroundColor(textColor)
Text(date, style: .relative)
.font(.body)
.bold()
.foregroundColor(textColor)
} else {
Text(String(localized: "purchase_view_current_subscription_expired_on"))
.font(.body)
.bold()
.foregroundColor(textColor)
Text(date, style: .date)
.font(.body)
.bold()
.foregroundColor(textColor)
}
}
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
}
}
HStack {
ForEach(iapManager.sortedSubscriptionKeysByPriceOptions) { product in
Button(action: {
purchase(product: product)
}, label: {
Text("\(product.displayPrice)\n\(product.displayName)")
.foregroundColor(.white)
.bold()
.frame(maxWidth: .infinity)
.contentShape(Rectangle())
})
.padding()
.frame(maxWidth: .infinity)
.background(RoundedRectangle(cornerRadius: 10).fill(iapManager.colorForIAPButton(iapIdentifier: product.id)))
}
}
}
.padding([.leading, .trailing])
.frame(minWidth: 0, maxWidth: .infinity)
if iapManager.isLoadingSubscriptions {
VStack(spacing: 20) {
Text(String(localized: "purchase_view_loading"))
.font(.body)
.bold()
.frame(minWidth: 0, maxWidth: .infinity, alignment: .center)
ProgressView()
}
} else {
VStack(spacing: 20) {
Text(String(localized: "purchase_view_title"))
.font(.body)
.bold()
.foregroundColor(textColor)
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
if showCountdownTimer {
if let date = Calendar.current.date(byAdding: .day, value: 30, to: firstLaunchDate) {
HStack {
if iapManager.daysLeftBeforeIAP > 0 {
Text(String(localized: "purchase_view_current_subscription_expires_in"))
.font(.body)
.bold()
.foregroundColor(textColor)
Text(date, style: .relative)
.font(.body)
.bold()
.foregroundColor(textColor)
} else {
Text(String(localized: "purchase_view_current_subscription_expired_on"))
.font(.body)
.bold()
.foregroundColor(textColor)
Text(date, style: .date)
.font(.body)
.bold()
.foregroundColor(textColor)
}
}
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
}
}
HStack {
ForEach(iapManager.sortedSubscriptionKeysByPriceOptions) { product in
Button(action: {
purchase(product: product)
}, label: {
Text("\(product.displayPrice)\n\(product.displayName)")
.foregroundColor(.white)
.bold()
.frame(maxWidth: .infinity)
.contentShape(Rectangle())
})
.padding()
.frame(maxWidth: .infinity)
.background(RoundedRectangle(cornerRadius: 10).fill(iapManager.colorForIAPButton(iapIdentifier: product.id)))
}
}
}
.padding([.leading, .trailing])
.frame(minWidth: 0, maxWidth: .infinity)
}
}
.background(.ultraThinMaterial)
.frame(minWidth: 0, maxWidth: .infinity)
}
.background(.ultraThinMaterial)
.frame(minWidth: 0, maxWidth: .infinity)
.background(.clear)
}