Mercurial > public > geoquiz
comparison GeoQuiz/BuyPremiumModalView.swift @ 12:ce7ea84f67f5
display product prices
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sun, 09 Oct 2022 19:46:44 +0200 |
parents | 039b26a99a48 |
children | bdfff35dd43c |
comparison
equal
deleted
inserted
replaced
11:039b26a99a48 | 12:ce7ea84f67f5 |
---|---|
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct BuyPremiumModalView: View { | 10 struct BuyPremiumModalView: View { |
11 @Environment(\.dismiss) var dismiss | 11 @Environment(\.dismiss) var dismiss |
12 @StateObject var storeKitRC = StoreKitRC() | |
12 | 13 |
13 var body: some View { | 14 var body: some View { |
14 NavigationView { | 15 NavigationView { |
15 ScrollView(showsIndicators: false) { | 16 ScrollView(showsIndicators: false) { |
16 VStack(alignment: .center, spacing: 20) { | 17 VStack(alignment: .center, spacing: 20) { |
52 Text("No subscriptions.") | 53 Text("No subscriptions.") |
53 .font(.title2) | 54 .font(.title2) |
54 .fontWeight(.semibold) | 55 .fontWeight(.semibold) |
55 .foregroundColor(.secondary) | 56 .foregroundColor(.secondary) |
56 | 57 |
57 Button { | 58 if let productPrice = storeKitRC.productPrice { |
58 // Buy | 59 Button { |
59 } label: { | 60 // Buy |
60 Text("Buy for $2.99") | 61 } label: { |
61 .font(.headline) | 62 Text("Buy for \(productPrice)") |
62 .padding() | 63 .font(.headline) |
64 .padding() | |
65 } | |
66 .buttonStyle(.borderedProminent) | |
67 .padding(.top) | |
68 } else { | |
69 ProgressView() | |
70 .padding(.top) | |
63 } | 71 } |
64 .buttonStyle(.borderedProminent) | |
65 .padding(.top) | |
66 } | 72 } |
67 .padding() | 73 .padding() |
68 | 74 |
69 VStack { | 75 VStack { |
70 Text("GeoQuiz is an indie game") | 76 Text("GeoQuiz is an indie game") |
71 Text("I appreciate your support ❤️") | 77 Text("I appreciate your support ❤️") |
72 } | 78 } |
73 .font(.callout) | 79 .font(.callout) |
74 .foregroundColor(.secondary) | 80 .foregroundColor(.secondary) |
81 .padding() | |
75 } | 82 } |
76 } | 83 } |
77 .navigationBarTitleDisplayMode(.inline) | 84 .navigationBarTitleDisplayMode(.inline) |
78 .toolbar { | 85 .toolbar { |
79 ToolbarItem(placement: .cancellationAction) { | 86 ToolbarItem(placement: .cancellationAction) { |
82 } label: { | 89 } label: { |
83 Label("Exit", systemImage: "multiply") | 90 Label("Exit", systemImage: "multiply") |
84 } | 91 } |
85 } | 92 } |
86 } | 93 } |
94 .alert("Something went wrong 🤕", isPresented: $storeKitRC.showingErrorAlert) { | |
95 Button("OK", role: .cancel) { dismiss() } | |
96 } message: { | |
97 Text(storeKitRC.errorMessage) | |
98 } | |
87 } | 99 } |
88 } | 100 } |
89 } | 101 } |
90 | 102 |
91 struct BuyPremiumModalView_Previews: PreviewProvider { | 103 struct BuyPremiumModalView_Previews: PreviewProvider { |