Mercurial > public > geoquiz
comparison GeoQuiz/ContentView.swift @ 13:bdfff35dd43c
implement RevenueCat
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 12 Oct 2022 11:47:29 +0200 |
parents | 039b26a99a48 |
children | 136928bae534 |
comparison
equal
deleted
inserted
replaced
12:ce7ea84f67f5 | 13:bdfff35dd43c |
---|---|
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 | 9 |
10 struct ContentView: View { | 10 struct ContentView: View { |
11 @State private var gameModeSelection: GameMode? = nil | |
12 | |
11 @State private var showingBuyPremiumModalView = false | 13 @State private var showingBuyPremiumModalView = false |
12 @State private var showingSettingsModalView = false | 14 @State private var showingSettingsModalView = false |
13 @State private var showingProfileModalView = false | 15 @State private var showingProfileModalView = false |
14 | 16 |
17 @StateObject var storeKitRC = StoreKitRC() | |
18 | |
15 var body: some View { | 19 var body: some View { |
16 NavigationView { | 20 NavigationView { |
17 ScrollView(showsIndicators: false) { | 21 VStack { |
18 VStack(alignment: .leading, spacing: 30) { | 22 NavigationLink( |
19 Text("Select a game 🎮") | 23 destination: GuessTheFlagView(), |
20 .font(.largeTitle.bold()) | 24 tag: GameMode.guessTheFlag, |
21 .padding(.bottom) | 25 selection: $gameModeSelection) |
22 | 26 { |
23 NavigationLink(destination: GuessTheFlagView()) { | 27 EmptyView() |
24 GameButton( | 28 } |
25 gradient: .main, | 29 |
26 level: "Level 1", symbol: "flag.fill", name: "Guess the flag" | 30 NavigationLink( |
27 ) | 31 destination: GuessTheCapitalView(), |
32 tag: GameMode.guessTheCapital, | |
33 selection: $gameModeSelection) | |
34 { | |
35 EmptyView() | |
36 } | |
37 | |
38 NavigationLink( | |
39 destination: GuessTheCountryView(), | |
40 tag: GameMode.guessTheCountry, | |
41 selection: $gameModeSelection) | |
42 { | |
43 EmptyView() | |
44 } | |
45 | |
46 NavigationLink( | |
47 destination: GuessThePopulationView(), | |
48 tag: GameMode.guessThePopulation, | |
49 selection: $gameModeSelection) | |
50 { | |
51 EmptyView() | |
52 } | |
53 | |
54 ScrollView(showsIndicators: false) { | |
55 VStack(alignment: .leading, spacing: 30) { | |
56 Text("Select a game 🎮") | |
57 .font(.largeTitle.bold()) | |
58 .padding(.bottom) | |
59 | |
60 Button { | |
61 gameModeSelection = .guessTheFlag | |
62 } label: { | |
63 GameButton( | |
64 gradient: .main, | |
65 level: "Level 1", | |
66 symbol: "flag.fill", | |
67 name: "Guess the flag" | |
68 ) | |
69 } | |
70 | |
71 Button { | |
72 if storeKitRC.isActive { | |
73 gameModeSelection = .guessTheCapital | |
74 } else { | |
75 showingBuyPremiumModalView = true | |
76 } | |
77 } label: { | |
78 GameButton( | |
79 gradient: .secondary, | |
80 level: "Level 2", | |
81 symbol: storeKitRC.isActive ? "building.2.fill": "lock.fill", | |
82 name: "Guess the capital" | |
83 ) | |
84 } | |
85 | |
86 Button { | |
87 if storeKitRC.isActive { | |
88 gameModeSelection = .guessTheCountry | |
89 } else { | |
90 showingBuyPremiumModalView = true | |
91 } | |
92 } label: { | |
93 GameButton( | |
94 gradient: .tertiary, | |
95 level: "Level 3", | |
96 symbol: storeKitRC.isActive ? "globe.americas.fill": "lock.fill", | |
97 name: "Guess the country" | |
98 ) | |
99 } | |
100 | |
101 Button { | |
102 if storeKitRC.isActive { | |
103 gameModeSelection = .guessThePopulation | |
104 } else { | |
105 showingBuyPremiumModalView = true | |
106 } | |
107 } label: { | |
108 GameButton( | |
109 gradient: .quaternary, | |
110 level: "Level 4", | |
111 symbol: storeKitRC.isActive ? "person.fill": "lock.fill", | |
112 name: "Guess the population" | |
113 ) | |
114 } | |
28 } | 115 } |
29 | 116 .padding() |
30 NavigationLink(destination: GuessTheCapitalView()) { | |
31 GameButton( | |
32 gradient: .secondary, | |
33 level: "Level 2", symbol: "building.2.fill", name: "Guess the capital" | |
34 ) | |
35 } | |
36 | |
37 NavigationLink(destination: GuessTheCountryView()) { | |
38 GameButton( | |
39 gradient: .tertiary, | |
40 level: "Level 3", symbol: "globe.americas.fill", name: "Guess the country" | |
41 ) | |
42 } | |
43 | |
44 NavigationLink(destination: GuessThePopulationView()) { | |
45 GameButton( | |
46 gradient: .quaternary, | |
47 level: "Level 4", symbol: "person.fill", name: "Guess the population" | |
48 ) | |
49 } | |
50 } | 117 } |
51 .padding() | |
52 } | 118 } |
53 .navigationTitle("GeoQuiz") | 119 .navigationTitle("GeoQuiz") |
54 .navigationBarTitleDisplayMode(.inline) | 120 .navigationBarTitleDisplayMode(.inline) |
55 .toolbar { | 121 .toolbar { |
56 ToolbarItem(placement: .navigationBarLeading) { | 122 ToolbarItem(placement: .navigationBarLeading) { |
60 Label("Settings", systemImage: "gear") | 126 Label("Settings", systemImage: "gear") |
61 } | 127 } |
62 } | 128 } |
63 | 129 |
64 ToolbarItemGroup { | 130 ToolbarItemGroup { |
65 Button { | 131 if !storeKitRC.isActive { |
66 showingBuyPremiumModalView = true | 132 Button { |
67 } label: { | 133 showingBuyPremiumModalView = true |
68 Label("Buy premium", systemImage: "star") | 134 } label: { |
135 Label("Buy premium", systemImage: "star") | |
136 } | |
69 } | 137 } |
70 | 138 |
71 Button { | 139 Button { |
72 showingProfileModalView = true | 140 showingProfileModalView = true |
73 } label: { | 141 } label: { |
74 Label("Profile", systemImage: "person") | 142 Label("Profile", systemImage: "person") |
75 } | 143 } |
76 } | 144 } |
77 } | 145 } |
78 .sheet(isPresented: $showingBuyPremiumModalView) { | 146 .sheet(isPresented: $showingBuyPremiumModalView) { |
79 BuyPremiumModalView() | 147 BuyPremiumModalView(storeKitRC: storeKitRC) |
80 } | 148 } |
81 | 149 |
82 .sheet(isPresented: $showingSettingsModalView) { | 150 .sheet(isPresented: $showingSettingsModalView) { |
83 SettingsModalView() | 151 SettingsModalView() |
84 } | 152 } |