Skip to content

Commit 4493bff

Browse files
authored
Merge pull request #269 from TaskarCenterAtUW/bug-2033-Misaligned-first-answer-choice-box
Fixed Misaligned first answer choice box
2 parents e1ad7d4 + 1a3aeae commit 4493bff

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

GoInfoGame/GoInfoGame/DataBase/DatabaseConnector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import osmparser
1414
class DatabaseConnector {
1515
static let shared = DatabaseConnector()
1616

17-
private let realm: Realm
17+
let realm: Realm
1818

1919
private init() {
2020
// Initialize Realm instance

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

Lines changed: 15 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,16 @@ 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
145147
}
146148

147149
Text(option.choiceText)
148150
.font(.system(size: 15, weight: .bold))
149151
.foregroundColor(.white)
150152
.shadow(color: Color.black.opacity(0.7), radius: 4, x: 0, y: 2)
153+
.frame(width: 100, height: 100)
154+
.minimumScaleFactor(0.67) // min font size is 10
151155
}
152156
}
153157
}
@@ -217,6 +221,11 @@ struct QuestOptions: View {
217221
}
218222
}
219223

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

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+
}

GoInfoGame/GoInfoGame/quests/QuestUndoManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MapUndoManager {
1515
private let realm: Realm
1616

1717
private init() {
18-
realm = try! Realm()
18+
realm = DatabaseConnector.shared.realm
1919
}
2020

2121
var updateTagsHandler: ((_ changeset: StoredChangeset?) -> Void)?

0 commit comments

Comments
 (0)