Skip to content

Commit 9fb317c

Browse files
committed
added some changes to custom sure alert
1 parent d771a05 commit 9fb317c

File tree

9 files changed

+36
-17
lines changed

9 files changed

+36
-17
lines changed

GoInfoGame/GoInfoGame/Helpers/LocalizedStrings.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ enum LocalizedStrings: String {
8787
case questStepsRampSeparateWheelchairDecline = "quest_steps_ramp_separate_wheelchair_decline"
8888
case questPedestrianCrossingIsland = "quest_pedestrian_crossing_island"
8989
case dontShowAgain = "dont_show_again"
90+
case questTactilePavingKerbTitle = "quest_tactile_paving_kerb_title"
9091

9192
var localized: String {
9293
return NSLocalizedString(rawValue, comment: "")

GoInfoGame/GoInfoGame/UI/CustomComponents/CustomSureAlert.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,29 @@
88
import SwiftUI
99

1010
struct CustomSureAlert: View {
11+
let alertTitle: String
12+
let content: String
13+
let isDontShowCheckVisible: Bool
1114
let onCancel: () -> Void
1215
let onConfirm: () -> Void
1316

1417
var body: some View {
15-
CustomAlert(title: LocalizedStrings.questSourceDialogTitle.localized, content: {
18+
CustomAlert(title: alertTitle, content: {
1619
VStack {
17-
Text(LocalizedStrings.questSourceDialogNote.localized)
20+
Text(content)
1821
Spacer()
19-
HStack {
20-
Image(systemName: "square")
21-
.foregroundColor(.gray)
22-
Text(LocalizedStrings.dontShowAgain.localized)
22+
if isDontShowCheckVisible {
23+
HStack {
24+
Image(systemName: "square")
25+
.foregroundColor(.gray)
26+
Text(LocalizedStrings.dontShowAgain.localized)
27+
}
2328
}
2429
}
2530
}, leftActionText: LocalizedStrings.undoConfirmNegative.localized, rightActionText: LocalizedStrings.questGenericConfirmationYes.localized, leftButtonAction: onCancel, rightButtonAction: onConfirm, height: 200, width: 270)
2631
}
2732
}
2833

2934
#Preview {
30-
CustomSureAlert(onCancel: {}, onConfirm: {})
35+
CustomSureAlert(alertTitle: "", content: LocalizedStrings.questSourceDialogNote.localized,isDontShowCheckVisible: true, onCancel: {}, onConfirm: {})
3136
}

GoInfoGame/GoInfoGame/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,5 @@
8686
"quest_steps_ramp_separate_wheelchair_decline" = "not separate";
8787
"quest_pedestrian_crossing_island" = "Does this pedestrian crossing have an island?";
8888
"dont_show_again" = "Don't show again for this session";
89+
"quest_tactile_paving_kerb_title" = "Is there tactile paving on this curb here?";
8990

GoInfoGame/GoInfoGame/quests/BusStopLit/BusStopLitForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct BusStopLitForm: View, QuestForm {
3333
.shadow(color: .gray, radius: 2, x: 0, y: 2))
3434
}.padding()
3535
if isShowingAreYouSure {
36-
CustomSureAlert(onCancel: {
36+
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized, isDontShowCheckVisible: true,onCancel: {
3737
self.isShowingAreYouSure = false
3838
}, onConfirm: {
3939
self.isShowingAreYouSure = false

GoInfoGame/GoInfoGame/quests/CrossingIsland/CrossingIslandForm.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct CrossingIslandForm: View, QuestForm {
1515
typealias AnswerClass = YesNoAnswer
1616
@State private var isShowingAreYouSure = false
1717
@State private var selectedAnswer: YesNoAnswer = .unknown
18+
@State private var showOtherAlert = false
1819

1920
var body: some View {
2021
ZStack {
@@ -26,6 +27,8 @@ struct CrossingIslandForm: View, QuestForm {
2627
self.selectedAnswer = answer
2728
if answer == .yes || answer == .no {
2829
self.isShowingAreYouSure.toggle()
30+
} else if answer == .other {
31+
self.showOtherAlert.toggle()
2932
}
3033
})
3134
.background(
@@ -34,14 +37,23 @@ struct CrossingIslandForm: View, QuestForm {
3437
.shadow(color: .gray, radius: 2, x: 0, y: 2))
3538
}.padding()
3639
if isShowingAreYouSure {
37-
CustomSureAlert(onCancel: {
40+
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized, isDontShowCheckVisible: true,onCancel: {
3841
self.isShowingAreYouSure = false
3942
}, onConfirm: {
4043
self.isShowingAreYouSure = false
4144
self.action?(selectedAnswer)
4245
})
4346
.zIndex(1)
4447
}
48+
/// if user selects other answers option
49+
if showOtherAlert {
50+
/// display leave a note instead alert
51+
CustomSureAlert(alertTitle: LocalizedStrings.questLeaveNewNoteTitle.localized, content: LocalizedStrings.questLeaveNewNoteDescription.localized, isDontShowCheckVisible: false, onCancel: {
52+
self.showOtherAlert = false
53+
}, onConfirm: {
54+
self.showOtherAlert = false
55+
})
56+
}
4557
}
4658
}
4759
}

GoInfoGame/GoInfoGame/quests/Handrail/HandRailForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct HandRailForm: View, QuestForm {
3030
.shadow(color: .gray, radius: 2, x: 0, y: 2))
3131
}.padding()
3232
if isShowingAreYouSure {
33-
CustomSureAlert(onCancel: {
33+
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized, isDontShowCheckVisible: true,onCancel: {
3434
self.isShowingAreYouSure = false
3535
}, onConfirm: {
3636
self.isShowingAreYouSure = false

GoInfoGame/GoInfoGame/quests/TactilePavingKerb/TactilePavingKerbForm.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct TactilePavingKerbForm: View, QuestForm {
1919
var body: some View {
2020
ZStack{
2121
VStack{
22-
QuestionHeader(icon:Image("kerb_tactile_paving"), title: LocalizedStrings.questStepCountTitle.localized, subtitle: "Lowered Curb")
22+
QuestionHeader(icon:Image("kerb_tactile_paving"), title: LocalizedStrings.questTactilePavingKerbTitle.localized, subtitle: "Lowered Curb")
2323
VStack(alignment:.leading){
2424
Text(LocalizedStrings.usuallyLooksLikeThis.localized).font(.caption).foregroundColor(.gray)
2525
Image("tactile_paving_illustration")
@@ -42,7 +42,7 @@ struct TactilePavingKerbForm: View, QuestForm {
4242
/// if user selects yes/no option
4343
if showAlert {
4444
/// display are you sure alert
45-
CustomSureAlert(onCancel: {
45+
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized, isDontShowCheckVisible: true, onCancel: {
4646
self.showAlert = false
4747
}, onConfirm: {
4848
self.showAlert = false
@@ -53,11 +53,11 @@ struct TactilePavingKerbForm: View, QuestForm {
5353
/// if user selects other answers option
5454
if showOtherAlert {
5555
/// display leave a note instead alert
56-
CustomNoteAlert {
56+
CustomSureAlert(alertTitle: LocalizedStrings.questLeaveNewNoteTitle.localized, content: LocalizedStrings.questLeaveNewNoteDescription.localized, isDontShowCheckVisible: false, onCancel: {
5757
self.showOtherAlert = false
58-
} onConfirm: {
58+
}, onConfirm: {
5959
self.showOtherAlert = false
60-
}
60+
})
6161
}
6262
}.onTapGesture {
6363
showAlert = false

GoInfoGame/GoInfoGame/quests/TactilePavingSteps/TactilePavingStepsForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct TactilePavingStepsForm: View, QuestForm {
4141
.shadow(color: .gray, radius: 2, x: 0, y: 2))
4242
}.padding()
4343
if isShowingAreYouSure {
44-
CustomSureAlert(onCancel: {
44+
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized, isDontShowCheckVisible: true,onCancel: {
4545
self.isShowingAreYouSure = false
4646
}, onConfirm: {
4747
self.isShowingAreYouSure = false

GoInfoGame/GoInfoGame/quests/WayLit/WayLitForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct WayLitForm: View, QuestForm {
3232
.shadow(color: .gray, radius: 2, x: 0, y: 2))
3333
}.padding()
3434
if isShowingAreYouSure {
35-
CustomSureAlert(onCancel: {
35+
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized, isDontShowCheckVisible: true,onCancel: {
3636
self.isShowingAreYouSure = false
3737
}, onConfirm: {
3838
self.isShowingAreYouSure = false

0 commit comments

Comments
 (0)