Skip to content

Commit c04fc73

Browse files
authored
Merge pull request #62 from TaskarCenterAtUW/feature-yes-no-modification
Add sure prompt to yes no view
2 parents a73e974 + 3f5f8a8 commit c04fc73

File tree

6 files changed

+149
-40
lines changed

6 files changed

+149
-40
lines changed

GoInfoGame/GoInfoGame.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
FA87A8192B6B01A4000A6BEA /* HandRailTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A8182B6B01A4000A6BEA /* HandRailTests.swift */; };
162162
FA87A81B2B6B042E000A6BEA /* SideWalkWidthTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A81A2B6B042E000A6BEA /* SideWalkWidthTests.swift */; };
163163
FABF3CF42B7419BB0080EAC9 /* LocationManagerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FABF3CF32B7419BB0080EAC9 /* LocationManagerDelegate.swift */; };
164+
FABF3CF82B822F120080EAC9 /* CustomSureAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = FABF3CF72B822F120080EAC9 /* CustomSureAlert.swift */; };
164165
FAC9E60F2B04F9C800E2C608 /* OverpassRequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC9E60E2B04F9C800E2C608 /* OverpassRequestManager.swift */; };
165166
FAC9E6112B06811300E2C608 /* LocationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC9E6102B06811300E2C608 /* LocationManager.swift */; };
166167
FAD5C4F32AFCBE700040C61A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAD5C4F22AFCBE700040C61A /* AppDelegate.swift */; };
@@ -411,6 +412,7 @@
411412
FA87A8182B6B01A4000A6BEA /* HandRailTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandRailTests.swift; sourceTree = "<group>"; };
412413
FA87A81A2B6B042E000A6BEA /* SideWalkWidthTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SideWalkWidthTests.swift; sourceTree = "<group>"; };
413414
FABF3CF32B7419BB0080EAC9 /* LocationManagerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManagerDelegate.swift; sourceTree = "<group>"; };
415+
FABF3CF72B822F120080EAC9 /* CustomSureAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSureAlert.swift; sourceTree = "<group>"; };
414416
FAC9E60E2B04F9C800E2C608 /* OverpassRequestManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverpassRequestManager.swift; sourceTree = "<group>"; };
415417
FAC9E6102B06811300E2C608 /* LocationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManager.swift; sourceTree = "<group>"; };
416418
FAD5C4EF2AFCBE700040C61A /* GoInfoGame.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GoInfoGame.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -661,6 +663,7 @@
661663
973FC04B2B5A5F5F00878269 /* RadioItem.swift */,
662664
97AC1C092B6B7F10004F0BF4 /* CustomVerticalButtonsList.swift */,
663665
97AC1C0B2B6B843C004F0BF4 /* CustomAlert.swift */,
666+
FABF3CF72B822F120080EAC9 /* CustomSureAlert.swift */,
664667
);
665668
path = CustomComponents;
666669
sourceTree = "<group>";
@@ -1605,6 +1608,7 @@
16051608
97AC1C0A2B6B7F10004F0BF4 /* CustomVerticalButtonsList.swift in Sources */,
16061609
973FC0352B592C0F00878269 /* StairNumberForm.swift in Sources */,
16071610
FAC9E60F2B04F9C800E2C608 /* OverpassRequestManager.swift in Sources */,
1611+
FABF3CF82B822F120080EAC9 /* CustomSureAlert.swift in Sources */,
16081612
973FC0482B5A477E00878269 /* CrossMarking.swift in Sources */,
16091613
05DBBB642B17204300B6F110 /* RealmOPGeometry.swift in Sources */,
16101614
FA87A8102B68142F000A6BEA /* LoadingView.swift in Sources */,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// CustomSureAlert.swift
3+
// GoInfoGame
4+
//
5+
// Created by Achyut Kumar M on 18/02/24.
6+
//
7+
8+
import SwiftUI
9+
10+
struct CustomSureAlert: View {
11+
let onCancel: () -> Void
12+
let onConfirm: () -> Void
13+
14+
var body: some View {
15+
CustomAlert(title: "Are you sure you checked this on-site?", content: {
16+
VStack {
17+
Text("Only information that was found on a survey should be entered.")
18+
Spacer()
19+
HStack {
20+
Image(systemName: "square")
21+
.foregroundColor(.gray)
22+
Text("Don't show again for this session")
23+
}
24+
}
25+
}, leftActionText: "CANCEL", rightActionText: "YES, I AM SURE", leftButtonAction: onCancel, rightButtonAction: onConfirm, height: 200, width: 270)
26+
}
27+
}
28+
29+
#Preview {
30+
CustomSureAlert(onCancel: {}, onConfirm: {})
31+
}

