Skip to content

Commit 13533d4

Browse files
author
Achyut Kumar M
committed
minor ui fixes
1 parent 4126a20 commit 13533d4

File tree

4 files changed

+65
-41
lines changed

4 files changed

+65
-41
lines changed

GoInfoGame/GoInfoGame/Helpers/Extensions.swift

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,37 @@ extension MKPolyline {
2525
}
2626

2727
extension View {
28-
func hideKeyboard() {
29-
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
28+
func hideKeyboardOnTap() -> some View {
29+
self.simultaneousGesture(
30+
TapGesture()
31+
.onEnded {
32+
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder),
33+
to: nil, from: nil, for: nil)
34+
}
35+
)
3036
}
3137
}
3238

39+
extension MKMapRect {
40+
init(_ region: MKCoordinateRegion) {
41+
let topLeft = CLLocationCoordinate2D(
42+
latitude: region.center.latitude + (region.span.latitudeDelta / 2),
43+
longitude: region.center.longitude - (region.span.longitudeDelta / 2)
44+
)
45+
let bottomRight = CLLocationCoordinate2D(
46+
latitude: region.center.latitude - (region.span.latitudeDelta / 2),
47+
longitude: region.center.longitude + (region.span.longitudeDelta / 2)
48+
)
49+
50+
let a = MKMapPoint(topLeft)
51+
let b = MKMapPoint(bottomRight)
52+
53+
self = MKMapRect(
54+
origin: MKMapPoint(x: min(a.x, b.x), y: min(a.y, b.y)),
55+
size: MKMapSize(width: abs(a.x - b.x), height: abs(a.y - b.y))
56+
)
57+
}
58+
}
3359

3460
extension MKMapView {
3561
func isZoomedIn(maxLatitudeDelta: CLLocationDegrees = 0.005) -> Bool {

GoInfoGame/GoInfoGame/UI/UserSettingsView.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ struct UserSettingsView: View {
6464
.scaledToFit()
6565
.frame(width: 20, height: 20)
6666
.foregroundColor(Color(red: 69/255, green: 81/255, blue: 108/255))
67-
68-
//add tap gesture to navigate to the respective view
67+
6968
Text(option.title)
7069
.font(.custom("Lato-Bold", size: 16))
7170
.foregroundColor(Color(red: 69/255, green: 81/255, blue: 108/255))
7271
.padding(.leading, 8)
73-
.onTapGesture {
74-
onNavigate(option.destination)
75-
}
76-
7772

7873
Spacer()
7974
}
8075
.padding(.horizontal, 16)
81-
.frame(height: 50) // Increased row height
82-
76+
.frame(height: 50)
77+
.frame(maxWidth: .infinity)
78+
.contentShape(Rectangle())
79+
.onTapGesture {
80+
onNavigate(option.destination)
81+
}
82+
8383
if option.title != options.last?.title {
8484
Divider().padding(.leading, 16)
8585
}
@@ -90,7 +90,7 @@ struct UserSettingsView: View {
9090
.clipShape(RoundedRectangle(cornerRadius: 16))
9191
.padding([.leading, .trailing], 22)
9292
}
93-
93+
9494
Spacer()
9595
}
9696
.padding(.bottom, 16)

GoInfoGame/GoInfoGame/quests/LongQuests/View/LongForm.swift

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,42 +183,40 @@ struct LongForm: View, QuestForm {
183183
}
184184
}
185185
}
186-
Button(action: {
187-
if !viewModel.answersToBeSubmitted.isEmpty {
188-
if let action = action {
189-
if !uploadedPhotos.isEmpty {
190-
viewModel.answersToBeSubmitted["ext:kartaview_url"] = uploadedPhotos.joined(separator: ", ")
191-
}
192-
193-
action(viewModel.answersToBeSubmitted)
194-
}
195-
} else {
196-
self.showSubmitAlert = true
197-
self.submitAlert = "Please answer atleast one quest to submit"
198-
}
199-
200-
}) {
201-
Text("Submit")
202-
.font(.custom("Lato-Bold", size: 16))
203-
.foregroundColor(.white)
204-
.padding()
205-
.frame(width: 200, height: 40)
206-
.background(Color(red: 135/255, green: 62/255, blue: 242/255))
207-
.cornerRadius(20)
208-
}
209-
.frame(maxWidth: .infinity)
210186
}
211187
.frame(maxWidth: .infinity)
212188
} else {
213189
Text("No Quests available")
214190
}
215191
}
216192
}
217-
.simultaneousGesture(
218-
TapGesture().onEnded {
219-
hideKeyboard()
193+
.hideKeyboardOnTap()
194+
195+
Button(action: {
196+
if !viewModel.answersToBeSubmitted.isEmpty {
197+
if let action = action {
198+
if !uploadedPhotos.isEmpty {
199+
viewModel.answersToBeSubmitted["ext:kartaview_url"] = uploadedPhotos.joined(separator: ", ")
200+
}
201+
202+
action(viewModel.answersToBeSubmitted)
203+
}
204+
} else {
205+
self.showSubmitAlert = true
206+
self.submitAlert = "Please answer atleast one quest to submit"
220207
}
221-
)
208+
209+
}) {
210+
Text("Submit")
211+
.font(.custom("Lato-Bold", size: 16))
212+
.foregroundColor(.white)
213+
.padding()
214+
.frame(width: 200, height: 40)
215+
.background(Color(red: 135/255, green: 62/255, blue: 242/255))
216+
.cornerRadius(20)
217+
}
218+
.frame(maxWidth: .infinity)
219+
222220
}
223221
.onChange(of: capturedImage) { newValue in
224222
if newValue != nil {

GoInfoGame/GoInfoGame/quests/QuestCategory/UI/ManageQuestsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct ManageQuestsView: View {
1515
var body: some View {
1616
VStack(alignment: .leading, spacing: 12) {
1717
HStack(alignment: .firstTextBaseline) {
18-
Text("Manage Quests")
18+
Text("Choose which features to survey")
1919
.font(.custom("Lato-Bold", size: 20))
2020
.foregroundColor(Color(red: 69/255, green: 81/255, blue: 108/255))
2121
.padding(.top, 30)
@@ -37,7 +37,7 @@ struct ManageQuestsView: View {
3737
.foregroundColor(Color(red: 132/255, green: 135/255, blue: 153/255))
3838
.padding(.horizontal)
3939

40-
Text("TYPES")
40+
Text("FEATURES")
4141
.font(.custom("Lato-Bold", size: 15))
4242
.foregroundColor(Color(red: 132/255, green: 135/255, blue: 153/255))
4343
.padding(.horizontal)

0 commit comments

Comments
 (0)