|
private var paymentButtons: some View { |
|
VStack { |
|
HStack(spacing: 0) { |
|
sub.map{ sub in |
|
makeBorderedButton(action: { |
|
self.buttonAction(purchase: sub) |
|
}, label: self.subscriptionManager.subscriptionStatus == .subscribed ? |
|
"Thanks!" : |
|
"\(formattedPrice(for: sub)) Monthly") |
|
.opacity(subscriptionManager.inPaymentProgress ? 0.5 : 1.0) |
|
.disabled(subscriptionManager.inPaymentProgress) |
|
} |
|
|
|
Spacer(minLength: 18) |
|
|
|
yearlySub.map{ yearlySub in |
|
makeBorderedButton(action: { |
|
self.buttonAction(purchase: yearlySub) |
|
}, label: self.subscriptionManager.subscriptionStatus == .subscribed ? |
|
"Thanks!" : |
|
"\(formattedPrice(for: yearlySub)) Yearly") |
|
.opacity(subscriptionManager.inPaymentProgress ? 0.5 : 1.0) |
|
.disabled(subscriptionManager.inPaymentProgress) |
|
} |
|
}.frame(maxWidth: 320) |
|
|
|
lifetime.map{ lifetime in |
|
makeBorderedButton(action: { |
|
self.buttonAction(purchase: lifetime) |
|
}, label: self.subscriptionManager.subscriptionStatus == .subscribed ? |
|
"Thank you for your support!" : |
|
"Buy lifetime AC Helper+ for \(formattedPrice(for: lifetime))") |
|
.opacity(subscriptionManager.inPaymentProgress ? 0.5 : 1.0) |
|
.disabled(subscriptionManager.inPaymentProgress) |
|
.padding(.top, 16) |
|
}.frame(maxWidth: 320) |
|
} |
|
} |
|
|
|
private func buttonAction(purchase: Purchases.Package) { |
|
if subscriptionManager.subscriptionStatus == .subscribed { |
|
presentationMode.wrappedValue.dismiss() |
|
} else { |
|
subscriptionManager.purchase(source: self.source.rawValue, |
|
product: purchase) |
|
} |
|
} |
|
|
|
private func makeBorderedButton(action: @escaping () -> Void, label: |
|
LocalizedStringKey) -> some View { |
|
Button(action: action) { |
|
Text(label) |
|
.font(.headline) |
|
.fontWeight(.bold) |
|
.foregroundColor(.white) |
|
.minimumScaleFactor(0.01) |
|
.lineLimit(1) |
|
.frame(maxWidth: .infinity, |
|
maxHeight: 30) |
|
}.buttonStyle(PlainRoundedButton()).accentColor(.acTabBarTint).safeHoverEffect() |
|
} |