GoInfoGame/GoInfoGame/quests/BusStopLit/BusStopLitForm.swift

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,36 @@ struct BusStopLitForm: View, QuestForm {
1212
var action: ((YesNoAnswer) -> Void)?
1313

1414
typealias AnswerClass = YesNoAnswer
15+
@State private var isShowingAreYouSure = false
16+
@State private var selectedAnswer: YesNoAnswer = .unknown
17+
1518
var body: some View {
16-
VStack{
17-
QuestionHeader(icon: Image("stop_lit"),
18-
title: LocalizedStrings.questBusStopLitTitle.localized,
19-
subtitle: "SideWalk")
20-
YesNoView(action: action).padding(10)
19+
ZStack {
20+
VStack{
21+
QuestionHeader(icon: Image("stop_lit"),
22+
title: LocalizedStrings.questBusStopLitTitle.localized,
23+
subtitle: "SideWalk")
24+
YesNoView(action: { answer in
25+
self.selectedAnswer = answer
26+
if answer == .yes || answer == .no {
27+
self.isShowingAreYouSure.toggle()
28+
}
29+
})
2130
.background(
2231
RoundedRectangle(cornerRadius: 10)
2332
.fill(Color.white)
2433
.shadow(color: .gray, radius: 2, x: 0, y: 2))
25-
}.padding()
34+
}.padding()
35+
if isShowingAreYouSure {
36+
CustomSureAlert(onCancel: {
37+
self.isShowingAreYouSure = false
38+
}, onConfirm: {
39+
self.isShowingAreYouSure = false
40+
self.action?(selectedAnswer)
41+
})
42+
.zIndex(1)
43+
}
44+
}
2645
}
2746
}
2847

GoInfoGame/GoInfoGame/quests/Handrail/HandRailForm.swift

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,35 @@ import SwiftUI
1010
struct HandRailForm: View, QuestForm {
1111
typealias AnswerClass = YesNoAnswer
1212
var action: ((YesNoAnswer) -> Void)?
13+
@State private var isShowingAreYouSure = false
14+
@State private var selectedAnswer: YesNoAnswer = .unknown
1315

1416
var body: some View {
15-
VStack{
16-
QuestionHeader(icon: Image("steps_handrail"),
17-
title: "Do these steps have handrail?",
18-
subtitle: "")
19-
YesNoView(action: action)
17+
ZStack {
18+
VStack{
19+
QuestionHeader(icon: Image("steps_handrail"),
20+
title: "Do these steps have handrail?",
21+
subtitle: "")
22+
YesNoView(action: { answer in
23+
self.selectedAnswer = answer
24+
if answer == .yes || answer == .no {
25+
self.isShowingAreYouSure.toggle()
26+
}
27+
})
2028
.background(RoundedRectangle(cornerRadius: 10)
2129
.fill(Color.white)
2230
.shadow(color: .gray, radius: 2, x: 0, y: 2))
23-
}.padding()
31+
}.padding()
32+
if isShowingAreYouSure {
33+
CustomSureAlert(onCancel: {
34+
self.isShowingAreYouSure = false
35+
}, onConfirm: {
36+
self.isShowingAreYouSure = false
37+
self.action?(selectedAnswer)
38+
})
39+
.zIndex(1)
40+
}
41+
}
2442
}
2543
}
2644

