Skip to content

Commit 6bcb147

Browse files
committed
Fixed Misaligned first answer choice box
- Added grid items min and max widths for each items. - Added minimumScaleFactor to the text which is min of 10 pt. - Added line limit to text. it will render max 10 line of text and after ends with ellipsis. - Added content for preview for LongForm, LongQuestView, QuestOptions Ticket: https://dev.azure.com/TDEI-UW/TDEI/_workitems/edit/2033/
1 parent e1ad7d4 commit 6bcb147

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ struct QuestOptions: View {
3838
switch questType {
3939
case .exclusiveChoice:
4040
let columns = [
41-
GridItem(.flexible(), spacing: 30),
42-
GridItem(.flexible(), spacing: 30),
43-
GridItem(.flexible(), spacing: 30),
41+
GridItem(.flexible(minimum: 10.0, maximum: 100.0), spacing: 30),
42+
GridItem(.flexible(minimum: 10.0, maximum: 100.0), spacing: 30),
43+
GridItem(.flexible(minimum: 10.0, maximum: 100.0), spacing: 30),
4444
]
4545
ZStack {
4646
ScrollView {
@@ -142,12 +142,18 @@ struct QuestOptions: View {
142142
.font(.system(size: 15, weight: .bold))
143143
.foregroundColor(.black)
144144
.offset(x: offset.0, y: offset.1)
145+
.frame(width: 100, height: 100)
146+
.minimumScaleFactor(0.67) // min font size is 10
147+
.lineLimit(10)
145148
}
146149

147150
Text(option.choiceText)
148151
.font(.system(size: 15, weight: .bold))
149152
.foregroundColor(.white)
150153
.shadow(color: Color.black.opacity(0.7), radius: 4, x: 0, y: 2)
154+
.frame(width: 100, height: 100)
155+
.minimumScaleFactor(0.67) // min font size is 10
156+
.lineLimit(10)
151157
}
152158
}
153159
}
@@ -217,6 +223,11 @@ struct QuestOptions: View {
217223
}
218224
}
219225

220-
//#Preview {
221-
// QuestOptions(options: ["Ashpalt", "Concrete", "Brick", "Others"], selectedOption: "")
222-
//}
226+
#Preview {
227+
QuestOptions(options: [QuestAnswerChoice(value: "yes", choiceText: "Yes, this roadway can be crossed safely.", imageURL: nil, choiceFollowUp: nil),
228+
QuestAnswerChoice(value: "no", choiceText: "No, this roadway is too wide to cross safely.", imageURL: nil, choiceFollowUp: nil)], selectedAnswerId: .constant(UUID()), onChoiceSelected: { qa in
229+
230+
}, questType: GoInfoGame.QuestType.exclusiveChoice, currentAnswer: .constant("Binding<String?>")) { s in
231+
232+
}
233+
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,5 +325,14 @@ struct LongForm: View, QuestForm {
325325
}
326326

327327
#Preview {
328-
LongForm()
328+
let quest = LongFormElement(elementType: "Sidewalks", questQuery: "ways with (highway=footway and footway=sidewalk)", elementTypeIcon: "icon", quests: [LongQuest(questID: 14,
329+
questTitle: "Does the length of this crossing allow for safe navigation?",
330+
questDescription: "Determine whether this crossing is short enough to cross safely.",
331+
questType: .exclusiveChoice,
332+
questTag: "ext:crossing_adequate_length",
333+
questAnswerChoices: [QuestAnswerChoice(value: "yes", choiceText: "Yes, this roadway can be crossed safely. this is to test the line limit functionlity. want to see the max capability of this feature. the max lines should be 10. this is for our obervations only. till now it is able to render 10 lines with out any issue.", imageURL: nil, choiceFollowUp: nil),
334+
QuestAnswerChoice(value: "no", choiceText: "No, this roadway is too wide to cross safely.", imageURL: nil, choiceFollowUp: nil)], questImageURL: nil, questAnswerValidation: nil, questAnswerDependency: nil, questUserAnswer: nil)])
335+
QuestsRepository.shared.longQuestModels.append(quest)
336+
return LongForm(elementName: quest.elementType, questID: "questId",query: quest.questQuery, action: { tags in
337+
})
329338
}

GoInfoGame/GoInfoGame/quests/LongQuests/View/LongQuestView.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,21 @@ struct LongQuestView: View {
5858
}
5959

6060
}
61+
62+
#Preview {
63+
let longQeust = LongQuest(questID: 14,
64+
questTitle: "Does the length of this crossing allow for safe navigation?",
65+
questDescription: "Determine whether this crossing is short enough to cross safely.",
66+
questType: .exclusiveChoice,
67+
questTag: "ext:crossing_adequate_length",
68+
questAnswerChoices: [QuestAnswerChoice(value: "yes", choiceText: "Yes, this roadway can be crossed safely.", imageURL: nil, choiceFollowUp: nil),
69+
QuestAnswerChoice(value: "no", choiceText: "No, this roadway is too wide to cross safely.", imageURL: nil, choiceFollowUp: nil)], questImageURL: nil, questAnswerValidation: nil, questAnswerDependency: nil, questUserAnswer: nil)
70+
71+
72+
73+
LongQuestView(selectedAnswers: .constant([UUID(): UUID()]), quest: longQeust, onChoiceSelected: { qa in
74+
75+
}, uploadPhoto: { s in
76+
77+
}, currentAnswer: .constant(nil))
78+
}

0 commit comments

Comments
 (0)