Skip to content

Commit f904a7e

Browse files
authored
Merge pull request #171 from TaskarCenterAtUW/feature-relocate-hide-quest-button
Relocate 'Hide Quest' button
2 parents 834b829 + 63b2a1f commit f904a7e

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct MapView: View {
3737
selectedQuest: $viewModel.selectedQuest,
3838
shouldShowPolyline: $shouldShowPolyline,
3939

40-
isPresented: $showPopover, contextualInfo: { contextualInfo in
40+
isPresented: $isPresented, contextualInfo: { contextualInfo in
4141
print(contextualInfo)
4242
selectedDetent = .fraction(0.8)
4343
self.setContextualInfo(contextualinfo: contextualInfo)
@@ -108,40 +108,8 @@ struct MapView: View {
108108
EmptyView()
109109
}
110110
}
111-
// ToolbarItem(placement: .navigationBarTrailing) {
112-
// HStack {
113-
// NavigationLink(destination: QuestsListUIView()) {
114-
// Image(systemName: "list.bullet")
115-
// }
116-
// NavigationLink(destination: MeasureSidewalkView()) {
117-
// Image(systemName: "camera")
118-
// }
119-
// }
120-
// }
121111
}
122112
.toolbarBackground(.visible, for: .navigationBar)
123-
124-
.popover(isPresented: $showPopover) {
125-
VStack {
126-
Button("Hide Quest") {
127-
viewModel.hideQuest(elementId: viewModel.selectedQuest!.parent!.displayUnit.id)
128-
showPopover = false
129-
shouldShowPolyline = false
130-
}
131-
132-
Button("Answer Quest") {
133-
showPopover = false
134-
isPresented = true
135-
}
136-
.padding()
137-
}
138-
.padding([.top], 50)
139-
.frame(maxHeight: 50)
140-
.onAppear {
141-
shouldShowPolyline = true
142-
}
143-
.presentationDetents([.fraction(0.2)])
144-
}
145113
.onChange(of: showPopover) { newValue in
146114
if !newValue {
147115
shouldShowPolyline = false
@@ -182,6 +150,9 @@ struct MapView: View {
182150
isSyncing = false
183151
print("synced")
184152
showAlert = true
153+
case .hideElement(let elementId):
154+
shouldShowPolyline = false
155+
viewModel.hideQuest(elementId: elementId)
185156
}
186157
}
187158
.onReceive(QuestsPublisher.shared.refreshQuest, perform: { _ in
@@ -218,6 +189,7 @@ public enum SheetDismissalScenario {
218189
case submitted(String)
219190
case syncing
220191
case synced
192+
case hideElement(String)
221193
}
222194

223195
//TODO: Move to a new file

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,32 @@ struct LongForm: View, QuestForm {
4646
var body: some View {
4747
ZStack {
4848
VStack(alignment: .leading) {
49-
VStack {
5049
HStack {
5150
Text("\(elementHeading())")
5251
.font(.custom("Lato-Bold", size: 16))
53-
.padding([.leading], 20)
54-
Text("ID: \(questID ?? "0")")
55-
.font(.custom("Lato-Regular", size: 13))
56-
.padding([.leading], 20)
52+
Spacer()
53+
Button("Hide Quest") {
54+
withAnimation {
55+
MapViewPublisher.shared.dismissSheet.send(.hideElement(questID ?? "0"))
56+
presentationMode.wrappedValue.dismiss()
57+
}
58+
59+
}
5760
}
61+
5862
.padding(EdgeInsets(top: 20, leading: 20, bottom: 10, trailing: 20))
63+
64+
Text("ID: \(questID ?? "0")")
65+
.font(.custom("Lato-Regular", size: 13))
66+
.padding([.leading], 20)
67+
5968
LongFormDismissButtonView {
6069
withAnimation {
6170
presentationMode.wrappedValue.dismiss()
6271
}
6372
}
6473
.padding([.trailing], 20)
65-
}
74+
6675

6776

6877
VStack {

0 commit comments

Comments
 (0)