Use Apple's SubscriptionStoreView for subscription UI instead of custom pricing cards. Onboarding flow keeps feature pages but embeds PaywallView for the pricing page. Removes ~500 lines of custom pricing UI (PricingOptionCard, OnboardingPricingRow, PricingBackground, SportsIconWithGlow). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
71 lines
2.2 KiB
Swift
71 lines
2.2 KiB
Swift
//
|
|
// PaywallView.swift
|
|
// SportsTime
|
|
//
|
|
// Full-screen paywall for Pro subscription using SubscriptionStoreView.
|
|
//
|
|
|
|
import SwiftUI
|
|
import StoreKit
|
|
|
|
struct PaywallView: View {
|
|
@Environment(\.dismiss) private var dismiss
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
private let storeManager = StoreManager.shared
|
|
|
|
var body: some View {
|
|
SubscriptionStoreView(subscriptions: storeManager.products.filter { $0.subscription != nil }) {
|
|
VStack(spacing: Theme.Spacing.md) {
|
|
Image(systemName: "star.circle.fill")
|
|
.font(.system(size: 60))
|
|
.foregroundStyle(Theme.warmOrange)
|
|
|
|
Text("Upgrade to Pro")
|
|
.font(.largeTitle.bold())
|
|
.foregroundStyle(Theme.textPrimary(colorScheme))
|
|
|
|
Text("Unlock the full SportsTime experience")
|
|
.font(.body)
|
|
.foregroundStyle(Theme.textSecondary(colorScheme))
|
|
|
|
HStack(spacing: Theme.Spacing.lg) {
|
|
featurePill(icon: "infinity", text: "Unlimited Trips")
|
|
featurePill(icon: "doc.fill", text: "PDF Export")
|
|
featurePill(icon: "trophy.fill", text: "Progress")
|
|
}
|
|
.padding(.top, Theme.Spacing.sm)
|
|
}
|
|
.padding(Theme.Spacing.lg)
|
|
}
|
|
.storeButton(.visible, for: .restorePurchases)
|
|
.subscriptionStoreControlStyle(.prominentPicker)
|
|
.subscriptionStoreButtonLabel(.displayName.multiline)
|
|
.onInAppPurchaseCompletion { _, result in
|
|
if case .success(.success) = result {
|
|
dismiss()
|
|
}
|
|
}
|
|
.task {
|
|
await storeManager.loadProducts()
|
|
}
|
|
}
|
|
|
|
private func featurePill(icon: String, text: String) -> some View {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: icon)
|
|
.font(.system(size: 11))
|
|
Text(text)
|
|
.font(.caption2)
|
|
}
|
|
.foregroundStyle(Theme.textMuted(colorScheme))
|
|
.padding(.horizontal, 10)
|
|
.padding(.vertical, 6)
|
|
.background(Theme.warmOrange.opacity(0.08), in: Capsule())
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
PaywallView()
|
|
}
|