IAP
This commit is contained in:
@@ -17,9 +17,12 @@ struct PurchaseButtonView: View {
|
||||
}
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
||||
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
||||
|
||||
var iapManager: IAPManager
|
||||
|
||||
private let height: Float
|
||||
private let showCountdownTimer: Bool
|
||||
private let showManageSubClosure: (() -> Void)?
|
||||
|
||||
@State var isPurchasing: Bool = false
|
||||
@@ -30,10 +33,11 @@ struct PurchaseButtonView: View {
|
||||
}
|
||||
}
|
||||
|
||||
public init(height: Float, iapManager: IAPManager, showManageSubClosure: (() -> Void)? = nil) {
|
||||
public init(height: Float, iapManager: IAPManager, showManageSubClosure: (() -> Void)? = nil, showCountdownTimer: Bool = false) {
|
||||
self.height = height
|
||||
self.showManageSubClosure = showManageSubClosure
|
||||
self.iapManager = iapManager
|
||||
self.showCountdownTimer = showCountdownTimer
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -95,6 +99,7 @@ struct PurchaseButtonView: View {
|
||||
private var buyOptionsView: some View {
|
||||
VStack {
|
||||
ZStack {
|
||||
theme.currentTheme.secondaryBGColor
|
||||
VStack(spacing: 20) {
|
||||
Text(String(localized: "purchase_view_title"))
|
||||
.font(.body)
|
||||
@@ -102,6 +107,34 @@ struct PurchaseButtonView: View {
|
||||
.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: {
|
||||
|
||||
Reference in New Issue
Block a user