Skip to content

Commit

Permalink
home(visionOS): add button to open preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Sep 21, 2023
1 parent 1483021 commit c6ddedc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Platform/Shared/VMNavigationListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ struct VMNavigationListView: View {
VMDetailsView(vm: vm)
} else {
VMPlaceholderView()
#if os(visionOS)
.toolbar {
UTMPreferenceButtonToolbarContent()
}
#endif
}
}
} else {
Expand Down
18 changes: 18 additions & 0 deletions Platform/Shared/VMToolbarModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct VMToolbarModifier: ViewModifier {

func body(content: Content) -> some View {
content.toolbar {
#if os(visionOS)
UTMPreferenceButtonToolbarContent()
#endif
ToolbarItemGroup(placement: buttonPlacement) {
if vm.isShortcut {
DestructiveButton {
Expand Down Expand Up @@ -151,3 +154,18 @@ struct VMToolbarModifier: ViewModifier {
})
}
}

#if os(visionOS)
struct UTMPreferenceButtonToolbarContent: ToolbarContent {
var body: some ToolbarContent {
ToolbarItem(placement: .topBarLeading) {
Button {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
} label: {
Label("Preferences", systemImage: "gear")
.labelStyle(.iconOnly)
}.help("Show UTM preferences")
}
}
}
#endif

0 comments on commit c6ddedc

Please sign in to comment.