GoInfoGame/GoInfoGame/quests/TactilePavingSteps/TactilePavingStepsForm.swift

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,45 @@ import SwiftUI
1111
struct TactilePavingStepsForm: View, QuestForm {
1212
var action: ((YesNoAnswer) -> Void)?
1313
typealias AnswerClass = YesNoAnswer
14+
@State private var isShowingAreYouSure = false
15+
@State private var selectedAnswer: YesNoAnswer = .unknown
1416

1517
var body: some View {
16-
VStack{
17-
QuestionHeader(icon:Image("steps_tactile_paving"),
18-
title: LocalizedStrings.questTactilePavingTitleSteps.localized,
19-
subtitle: "Stair Number")
20-
VStack(alignment:.leading){
21-
Text(LocalizedStrings.usuallyLooksLikeThis.localized)
22-
.font(.caption)
23-
.foregroundColor(.gray)
24-
Image("tactile_paving_illustration")
25-
.resizable()
26-
.scaledToFill()
27-
Divider()
28-
YesNoView(action: action)
29-
} .padding(10)
30-
.background(
31-
RoundedRectangle(cornerRadius: 10)
32-
.fill(Color.white)
33-
.shadow(color: .gray, radius: 2, x: 0, y: 2))
34-
}.padding()
18+
ZStack {
19+
VStack{
20+
QuestionHeader(icon:Image("steps_tactile_paving"),
21+
title: LocalizedStrings.questTactilePavingTitleSteps.localized,
22+
subtitle: "Stair Number")
23+
VStack(alignment:.leading){
24+
Text(LocalizedStrings.usuallyLooksLikeThis.localized)
25+
.font(.caption)
26+
.foregroundColor(.gray)
27+
Image("tactile_paving_illustration")
28+
.resizable()
29+
.scaledToFill()
30+
Divider()
31+
YesNoView(action: { answer in
32+
self.selectedAnswer = answer
33+
if answer == .yes || answer == .no {
34+
self.isShowingAreYouSure.toggle()
35+
}
36+
})
37+
} .padding(10)
38+
.background(
39+
RoundedRectangle(cornerRadius: 10)
40+
.fill(Color.white)
41+
.shadow(color: .gray, radius: 2, x: 0, y: 2))
42+
}.padding()
43+
if isShowingAreYouSure {
44+
CustomSureAlert(onCancel: {
45+
self.isShowingAreYouSure = false
46+
}, onConfirm: {
47+
self.isShowingAreYouSure = false
48+
self.action?(selectedAnswer)
49+
})
50+
.zIndex(1)
51+
}
52+
}
3553
}
3654
}
3755

GoInfoGame/GoInfoGame/quests/WayLit/WayLitForm.swift

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,36 @@ import SwiftUI
1111
struct WayLitForm: View, QuestForm {
1212
var action: ((YesNoAnswer) -> Void)?
1313
typealias AnswerClass = YesNoAnswer
14+
@State private var isShowingAreYouSure = false
15+
@State private var selectedAnswer: YesNoAnswer = .unknown
16+
1417

1518
var body: some View {
16-
VStack{
17-
QuestionHeader(icon: Image("add_way_lit"),
18-
title: LocalizedStrings.questLitTitle.localized,
19-
subtitle: "SideWalk")
20-
YesNoView(action: action)
21-
.background(RoundedRectangle(cornerRadius: 10)
22-
.fill(Color.white)
23-
.shadow(color: .gray, radius: 2, x: 0, y: 2))
24-
}.padding()
19+
ZStack {
20+
VStack{
21+
QuestionHeader(icon: Image("add_way_lit"),
22+
title: LocalizedStrings.questLitTitle.localized,
23+
subtitle: "SideWalk")
24+
YesNoView(action: { answer in
25+
self.selectedAnswer = answer
26+
if answer == .yes || answer == .no {
27+
self.isShowingAreYouSure.toggle()
28+
}
29+
})
30+
.background(RoundedRectangle(cornerRadius: 10)
31+
.fill(Color.white)
32+
.shadow(color: .gray, radius: 2, x: 0, y: 2))
33+
}.padding()
34+
if isShowingAreYouSure {
35+
CustomSureAlert(onCancel: {
36+
self.isShowingAreYouSure = false
37+
}, onConfirm: {
38+
self.isShowingAreYouSure = false
39+
self.action?(selectedAnswer)
40+
})
41+
.zIndex(1)
42+
}
43+
}
2544
}
2645
}
2746

0 commit comments

Comments
 (0)