Skip to content

Commit d1cae19

Browse files
committed
Fixed quest answer selection issue
- There is an issue in iOS 17.5 to handle multiple touches on the same instance.
1 parent d89ff00 commit d1cae19

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

GoInfoGame/GoInfoGame/quests/LongQuests/Components/QuestOptions.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ struct QuestOptions: View {
112112
label: option.choiceText,
113113
isSelected: currentAnswer == option.value
114114
)
115-
.onLongPressGesture {
116-
selectedImageURL = imageUrl
117-
selectedImageText = option.choiceText
118-
}
119115
} else {
120116
ZStack {
121117
Image("no_image")
@@ -161,7 +157,12 @@ struct QuestOptions: View {
161157
RoundedRectangle(cornerRadius: 8)
162158
.stroke(currentAnswer == option.value ? Color.blue : Color.clear, lineWidth: 3)
163159
)
164-
160+
.onLongPressGesture {
161+
if let imageUrl = option.imageURL, !imageUrl.isEmpty {
162+
selectedImageURL = imageUrl
163+
selectedImageText = option.choiceText
164+
}
165+
}
165166
}
166167
}
167168

@@ -222,7 +223,7 @@ struct QuestOptions: View {
222223
}
223224

224225
#Preview {
225-
QuestOptions(options: [QuestAnswerChoice(value: "yes", choiceText: "Yes, this roadway can be crossed safely.", imageURL: nil, choiceFollowUp: nil),
226+
QuestOptions(options: [QuestAnswerChoice(value: "asphalt", choiceText: "Asphalt", imageURL: "https://raw.githubusercontent.com/TaskarCenterAtUW/tdei-tools/refs/heads/main/images/sidewalk/surface/asphalt_landscape.png", choiceFollowUp: nil),
226227
QuestAnswerChoice(value: "no", choiceText: "No, this roadway is too wide to cross safely.", imageURL: nil, choiceFollowUp: nil)], selectedAnswerId: .constant(UUID()), onChoiceSelected: { qa in
227228

228229
}, questType: GoInfoGame.QuestType.exclusiveChoice, currentAnswer: .constant("Binding<String?>")) { s in

0 commit comments

Comments
 (0)