11
|
1 //
|
|
2 // BuyPremiumModalView.swift
|
|
3 // GeoQuiz
|
|
4 //
|
|
5 // Created by Dennis Concepción Martín on 9/10/22.
|
|
6 //
|
|
7
|
|
8 import SwiftUI
|
|
9
|
|
10 struct BuyPremiumModalView: View {
|
|
11 @Environment(\.dismiss) var dismiss
|
12
|
12 @StateObject var storeKitRC = StoreKitRC()
|
11
|
13
|
|
14 var body: some View {
|
|
15 NavigationView {
|
|
16 ScrollView(showsIndicators: false) {
|
|
17 VStack(alignment: .center, spacing: 20) {
|
|
18 VStack(spacing: 20) {
|
|
19 Text("Unlock Premium 🤩")
|
|
20 .font(.largeTitle.bold())
|
|
21
|
|
22 Text("Unlock three more game modes to become a geography master and support the future development of GeoQuiz.")
|
|
23 .foregroundColor(.secondary)
|
|
24 .multilineTextAlignment(.center)
|
|
25 .frame(maxWidth: 400)
|
|
26 }
|
|
27 .padding()
|
|
28
|
|
29 ScrollView(.horizontal, showsIndicators: false) {
|
|
30 HStack(spacing: 20) {
|
|
31 Group {
|
|
32 Image("GuessTheCapital")
|
|
33 .resizable()
|
|
34
|
|
35 Image("GuessTheCountry")
|
|
36 .resizable()
|
|
37
|
|
38 Image("GuessThePopulation")
|
|
39 .resizable()
|
|
40 }
|
|
41 .scaledToFit()
|
|
42 .cornerRadius(25)
|
|
43 .frame(height: 500)
|
|
44 }
|
|
45 .padding()
|
|
46 }
|
|
47
|
|
48 VStack(spacing: 10) {
|
|
49 Text("A one-time payment.")
|
|
50 .font(.title)
|
|
51 .fontWeight(.semibold)
|
|
52
|
|
53 Text("No subscriptions.")
|
|
54 .font(.title2)
|
|
55 .fontWeight(.semibold)
|
|
56 .foregroundColor(.secondary)
|
|
57
|
12
|
58 if let productPrice = storeKitRC.productPrice {
|
|
59 Button {
|
|
60 // Buy
|
|
61 } label: {
|
|
62 Text("Buy for \(productPrice)")
|
|
63 .font(.headline)
|
|
64 .padding()
|
|
65 }
|
|
66 .buttonStyle(.borderedProminent)
|
|
67 .padding(.top)
|
|
68 } else {
|
|
69 ProgressView()
|
|
70 .padding(.top)
|
11
|
71 }
|
|
72 }
|
|
73 .padding()
|
|
74
|
|
75 VStack {
|
|
76 Text("GeoQuiz is an indie game")
|
|
77 Text("I appreciate your support ❤️")
|
|
78 }
|
|
79 .font(.callout)
|
|
80 .foregroundColor(.secondary)
|
12
|
81 .padding()
|
11
|
82 }
|
|
83 }
|
|
84 .navigationBarTitleDisplayMode(.inline)
|
|
85 .toolbar {
|
|
86 ToolbarItem(placement: .cancellationAction) {
|
|
87 Button {
|
|
88 dismiss()
|
|
89 } label: {
|
|
90 Label("Exit", systemImage: "multiply")
|
|
91 }
|
|
92 }
|
|
93 }
|
12
|
94 .alert("Something went wrong 🤕", isPresented: $storeKitRC.showingErrorAlert) {
|
|
95 Button("OK", role: .cancel) { dismiss() }
|
|
96 } message: {
|
|
97 Text(storeKitRC.errorMessage)
|
|
98 }
|
11
|
99 }
|
|
100 }
|
|
101 }
|
|
102
|
|
103 struct BuyPremiumModalView_Previews: PreviewProvider {
|
|
104 static var previews: some View {
|
|
105 BuyPremiumModalView()
|
|
106 }
|
|
107 }
|