Skip to content

Commit 80dd31a

Browse files
author
Achyut Kumar M
committed
add switchWorkspace option to the sheet and switch (navigation) logic
1 parent 88be93e commit 80dd31a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ struct MapView: View {
252252
}
253253

254254
.sheet(isPresented: $showUserSettingsSheet) {
255-
UserSettingsView( options: OptionModel.options, onNavigate: { navigate in
255+
UserSettingsView(selectedWorkspace: selectedWorkspace?.title ?? "", options: OptionModel.options, onNavigate: { navigate in
256256
showUserSettingsSheet = false
257257
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
258258
// navigateToProfileSettings = true
@@ -280,6 +280,10 @@ struct MapView: View {
280280
let extendedVisibleRect = rect.insetBy(dx: -rect.size.width * 0.25, dy: -rect.size.height * 0.25)
281281
shadowOverlay.addVisibleRect(extendedVisibleRect)
282282

283+
case .switchWorkspace:
284+
//navigate to inital view
285+
print("Switch workspace here")
286+
switchToInitialView()
283287
}
284288
}
285289

@@ -422,6 +426,14 @@ struct MapView: View {
422426
}
423427
}
424428

429+
func switchToInitialView() {
430+
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
431+
let window = scene.windows.first {
432+
window.rootViewController = UIHostingController(rootView: InitialView())
433+
window.makeKeyAndVisible()
434+
}
435+
}
436+
425437
private func setContextualInfo(contextualinfo: String) {
426438
contextualInfo.info = contextualinfo
427439

GoInfoGame/GoInfoGame/UI/UserSettingsView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,29 @@ struct OptionModel: Identifiable, Hashable {
1818
static let options: [OptionModel] = [
1919
OptionModel(title: "User Profile", icon: "person.crop.circle.fill", destination: .profile),
2020
OptionModel(title: "Manage Quests", icon: "slider.horizontal.3", destination: .manageQuests),
21-
OptionModel(title: "Download Data", icon: "arrow.down.circle.fill", destination: .downloadData)
21+
OptionModel(title: "Download Data", icon: "arrow.down.circle.fill", destination: .downloadData),
22+
OptionModel(title: "Switch Workspace", icon: "arrow.right.arrow.left.circle.fill", destination: .switchWorkspace)
2223
]
2324
}
2425

2526
enum SettingsDestination: Hashable {
2627
case profile
2728
case manageQuests
2829
case downloadData
30+
case switchWorkspace
2931

3032
}
3133
struct UserSettingsView: View {
3234
@Environment(\.presentationMode) var presentationMode
3335

34-
36+
@State var selectedWorkspace: String = ""
3537
let options: [OptionModel]
3638
let onNavigate: (SettingsDestination) -> Void
3739

3840
var body: some View {
3941
VStack(alignment: .leading, spacing: 12) {
4042
HStack(alignment: .firstTextBaseline) {
41-
Text("")
43+
Text(selectedWorkspace)
4244

4345

4446
Spacer()

0 commit comments

Comments
 (0)