Mercurial > public > geoquiz
comparison GeoQuiz/ContentView.swift @ 26:425078c01194
refactor code
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Wed, 09 Nov 2022 10:30:01 +0100 |
parents | b145c408f791 |
children | 3f4b366d476d |
comparison
equal
deleted
inserted
replaced
25:b3df0f5dc750 | 26:425078c01194 |
---|---|
11 @State private var path: [GameType] = [] | 11 @State private var path: [GameType] = [] |
12 @State private var showingBuyPremiumModalView = false | 12 @State private var showingBuyPremiumModalView = false |
13 @State private var showingSettingsModalView = false | 13 @State private var showingSettingsModalView = false |
14 @State private var showingProfileModalView = false | 14 @State private var showingProfileModalView = false |
15 | 15 |
16 @StateObject var storeKitController = StoreKitController() | 16 @StateObject var storeController = StoreController() |
17 @StateObject var userController = UserController() | 17 @StateObject var userController = UserController() |
18 | 18 |
19 let premiumGames: [GameType] = [.guessTheCapital, .guessTheCountry, .guessThePopulation] | 19 let premiumGames: [GameType] = [.guessTheCapital, .guessTheCountry, .guessThePopulation] |
20 | 20 |
21 var body: some View { | 21 var body: some View { |
36 GameButton(gameType: .guessTheFlag, isActive: true) | 36 GameButton(gameType: .guessTheFlag, isActive: true) |
37 } | 37 } |
38 | 38 |
39 ForEach(premiumGames, id: \.rawValue) { gameType in | 39 ForEach(premiumGames, id: \.rawValue) { gameType in |
40 Button { | 40 Button { |
41 if storeKitController.premiumIsActive { | 41 if storeController.premiumIsActive { |
42 path.append(gameType) | 42 path.append(gameType) |
43 } else { | 43 } else { |
44 showingBuyPremiumModalView = true | 44 showingBuyPremiumModalView = true |
45 } | 45 } |
46 } label: { | 46 } label: { |
47 GameButton(gameType: gameType, isActive: storeKitController.premiumIsActive) | 47 GameButton(gameType: gameType, isActive: storeController.premiumIsActive) |
48 } | 48 } |
49 } | 49 } |
50 } | 50 } |
51 .padding() | 51 .padding() |
52 } | 52 } |
74 Label("Settings", systemImage: "gear") | 74 Label("Settings", systemImage: "gear") |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 ToolbarItemGroup { | 78 ToolbarItemGroup { |
79 if !storeKitController.premiumIsActive { | 79 if !storeController.premiumIsActive { |
80 Button { | 80 Button { |
81 showingBuyPremiumModalView = true | 81 showingBuyPremiumModalView = true |
82 } label: { | 82 } label: { |
83 Label("Buy premium", systemImage: "star") | 83 Label("Buy premium", systemImage: "star") |
84 } | 84 } |
90 Label("Profile", systemImage: "person") | 90 Label("Profile", systemImage: "person") |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 .sheet(isPresented: $showingBuyPremiumModalView) { | 94 .sheet(isPresented: $showingBuyPremiumModalView) { |
95 BuyPremiumModalView(storeKitController: storeKitController) | 95 BuyPremiumModalView(storeController: storeController) |
96 } | 96 } |
97 | 97 |
98 .sheet(isPresented: $showingSettingsModalView) { | 98 .sheet(isPresented: $showingSettingsModalView) { |
99 SettingsModalView(user: userController) | 99 SettingsModalView(userController: userController) |
100 } | 100 } |
101 | 101 |
102 .sheet(isPresented: $showingProfileModalView) { | 102 .sheet(isPresented: $showingProfileModalView) { |
103 ProfileModalView(userController: userController, storeKitController: storeKitController) | 103 ProfileModalView(userController: userController, storeController: storeController) |
104 } | 104 } |
105 } | 105 } |
106 .navigationViewStyle(StackNavigationViewStyle()) | 106 .navigationViewStyle(StackNavigationViewStyle()) |
107 } | 107 } |
108 } | 108 } |