Skip to content

Commit 72a2e4a

Browse files
authored
Merge pull request #59 from TaskarCenterAtUW/feature-tag-stepsRamp
Added tags for Steps Ramps
2 parents 7779025 + 67df7e9 commit 72a2e4a

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

GoInfoGame/GoInfoGame/quests/StepsRamp/StepsRamp.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ class StepsRamp: QuestBase, Quest {
5757

5858
func onAnswer(answer: StepsRampAnswer) {
5959
if let rData = self.relationData {
60-
// self.updateTags(id: rData.id, tags: ["ramp":"s"], type: rData.type)
60+
let tags = ["ramp:bicycle": answer.bicycleRamp ? "yes" : "no",
61+
"ramp:wheelchair": answer.wheelchairRamp.rawValue,
62+
"ramp:stroller": answer.strollerRamp ? "yes" : "no"]
63+
self.updateTags(id: rData.id, tags: tags, type: rData.type)
6164
}
6265
}
6366

64-
6567
func copyWithElement(element: Element) -> any Quest {
6668
let q = StepsRamp()
6769
q.relationData = element
@@ -85,8 +87,8 @@ class StepsRampAnswer {
8587
}
8688
}
8789

88-
enum WheelchairRampStatus {
89-
case YES
90-
case NO
91-
case SEPARATE
90+
enum WheelchairRampStatus: String {
91+
case YES = "yes"
92+
case NO = "no"
93+
case SEPARATE = "separate"
9294
}

GoInfoGame/GoInfoGame/quests/StepsRamp/StepsRampForm.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ struct StepsRampForm: View, QuestForm {
2020
ImageData(id:"ramp_stroller",type: "stroller", imageName: "ramp_stroller", tag: "ramp:stroller", optionName: LocalizedStrings.questStepsRampStroller.localized),
2121
ImageData(id:"ramp_wheelchair",type: "wheelchair", imageName: "ramp_wheelchair", tag: "ramp:wheelchair", optionName: LocalizedStrings.questStepsRampWheelchair.localized),
2222
]
23+
var isBicycleRamp:Bool {
24+
selectedImage.contains("ramp:bicycle")
25+
}
26+
var isStrollerRamp:Bool {
27+
selectedImage.contains("ramp:stroller")
28+
}
2329
var body: some View {
2430
VStack (alignment: .leading){
2531
QuestionHeader(icon: Image("ic_quest_steps_ramp"), title: LocalizedStrings.questStepsRampTitle.localized, subtitle: "North 88th Street").padding(.bottom,10)
2632
VStack(alignment: .leading){
2733
Text(LocalizedStrings.select.localized).font(.caption).foregroundColor(.gray)
2834
ImageGridItemView(gridCount: 2, isLabelBelow: false, imageData: imageData, isImageRotated: false, isDisplayImageOnly: false, isScrollable: false, allowMultipleSelection: true, onTap: { (selectedImage) in
29-
print("Clicked Tag: \(selectedImage)")
3035
}, selectedImages: $selectedImage)
31-
3236
Divider()
3337
HStack() {
3438
Spacer()
@@ -43,12 +47,10 @@ struct StepsRampForm: View, QuestForm {
4347
Spacer()
4448
if !selectedImage.isEmpty {
4549
Button() {
46-
/// applying final selected answer
4750
if selectedImage.contains("ramp:wheelchair") {
4851
showWheelchairAlert = true
4952
}else {
50-
//TODO: none/bicycle/stroller type answer
51-
let answer = StepsRampAnswer(bicycleRamp: true, strollerRamp: true, wheelchairRamp: .NO)
53+
let answer = StepsRampAnswer(bicycleRamp: isBicycleRamp, strollerRamp: isStrollerRamp, wheelchairRamp: .NO)
5254
action?(answer)
5355
}
5456
}label: {
@@ -59,10 +61,12 @@ struct StepsRampForm: View, QuestForm {
5961
/// displayed only when selected answers contains wheelchair
6062
.alert(LocalizedStrings.questStepsRampSeparateWheelchair.localized, isPresented: $showWheelchairAlert) {
6163
Button(LocalizedStrings.questStepsRampSeparateWheelchairConfirm.localized.uppercased(), action: {
62-
//TODO: wheelchair type answer separate
64+
let answer = StepsRampAnswer(bicycleRamp: isBicycleRamp, strollerRamp: isStrollerRamp, wheelchairRamp: WheelchairRampStatus.SEPARATE)
65+
action?(answer)
6366
})
6467
Button(LocalizedStrings.questStepsRampSeparateWheelchairDecline.localized.uppercased(), action: {
65-
//TODO: wheelchair type answer not separate
68+
let answer = StepsRampAnswer(bicycleRamp: isBicycleRamp, strollerRamp: isStrollerRamp, wheelchairRamp: WheelchairRampStatus.YES)
69+
action?(answer)
6670
})
6771
/// no action to be taken
6872
Button(LocalizedStrings.questGenericConfirmationNo.localized, role: .cancel, action: {})

0 commit comments

Comments
 (0)