Skip to content

Commit 2ba3467

Browse files
authored
Merge pull request #78 from TaskarCenterAtUW/feature-add-subtTitle-sidewalk
Feature add subTitle sidewalkWidth
2 parents 31bf0e0 + 8f8db68 commit 2ba3467

File tree

7 files changed

+30
-3
lines changed

7 files changed

+30
-3
lines changed

GoInfoGame/GoInfoGame/UI/CustomComponents/QuestionHeader.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ struct QuestionHeader: View {
3434
.font(.subheadline)
3535
.foregroundColor(.gray)
3636
.padding(.top,2)
37+
.multilineTextAlignment(.leading)
38+
.lineLimit(nil)
39+
.fixedSize(horizontal: false, vertical: true)
3740
}
3841
}
3942
}

GoInfoGame/GoInfoGame/UI/Map/CustomMap.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ struct CustomMap: UIViewRepresentable {
144144
let newCoordinates = Set(newAnnotations.map { $0.coordinate })
145145
/// Checking if the coordinates of existing annotations are different from the coordinates of new annotations
146146
if existingCoordinates != newCoordinates {
147+
/// to reset isRegionSet value whenever region changes.
148+
context.coordinator.isRegionSet = false
147149
/// Removing annotations that are not present in the new set
148150
let annotationsToRemove = mapView.annotations.filter {
149151
guard let displayUnitAnnotation = $0 as? DisplayUnitAnnotation else { return false }
@@ -164,15 +166,16 @@ struct CustomMap: UIViewRepresentable {
164166

165167
// calculate distance between user current location and selected annotation
166168
func calculateDistance(selectedAnnotation: CLLocationCoordinate2D) -> CLLocationDistance {
167-
let userCurrentLocation = locationManagerDelegate.locationManager.location!.coordinate
169+
guard let userCurrentLocation = locationManagerDelegate.locationManager.location?.coordinate else { return CLLocationDistance(0) }
170+
168171
let fromLocation = CLLocation(latitude: userCurrentLocation.latitude, longitude: userCurrentLocation.longitude)
169172
let toLocation = CLLocation(latitude: selectedAnnotation.latitude, longitude: selectedAnnotation.longitude)
170173
return CLLocationDistance(Int(fromLocation.distance(from: toLocation)))
171174
}
172175

173176
// infer direction
174177
func inferDirection(selectedAnnotation: CLLocationCoordinate2D) -> String {
175-
let userCurrentLocation = locationManagerDelegate.locationManager.location!.coordinate
178+
guard let userCurrentLocation = locationManagerDelegate.locationManager.location?.coordinate else { return "undetermined" }
176179
let userLocationPoint = MKMapPoint(userCurrentLocation)
177180
let destinationPoint = MKMapPoint(selectedAnnotation)
178181
let angleRadians = atan2(destinationPoint.y - userLocationPoint.y, destinationPoint.x - userLocationPoint.x)

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct MapView: View {
2525
selectedQuest: $viewModel.selectedQuest,
2626
isPresented: $isPresented, contextualInfo: { contextualInfo in
2727
print(contextualInfo)
28+
self.setSubTitleForSideWalk(subTitle: contextualInfo)
2829
})
2930
.edgesIgnoringSafeArea(.all)
3031

@@ -46,6 +47,13 @@ struct MapView: View {
4647
isPresented = false
4748
}
4849
}
50+
51+
private func setSubTitleForSideWalk(subTitle: String) {
52+
if let sidewalk = self.viewModel.selectedQuest?.parent as? SideWalkWidth {
53+
sidewalk.subTitle = subTitle
54+
}
55+
}
56+
4957
}
5058

5159
#Preview {

GoInfoGame/GoInfoGame/quests/BusStopLit/BusStopLitForm.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct BusStopLitForm: View, QuestForm {
3131
RoundedRectangle(cornerRadius: 10)
3232
.fill(Color.white)
3333
.shadow(color: .gray, radius: 2, x: 0, y: 2))
34+
.padding(.bottom,20)
3435
}.padding()
3536
if isShowingAreYouSure {
3637
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized,leftBtnLabel: LocalizedStrings.undoConfirmNegative.localized, rightBtnLabel:LocalizedStrings.questGenericConfirmationYes.localized, isDontShowCheckVisible: true,onCancel: {

GoInfoGame/GoInfoGame/quests/SidewalkWidth/SideWalkWidth.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ class SideWalkWidth : QuestBase, Quest {
4040
return AnyView(self.internalForm as! SideWalkWidthForm)
4141
}
4242
}
43+
var subTitle: String = "" {
44+
didSet {
45+
if let sidwalk = self.internalForm as? SideWalkWidthForm {
46+
sidwalk.viewModel.subTitle = self.subTitle
47+
}
48+
}
49+
}
4350

4451
override init() {
4552
super.init()

GoInfoGame/GoInfoGame/quests/SidewalkWidth/SideWalkWidthForm.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import SwiftUI
99
import UIKit
1010
import Combine
1111

12+
class SideWalkWidthFormModel : ObservableObject {
13+
@Published var subTitle: String = "Residential Road"
14+
}
1215

1316
struct SideWalkWidthForm: View, QuestForm {
1417
typealias AnswerClass = WidthAnswer
@@ -17,13 +20,14 @@ struct SideWalkWidthForm: View, QuestForm {
1720
@State private var inches: Int = 0
1821
@State private var isConfirmAlert: Bool = false
1922
@State private var isKeyboardVisible: Bool = false // Track keyboard visibility
23+
@ObservedObject var viewModel = SideWalkWidthFormModel()
2024
var action: ((WidthAnswer) -> Void)?
2125

2226
var body: some View {
2327
VStack{
2428
QuestionHeader(icon: Image("sidewalk-width-img"),
2529
title: LocalizedStrings.questDetermineSidewalkWidth.localized,
26-
subtitle: "Residential Road")
30+
subtitle: viewModel.subTitle)
2731
Text(LocalizedStrings.questRoadWithExplanation.localized).font(.caption)
2832
.frame(maxWidth: .infinity, alignment: .leading)
2933
.fixedSize(horizontal: false, vertical: true)

GoInfoGame/GoInfoGame/quests/WayLit/WayLitForm.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct WayLitForm: View, QuestForm {
3030
.background(RoundedRectangle(cornerRadius: 10)
3131
.fill(Color.white)
3232
.shadow(color: .gray, radius: 2, x: 0, y: 2))
33+
.padding(.bottom,20)
3334
}.padding()
3435
if isShowingAreYouSure {
3536
CustomSureAlert(alertTitle: LocalizedStrings.questSourceDialogTitle.localized, content: LocalizedStrings.questSourceDialogNote.localized,leftBtnLabel: LocalizedStrings.undoConfirmNegative.localized, rightBtnLabel:LocalizedStrings.questGenericConfirmationYes.localized, isDontShowCheckVisible: true,onCancel: {

0 commit comments

Comments
 (0)