# HG changeset patch # User Dennis C. M. # Date 1664902464 -7200 # Node ID d945e52b07044f3344d2d30e8e90e26970554efa # Parent 1946bbfde4af8944bd141ff41447840e15ad7fca implement dynamic map diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz.xcodeproj/project.pbxproj --- a/GeoQuiz.xcodeproj/project.pbxproj Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz.xcodeproj/project.pbxproj Tue Oct 04 18:54:24 2022 +0200 @@ -9,8 +9,8 @@ /* Begin PBXBuildFile section */ 95030CEA28D1BA4D001AA3A1 /* AnswerButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95030CE928D1BA4D001AA3A1 /* AnswerButton.swift */; }; 9509A8DE28E5A19A00CFCDBA /* countries.json in Resources */ = {isa = PBXBuildFile; fileRef = 9509A8DD28E5A19A00CFCDBA /* countries.json */; }; - 9509A8E028E5A3C500CFCDBA /* GuessTheCurrency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9509A8DF28E5A3C500CFCDBA /* GuessTheCurrency.swift */; }; - 9509A8E228E5A3D700CFCDBA /* GuessThePopulation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9509A8E128E5A3D700CFCDBA /* GuessThePopulation.swift */; }; + 9509A8E028E5A3C500CFCDBA /* GuessTheCurrencyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9509A8DF28E5A3C500CFCDBA /* GuessTheCurrencyView.swift */; }; + 9509A8E228E5A3D700CFCDBA /* GuessThePopulationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9509A8E128E5A3D700CFCDBA /* GuessThePopulationView.swift */; }; 951AFAEA28E5655C00A4A4BD /* cities.json in Resources */ = {isa = PBXBuildFile; fileRef = 951AFAE828E5655C00A4A4BD /* cities.json */; }; 951AFAED28E5657500A4A4BD /* CityModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951AFAEC28E5657500A4A4BD /* CityModel.swift */; }; 951AFAEF28E565FE00A4A4BD /* CountryModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951AFAEE28E565FE00A4A4BD /* CountryModel.swift */; }; @@ -18,7 +18,6 @@ 951B630228D1A87C004F9877 /* GuessTheCapitalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951B630128D1A87C004F9877 /* GuessTheCapitalView.swift */; }; 951D197328D485E000671FAD /* CustomColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951D197228D485E000671FAD /* CustomColors.swift */; }; 952E41E928DC521200198643 /* GameAlertsModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952E41E828DC521200198643 /* GameAlertsModifier.swift */; }; - 952E41EB28DC612400198643 /* GameStatsModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952E41EA28DC612400198643 /* GameStatsModalView.swift */; }; 952E41ED28DC658900198643 /* SettingsModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952E41EC28DC658900198643 /* SettingsModalView.swift */; }; 952E41EF28DC692200198643 /* PlaySound.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952E41EE28DC692200198643 /* PlaySound.swift */; }; 952E41F228DC6F6E00198643 /* correctAnswer.wav in Resources */ = {isa = PBXBuildFile; fileRef = 952E41F028DC6F6D00198643 /* correctAnswer.wav */; }; @@ -31,11 +30,9 @@ 955A65A928D7815E00CEEC6D /* Haptics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955A65A828D7815E00CEEC6D /* Haptics.swift */; }; 956273EA28CB2E98008DC094 /* FlagImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 956273E928CB2E98008DC094 /* FlagImage.swift */; }; 9590359528E098FF00B24560 /* ProfileModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9590359428E098FF00B24560 /* ProfileModalView.swift */; }; - 9590359728E09AB000B24560 /* GameSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9590359628E09AB000B24560 /* GameSelector.swift */; }; - 959D257028C7251F00C55A5E /* BuyLivesModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 959D256F28C7251F00C55A5E /* BuyLivesModalView.swift */; }; 95AE8D5728C8750E0067F219 /* Load.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AE8D5628C8750E0067F219 /* Load.swift */; }; 95AF322A28DF293900023ACC /* GuessTheCountryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AF322928DF293900023ACC /* GuessTheCountryView.swift */; }; - 95AF322C28DF2BE700023ACC /* CityMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95AF322B28DF2BE700023ACC /* CityMap.swift */; }; + 95BC392D28EC42570049AB49 /* CityMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95BC392C28EC42570049AB49 /* CityMap.swift */; }; 95C430F928D0A8E500480D23 /* CustomGradients.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C430F828D0A8E500480D23 /* CustomGradients.swift */; }; 95C4315628C64A8C00212131 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C4315528C64A8C00212131 /* ContentView.swift */; }; 95C4315928C6500000212131 /* GameButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95C4315828C6500000212131 /* GameButton.swift */; }; @@ -46,8 +43,8 @@ /* Begin PBXFileReference section */ 95030CE928D1BA4D001AA3A1 /* AnswerButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnswerButton.swift; sourceTree = ""; }; 9509A8DD28E5A19A00CFCDBA /* countries.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = countries.json; sourceTree = ""; }; - 9509A8DF28E5A3C500CFCDBA /* GuessTheCurrency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuessTheCurrency.swift; sourceTree = ""; }; - 9509A8E128E5A3D700CFCDBA /* GuessThePopulation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuessThePopulation.swift; sourceTree = ""; }; + 9509A8DF28E5A3C500CFCDBA /* GuessTheCurrencyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuessTheCurrencyView.swift; sourceTree = ""; }; + 9509A8E128E5A3D700CFCDBA /* GuessThePopulationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuessThePopulationView.swift; sourceTree = ""; }; 951AFAE828E5655C00A4A4BD /* cities.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = cities.json; sourceTree = ""; }; 951AFAEC28E5657500A4A4BD /* CityModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityModel.swift; sourceTree = ""; }; 951AFAEE28E565FE00A4A4BD /* CountryModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryModel.swift; sourceTree = ""; }; @@ -55,7 +52,6 @@ 951B630128D1A87C004F9877 /* GuessTheCapitalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuessTheCapitalView.swift; sourceTree = ""; }; 951D197228D485E000671FAD /* CustomColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomColors.swift; sourceTree = ""; }; 952E41E828DC521200198643 /* GameAlertsModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameAlertsModifier.swift; sourceTree = ""; }; - 952E41EA28DC612400198643 /* GameStatsModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameStatsModalView.swift; sourceTree = ""; }; 952E41EC28DC658900198643 /* SettingsModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsModalView.swift; sourceTree = ""; }; 952E41EE28DC692200198643 /* PlaySound.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaySound.swift; sourceTree = ""; }; 952E41F028DC6F6D00198643 /* correctAnswer.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = correctAnswer.wav; sourceTree = ""; }; @@ -69,11 +65,9 @@ 955A65A828D7815E00CEEC6D /* Haptics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Haptics.swift; sourceTree = ""; }; 956273E928CB2E98008DC094 /* FlagImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlagImage.swift; sourceTree = ""; }; 9590359428E098FF00B24560 /* ProfileModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileModalView.swift; sourceTree = ""; }; - 9590359628E09AB000B24560 /* GameSelector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameSelector.swift; sourceTree = ""; }; - 959D256F28C7251F00C55A5E /* BuyLivesModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuyLivesModalView.swift; sourceTree = ""; }; 95AE8D5628C8750E0067F219 /* Load.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Load.swift; sourceTree = ""; }; 95AF322928DF293900023ACC /* GuessTheCountryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GuessTheCountryView.swift; sourceTree = ""; }; - 95AF322B28DF2BE700023ACC /* CityMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityMap.swift; sourceTree = ""; }; + 95BC392C28EC42570049AB49 /* CityMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CityMap.swift; sourceTree = ""; }; 95C430F828D0A8E500480D23 /* CustomGradients.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomGradients.swift; sourceTree = ""; }; 95C4315528C64A8C00212131 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 95C4315828C6500000212131 /* GameButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameButton.swift; sourceTree = ""; }; @@ -96,7 +90,6 @@ 95030CE728D1B60F001AA3A1 /* Logic */ = { isa = PBXGroup; children = ( - 9590359628E09AB000B24560 /* GameSelector.swift */, 95AE8D5628C8750E0067F219 /* Load.swift */, 955A65A828D7815E00CEEC6D /* Haptics.swift */, 952E41EE28DC692200198643 /* PlaySound.swift */, @@ -143,13 +136,11 @@ 95C4315528C64A8C00212131 /* ContentView.swift */, 95FA409928D9876B00129B60 /* GuessTheFlagView.swift */, 951B630128D1A87C004F9877 /* GuessTheCapitalView.swift */, - 9509A8DF28E5A3C500CFCDBA /* GuessTheCurrency.swift */, - 9509A8E128E5A3D700CFCDBA /* GuessThePopulation.swift */, + 9509A8DF28E5A3C500CFCDBA /* GuessTheCurrencyView.swift */, + 9509A8E128E5A3D700CFCDBA /* GuessThePopulationView.swift */, 95AF322928DF293900023ACC /* GuessTheCountryView.swift */, 9590359428E098FF00B24560 /* ProfileModalView.swift */, 952E41EC28DC658900198643 /* SettingsModalView.swift */, - 959D256F28C7251F00C55A5E /* BuyLivesModalView.swift */, - 952E41EA28DC612400198643 /* GameStatsModalView.swift */, 959D414728C87EA600BAAC14 /* Helpers */, 959D414528C87E8D00BAAC14 /* Models */, 95030CE728D1B60F001AA3A1 /* Logic */, @@ -186,7 +177,7 @@ 952E41E828DC521200198643 /* GameAlertsModifier.swift */, 95C430F828D0A8E500480D23 /* CustomGradients.swift */, 951D197228D485E000671FAD /* CustomColors.swift */, - 95AF322B28DF2BE700023ACC /* CityMap.swift */, + 95BC392C28EC42570049AB49 /* CityMap.swift */, ); path = Helpers; sourceTree = ""; @@ -266,19 +257,17 @@ buildActionMask = 2147483647; files = ( 955A65A928D7815E00CEEC6D /* Haptics.swift in Sources */, + 95BC392D28EC42570049AB49 /* CityMap.swift in Sources */, 952E41E928DC521200198643 /* GameAlertsModifier.swift in Sources */, - 9509A8E228E5A3D700CFCDBA /* GuessThePopulation.swift in Sources */, + 9509A8E228E5A3D700CFCDBA /* GuessThePopulationView.swift in Sources */, 955A658328D733E400CEEC6D /* Game.swift in Sources */, 95C4315628C64A8C00212131 /* ContentView.swift in Sources */, 95C4315928C6500000212131 /* GameButton.swift in Sources */, - 95AF322C28DF2BE700023ACC /* CityMap.swift in Sources */, 956273EA28CB2E98008DC094 /* FlagImage.swift in Sources */, 952E41EF28DC692200198643 /* PlaySound.swift in Sources */, 951AFAED28E5657500A4A4BD /* CityModel.swift in Sources */, - 9590359728E09AB000B24560 /* GameSelector.swift in Sources */, - 959D257028C7251F00C55A5E /* BuyLivesModalView.swift in Sources */, 951B630228D1A87C004F9877 /* GuessTheCapitalView.swift in Sources */, - 9509A8E028E5A3C500CFCDBA /* GuessTheCurrency.swift in Sources */, + 9509A8E028E5A3C500CFCDBA /* GuessTheCurrencyView.swift in Sources */, 9539829328C51EDE00B70973 /* GeoQuizApp.swift in Sources */, 95AF322A28DF293900023ACC /* GuessTheCountryView.swift in Sources */, 951AFAEF28E565FE00A4A4BD /* CountryModel.swift in Sources */, @@ -291,7 +280,6 @@ 95C430F928D0A8E500480D23 /* CustomGradients.swift in Sources */, 952E41ED28DC658900198643 /* SettingsModalView.swift in Sources */, 95FA409A28D9876B00129B60 /* GuessTheFlagView.swift in Sources */, - 952E41EB28DC612400198643 /* GameStatsModalView.swift in Sources */, 951AFAF128E5735400A4A4BD /* CityGame.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/AtomicTangerine.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/AtomicTangerine.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/AtomicTangerine.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.329", - "green" : "0.557", - "red" : "0.969" + "blue" : "74", + "green" : "132", + "red" : "247" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/BlueBell.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/BlueBell.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/BlueBell.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.796", - "green" : "0.561", - "red" : "0.616" + "blue" : "193", + "green" : "133", + "red" : "157" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/ChinaPink.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/ChinaPink.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/ChinaPink.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.616", - "green" : "0.467", - "red" : "0.867" + "blue" : "147", + "green" : "109", + "red" : "221" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/MaizeCrayola.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/MaizeCrayola.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/MaizeCrayola.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.329", - "green" : "0.780", - "red" : "0.973" + "blue" : "74", + "green" : "189", + "red" : "248" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/MayaBlue.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/MayaBlue.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/MayaBlue.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.973", - "green" : "0.733", - "red" : "0.322" + "blue" : "238", + "green" : "177", + "red" : "82" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/MiddleRed.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/MiddleRed.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/MiddleRed.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.443", - "green" : "0.561", - "red" : "0.875" + "blue" : "103", + "green" : "133", + "red" : "223" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/PinkLavender.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/PinkLavender.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/PinkLavender.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.906", - "green" : "0.765", - "red" : "0.933" + "blue" : "221", + "green" : "185", + "red" : "238" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Assets.xcassets/Custom colors/RoyalLightBlue.colorset/Contents.json --- a/GeoQuiz/Assets.xcassets/Custom colors/RoyalLightBlue.colorset/Contents.json Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Assets.xcassets/Custom colors/RoyalLightBlue.colorset/Contents.json Tue Oct 04 18:54:24 2022 +0200 @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.894", - "green" : "0.451", - "red" : "0.353" + "blue" : "218", + "green" : "105", + "red" : "90" } }, "idiom" : "universal" diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/BuyLivesModalView.swift --- a/GeoQuiz/BuyLivesModalView.swift Thu Sep 29 12:00:17 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -// -// BuyLivesModalView.swift -// GeoQuiz -// -// Created by Dennis Concepción Martín on 6/9/22. -// - -import SwiftUI - -struct BuyLivesModalView: View { - @Environment(\.dismiss) var dismiss - - var body: some View { - ScrollView { - HStack { - Spacer() - Button { - dismiss() - } label: { - Image(systemName: "multiply") - .imageScale(.large) - - } - } - .padding([.trailing, .top]) - - Section { - VStack(spacing: 20) { - Text("Buy lifes") - .font(.largeTitle) - .fontWeight(.semibold) - - Text("Keep learning about countries.") - .font(.headline) - .foregroundColor(.secondary) - - Image("heart") - .resizable() - .scaledToFit() - .frame(width: 180) - .padding(40) - .background( - Color.blue.opacity(0.5) - .cornerRadius(20) - .shadow(radius: 20) - ) - .padding() - - VStack(spacing: 30) { - - } - } - .padding() - } footer: { - Text("GeoQuiz is an indie app made by just one person. I'm glad that you are considering buying lifes to keep playing GeoQuiz.") - .font(.callout) - .foregroundColor(.secondary) - .padding() - } - } - } -} - -struct BuyLivesModalView_Previews: PreviewProvider { - static var previews: some View { - BuyLivesModalView() - } -} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/ContentView.swift --- a/GeoQuiz/ContentView.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/ContentView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -8,8 +8,7 @@ import SwiftUI struct ContentView: View { - @State private var gameName: GameName? = nil - @State private var showingBuyLivesModalView = false + @State private var showingBuyPremiumModalView = false @State private var showingSettingsModalView = false var body: some View { @@ -17,33 +16,21 @@ ScrollView(showsIndicators: false) { VStack(spacing: 20) { - NavigationLink( - destination: GuessTheFlagView(gameName: $gameName), - tag: GameName.guessTheFlag, - selection: $gameName - ) { + NavigationLink(destination: GuessTheFlagView()) { GameButton( gradient: .main, level: "Level 1", symbol: "flag.fill", name: "Guess the flag" ) } - NavigationLink( - destination: GuessTheCapitalView(gameName: $gameName), - tag: GameName.guessTheCapital, - selection: $gameName - ) { + NavigationLink(destination: GuessTheCapitalView()) { GameButton( gradient: .secondary, level: "Level 2", symbol: "building.2.fill", name: "Guess the capital" ) } - NavigationLink( - destination: GuessTheCountryView(gameName: $gameName), - tag: GameName.guessTheCountry, - selection: $gameName - ) { + NavigationLink(destination: GuessTheCountryView()) { GameButton( gradient: .tertiary, level: "Level 3", symbol: "globe.americas.fill", name: "Guess the country" @@ -75,14 +62,14 @@ ToolbarItemGroup { Button { - showingBuyLivesModalView = true + showingBuyPremiumModalView = true } label: { - Label("Buy lives", systemImage: "heart.fill") + Label("Buy premium", systemImage: "star") } } } - .sheet(isPresented: $showingBuyLivesModalView) { - BuyLivesModalView() + .sheet(isPresented: $showingBuyPremiumModalView) { + Text("Buy premium") } .sheet(isPresented: $showingSettingsModalView) { diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GameStatsModalView.swift --- a/GeoQuiz/GameStatsModalView.swift Thu Sep 29 12:00:17 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -//// -//// GameStatsModalView.swift -//// GeoQuiz -//// -//// Created by Dennis Concepción Martín on 22/9/22. -//// -// -//import SwiftUI -// -//struct GameStatsModalView: View { -// @ObservedObject var game: T -// @Environment(\.dismiss) var dismiss -// -// var body: some View { -// NavigationView { -// List { -// Section { -// ForEach(Array(game.correctAnswers.keys), id: \.self) { key in -// Text(key) -// } -// } header: { -// Text("Correct answers") -// } -// -// Section { -// ForEach(Array(game.wrongAnswers.keys), id: \.self) { key in -// Text(key) -// } -// } header: { -// Text("Wrong answers") -// } -// } -// .navigationTitle("Game stats") -// .toolbar { -// ToolbarItem(placement: .cancellationAction) { -// Button { -// dismiss() -// } label: { -// Label("Exit", systemImage: "multiply") -// } -// } -// } -// } -// } -//} -// -//struct GameStatsModalView_Previews: PreviewProvider { -// static var previews: some View { -// GameStatsModalView(game: GuessTheFlag()) -// } -//} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessTheCapitalView.swift --- a/GeoQuiz/GuessTheCapitalView.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/GuessTheCapitalView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -8,7 +8,6 @@ import SwiftUI struct GuessTheCapitalView: View { - @Binding var gameName: GameName? @StateObject var game = CountryGame() var body: some View { @@ -61,21 +60,14 @@ } } .navigationBarHidden(true) - .modifier(GameAlertsModifier(game: game, gameName: $gameName)) - .sheet(isPresented: $game.showingBuyLivesView) { - BuyLivesModalView() - } - - .sheet(isPresented: $game.showingGameStatsView) { -// GameStatsModalView(game: game) - } + .modifier(GameAlertsModifier(game: game)) } } struct GuessCapitalView_Previews: PreviewProvider { static var previews: some View { NavigationView { - GuessTheCapitalView(gameName: .constant(GameName.guessTheCapital)) + GuessTheCapitalView() } } } diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessTheCountryView.swift --- a/GeoQuiz/GuessTheCountryView.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/GuessTheCountryView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -6,10 +6,8 @@ // import SwiftUI -import MapKit struct GuessTheCountryView: View { - @Binding var gameName: GameName? @StateObject var game = CityGame() var body: some View { @@ -22,15 +20,8 @@ GameToolbar(game: game, color: .pinkLavender) Spacer() - - CityMap(region: MKCoordinateRegion( - center: CLLocationCoordinate2D( - latitude: game.correctAnswer.value.lat, - longitude: game.correctAnswer.value.lon - ), - span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)) - ) - .frame(height: geo.size.height * 0.3) + + CityMap(game: game) Spacer() @@ -68,19 +59,12 @@ } } .navigationBarHidden(true) - .modifier(GameAlertsModifier(game: game, gameName: $gameName)) - .sheet(isPresented: $game.showingBuyLivesView) { - BuyLivesModalView() - } - - .sheet(isPresented: $game.showingGameStatsView) { -// GameStatsModalView(game: game) - } + .modifier(GameAlertsModifier(game: game)) } } struct GuessTheCountryView_Previews: PreviewProvider { static var previews: some View { - GuessTheCountryView(gameName: .constant(GameName.guessTheCountry)) + GuessTheCountryView() } } diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessTheCurrency.swift --- a/GeoQuiz/GuessTheCurrency.swift Thu Sep 29 12:00:17 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -// -// GuessTheCurrency.swift -// GeoQuiz -// -// Created by Dennis Concepción Martín on 29/9/22. -// - -import SwiftUI - -struct GuessTheCurrency: View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) - } -} - -struct GuessTheCurrency_Previews: PreviewProvider { - static var previews: some View { - GuessTheCurrency() - } -} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessTheCurrencyView.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GeoQuiz/GuessTheCurrencyView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -0,0 +1,20 @@ +// +// GuessTheCurrencyView.swift +// GeoQuiz +// +// Created by Dennis Concepción Martín on 29/9/22. +// + +import SwiftUI + +struct GuessTheCurrencyView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct GuessTheCurrency_Previews: PreviewProvider { + static var previews: some View { + GuessTheCurrencyView() + } +} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessTheFlagView.swift --- a/GeoQuiz/GuessTheFlagView.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/GuessTheFlagView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -8,7 +8,6 @@ import SwiftUI struct GuessTheFlagView: View { - @Binding var gameName: GameName? @StateObject var game = CountryGame() var body: some View { @@ -54,19 +53,12 @@ } } .navigationBarHidden(true) - .modifier(GameAlertsModifier(game: game, gameName: $gameName)) - .sheet(isPresented: $game.showingBuyLivesView) { - BuyLivesModalView() - } - - .sheet(isPresented: $game.showingGameStatsView) { -// GameStatsModalView(game: game) - } + .modifier(GameAlertsModifier(game: game)) } } struct GuessTheFlagView_Previews: PreviewProvider { static var previews: some View { - GuessTheFlagView(gameName: .constant(GameName.guessTheFlag)) + GuessTheFlagView() } } diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessThePopulation.swift --- a/GeoQuiz/GuessThePopulation.swift Thu Sep 29 12:00:17 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -// -// GuessThePopulation.swift -// GeoQuiz -// -// Created by Dennis Concepción Martín on 29/9/22. -// - -import SwiftUI - -struct GuessThePopulation: View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) - } -} - -struct GuessThePopulation_Previews: PreviewProvider { - static var previews: some View { - GuessThePopulation() - } -} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/GuessThePopulationView.swift --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GeoQuiz/GuessThePopulationView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -0,0 +1,20 @@ +// +// GuessThePopulationView.swift +// GeoQuiz +// +// Created by Dennis Concepción Martín on 29/9/22. +// + +import SwiftUI + +struct GuessThePopulationView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct GuessThePopulation_Previews: PreviewProvider { + static var previews: some View { + GuessThePopulationView() + } +} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Helpers/AnswerButton.swift --- a/GeoQuiz/Helpers/AnswerButton.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Helpers/AnswerButton.swift Tue Oct 04 18:54:24 2022 +0200 @@ -13,7 +13,7 @@ var body: some View { RoundedRectangle(cornerRadius: 15) - .foregroundColor(.white) + .foregroundStyle(.regularMaterial) .overlay( Text(optionName) .font(.title2.bold()) diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Helpers/CityMap.swift --- a/GeoQuiz/Helpers/CityMap.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Helpers/CityMap.swift Tue Oct 04 18:54:24 2022 +0200 @@ -2,30 +2,31 @@ // CityMap.swift // GeoQuiz // -// Created by Dennis Concepción Martín on 24/9/22. +// Created by Dennis Concepción Martín on 4/10/22. // import SwiftUI -import MapKit struct CityMap: View { - @State var region: MKCoordinateRegion + @ObservedObject var game: CityGame var body: some View { - Map(coordinateRegion: $region, interactionModes: MapInteractionModes()) - .clipShape(RoundedRectangle(cornerRadius: 20)) - .shadow(radius: 10) + Group { + if let mapImage = game.mapImage { + Image(uiImage: mapImage) + .resizable() + .scaledToFit() + .clipShape(RoundedRectangle(cornerRadius: 20)) + .shadow(radius: 10) + } else { + ProgressView() + } + } } } struct CityMap_Previews: PreviewProvider { - static var region = MKCoordinateRegion( - center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), - span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5) - ) - static var previews: some View { - CityMap(region: region) - .frame(width: 300, height: 300) + CityMap(game: CityGame()) } } diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Helpers/GameAlertsModifier.swift --- a/GeoQuiz/Helpers/GameAlertsModifier.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Helpers/GameAlertsModifier.swift Tue Oct 04 18:54:24 2022 +0200 @@ -9,7 +9,7 @@ struct GameAlertsModifier: ViewModifier { @ObservedObject var game: T - @Binding var gameName: GameName? + @Environment(\.dismiss) var dismiss func body(content: Content) -> some View { content @@ -19,25 +19,25 @@ Text(game.alertMessage) } - .alert(game.alertTitle, isPresented: $game.showingNoLivesAlert) { - Button("Buy lives") { game.showingBuyLivesView = true } - Button("Exit", role: .destructive) { gameName = nil } - Button("Cancel", role: .cancel) { } + .alert(game.alertTitle, isPresented: $game.showingGameOverAlert) { + Button("Try again") { game.reset() } + Button("Exit", role: .cancel) { dismiss()} } message: { Text(game.alertMessage) } .alert(game.alertTitle, isPresented: $game.showingEndGameAlert) { - Button("Exit", role: .cancel) { gameName = nil } + Button("Play again") { game.reset() } + Button("Exit", role: .cancel) { dismiss() } } message: { Text(game.alertMessage) } .alert("Are you sure?", isPresented: $game.showingExitGameAlert) { - Button("Exit", role: .destructive) { gameName = nil } + Button("Exit", role: .destructive) { dismiss() } Button("Cancel", role: .cancel) { } } message: { - Text("You'll loose the progress so far.") + Text("Progress won't be saved.") } } } diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Helpers/GameToolbar.swift --- a/GeoQuiz/Helpers/GameToolbar.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Helpers/GameToolbar.swift Tue Oct 04 18:54:24 2022 +0200 @@ -24,7 +24,7 @@ .padding(10) .background( Circle() - .foregroundColor(.white) + .foregroundStyle(.regularMaterial) ) } } @@ -32,40 +32,32 @@ .frame(maxWidth: .infinity, alignment: .leading) Group { - Button { - game.showingGameStatsView = true - } label: { - Text("\(game.userScore)") - .font(.title.bold()) - .foregroundColor(color) - .padding() - .background( - Circle() - .foregroundColor(.white) - ) - } + Text("\(game.userScore)") + .font(.title.bold()) + .foregroundColor(color) + .padding() + .background( + Circle() + .foregroundStyle(.regularMaterial) + ) } .font(.title2) .scaleEffect(game.scoreScaleAmount) .frame(maxWidth: .infinity, alignment: .center) Group { - Button { - game.showingBuyLivesView = true - } label: { - HStack { - Image(systemName: "heart.fill") - Text("\(game.userLives)") - } - .font(.headline) - .foregroundColor(color) - .padding(10) - .background( - Capsule() - .foregroundColor(.white) - ) - .scaleEffect(game.livesScaleAmount) + HStack { + Image(systemName: "heart.fill") + Text("\(game.userLives)") } + .font(.headline) + .foregroundColor(color) + .padding(10) + .background( + Capsule() + .foregroundStyle(.regularMaterial) + ) + .scaleEffect(game.livesScaleAmount) } .font(.headline) .frame(maxWidth: .infinity, alignment: .trailing) diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Logic/CityGame.swift --- a/GeoQuiz/Logic/CityGame.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Logic/CityGame.swift Tue Oct 04 18:54:24 2022 +0200 @@ -7,6 +7,8 @@ import Foundation import AVFAudio +import SwiftUI +import MapKit class CityGame: Game, ObservableObject { @@ -16,8 +18,12 @@ var data: [String: T] var dataAsked = [String: T]() - // Data - @Published var correctAnswer = (key: String(), value: T(country: String(), lat: Double(), lon: Double())) + @Published var mapImage: UIImage? = nil + @Published var correctAnswer = (key: String(), value: T(country: String(), lat: Double(), lon: Double())) { + willSet { + getMapImage(lat: newValue.value.lat, lon: newValue.value.lon) + } + } // User @Published var userChoices = [String: T]() @@ -29,7 +35,7 @@ // Alerts @Published var alertTitle = String() @Published var alertMessage = String() - @Published var showingNoLivesAlert = false + @Published var showingGameOverAlert = false @Published var showingEndGameAlert = false @Published var showingWrongAnswerAlert = false @Published var showingExitGameAlert = false @@ -38,10 +44,6 @@ @Published var scoreScaleAmount = 1.0 @Published var livesScaleAmount = 1.0 - // Modal views - @Published var showingBuyLivesView = false - @Published var showingGameStatsView = false - // Sound effects @Published var player: AVAudioPlayer? @@ -51,3 +53,35 @@ askQuestion() } } + +extension CityGame { + func getMapImage(lat: Double, lon: Double) { + let region = MKCoordinateRegion( + center: CLLocationCoordinate2D( + latitude: lat, + longitude: lon + ), + span: MKCoordinateSpan( + latitudeDelta: 1.0, + longitudeDelta: 1.0 + ) + ) + + // Map options + let mapOptions = MKMapSnapshotter.Options() + mapOptions.region = region + mapOptions.size = CGSize(width: 600, height: 600) + mapOptions.showsBuildings = true + + // Create the snapshotter and run it + let snapshotter = MKMapSnapshotter(options: mapOptions) + snapshotter.start { (snapshot, error) in + if let snapshot = snapshot { + self.mapImage = snapshot.image + } else if let error = error { + print(error.localizedDescription) + } + } + } +} + diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Logic/CountryGame.swift --- a/GeoQuiz/Logic/CountryGame.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Logic/CountryGame.swift Tue Oct 04 18:54:24 2022 +0200 @@ -32,7 +32,7 @@ // Alerts @Published var alertTitle = String() @Published var alertMessage = String() - @Published var showingNoLivesAlert = false + @Published var showingGameOverAlert = false @Published var showingEndGameAlert = false @Published var showingWrongAnswerAlert = false @Published var showingExitGameAlert = false @@ -41,10 +41,6 @@ @Published var scoreScaleAmount = 1.0 @Published var livesScaleAmount = 1.0 - // Modal views - @Published var showingBuyLivesView = false - @Published var showingGameStatsView = false - // Sound effects @Published var player: AVAudioPlayer? diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Logic/Game.swift --- a/GeoQuiz/Logic/Game.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/Logic/Game.swift Tue Oct 04 18:54:24 2022 +0200 @@ -29,7 +29,7 @@ // Alerts var alertTitle: String { get set } var alertMessage: String { get set } - var showingNoLivesAlert: Bool { get set } + var showingGameOverAlert: Bool { get set } var showingEndGameAlert: Bool { get set } var showingWrongAnswerAlert: Bool { get set } var showingExitGameAlert: Bool { get set } @@ -38,10 +38,6 @@ var scoreScaleAmount: Double { get set } var livesScaleAmount: Double { get set } - // Modal views - var showingBuyLivesView: Bool { get set } - var showingGameStatsView: Bool { get set } - // Sound effects var player: AVAudioPlayer? { get set } } @@ -53,8 +49,8 @@ func askQuestion() { guard questionCounter < data.count else { - alertTitle = "Amazing!" - alertMessage = "You've completed the game." + alertTitle = "⭐️ Congratulations ⭐️" + alertMessage = "You completed the game." showingEndGameAlert = true return @@ -89,14 +85,6 @@ } func answer(_ choice: (key: String, value: T)) { - guard userLives > 0 else { - alertTitle = "Not enough lives!" - alertMessage = "Please buy more lives to keep playing" - showingNoLivesAlert = true - - return - } - if correctAnswer == choice { hapticSuccess() playSound("correctAnswer") @@ -116,12 +104,18 @@ livesScaleAmount += 1 userLives -= 1 } - - alertTitle = "Wrong!" - alertMessage = "You have \(userLives) lives left" - showingWrongAnswerAlert = true wrongAnswers[choice.key] = choice.value + + if userLives == 0 { + alertTitle = "🤕 Game over 🤕" + alertMessage = "Get up and try again." + showingGameOverAlert = true + } else { + alertTitle = "🔴 Wrong 🔴" + alertMessage = "You have \(userLives) lives left." + showingWrongAnswerAlert = true + } } DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [self] in @@ -132,6 +126,15 @@ } } + func reset() { + dataAsked = [String: T]() + userScore = 0 + userLives = 3 + correctAnswers = [String: T]() + wrongAnswers = [String: T]() + askQuestion() + } + private func playSound(_ filename: String) { guard let soundFileURL = Bundle.main.url(forResource: filename, withExtension: "wav") else { fatalError("Sound file \(filename) couldn't be found") diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/Logic/GameSelector.swift --- a/GeoQuiz/Logic/GameSelector.swift Thu Sep 29 12:00:17 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -// -// GameSelection.swift -// GeoQuiz -// -// Created by Dennis Concepción Martín on 13/9/22. -// - -import Foundation - -enum GameName { - case guessTheFlag, guessTheCapital, guessTheCountry, guessThePopulation -} diff -r 1946bbfde4af -r d945e52b0704 GeoQuiz/SettingsModalView.swift --- a/GeoQuiz/SettingsModalView.swift Thu Sep 29 12:00:17 2022 +0200 +++ b/GeoQuiz/SettingsModalView.swift Tue Oct 04 18:54:24 2022 +0200 @@ -10,16 +10,31 @@ struct SettingsModalView: View { @Environment(\.dismiss) var dismiss - // CHANGE THIS IN PRODUCTION - @State private var testHapticsIsOn = true - @State private var testGameEffectIsOn = true - // CHANGE THIS IN PRODUCTION - var body: some View { NavigationView { Form { - Toggle("Haptics is on", isOn: $testHapticsIsOn) - Toggle("Game effect is on", isOn: $testGameEffectIsOn) + Section { + // Difficulty + } header: { + Text("Game") + } footer: { + Text("The harder the difficulty the less lives you get.") + } + + Section { + // Toggle to disable haptics + // Toggle to disable sound effects + } header: { + Text("Effects") + } + + Section { + // About + // Report bugs + // Twitter + } header: { + Text("Get in touch") + } } .navigationTitle("Settings") .toolbar {