Mercurial > public > geoquiz
comparison GeoQuiz/GuessTheCountryView.swift @ 7:d945e52b0704
implement dynamic map
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Tue, 04 Oct 2022 18:54:24 +0200 |
parents | 1946bbfde4af |
children | e09959b4e4a8 |
comparison
equal
deleted
inserted
replaced
6:1946bbfde4af | 7:d945e52b0704 |
---|---|
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 24/9/22. | 5 // Created by Dennis Concepción Martín on 24/9/22. |
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 import MapKit | |
10 | 9 |
11 struct GuessTheCountryView: View { | 10 struct GuessTheCountryView: View { |
12 @Binding var gameName: GameName? | |
13 @StateObject var game = CityGame() | 11 @StateObject var game = CityGame() |
14 | 12 |
15 var body: some View { | 13 var body: some View { |
16 ZStack { | 14 ZStack { |
17 LinearGradient(gradient: .tertiary, startPoint: .top, endPoint: .bottom) | 15 LinearGradient(gradient: .tertiary, startPoint: .top, endPoint: .bottom) |
20 GeometryReader { geo in | 18 GeometryReader { geo in |
21 VStack(spacing: 20) { | 19 VStack(spacing: 20) { |
22 GameToolbar(game: game, color: .pinkLavender) | 20 GameToolbar(game: game, color: .pinkLavender) |
23 | 21 |
24 Spacer() | 22 Spacer() |
25 | 23 |
26 CityMap(region: MKCoordinateRegion( | 24 CityMap(game: game) |
27 center: CLLocationCoordinate2D( | |
28 latitude: game.correctAnswer.value.lat, | |
29 longitude: game.correctAnswer.value.lon | |
30 ), | |
31 span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5)) | |
32 ) | |
33 .frame(height: geo.size.height * 0.3) | |
34 | 25 |
35 Spacer() | 26 Spacer() |
36 | 27 |
37 HStack { | 28 HStack { |
38 VStack(alignment: .leading, spacing: 10) { | 29 VStack(alignment: .leading, spacing: 10) { |
66 } | 57 } |
67 .padding() | 58 .padding() |
68 } | 59 } |
69 } | 60 } |
70 .navigationBarHidden(true) | 61 .navigationBarHidden(true) |
71 .modifier(GameAlertsModifier(game: game, gameName: $gameName)) | 62 .modifier(GameAlertsModifier(game: game)) |
72 .sheet(isPresented: $game.showingBuyLivesView) { | |
73 BuyLivesModalView() | |
74 } | |
75 | |
76 .sheet(isPresented: $game.showingGameStatsView) { | |
77 // GameStatsModalView(game: game) | |
78 } | |
79 } | 63 } |
80 } | 64 } |
81 | 65 |
82 struct GuessTheCountryView_Previews: PreviewProvider { | 66 struct GuessTheCountryView_Previews: PreviewProvider { |
83 static var previews: some View { | 67 static var previews: some View { |
84 GuessTheCountryView(gameName: .constant(GameName.guessTheCountry)) | 68 GuessTheCountryView() |
85 } | 69 } |
86 } | 70 } |