mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Open search, stats, and settings from the Mac toolbar and View menu.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
011bc3c685
commit
df89cd1984
1 changed files with 63 additions and 20 deletions
|
|
@ -9,23 +9,23 @@ struct MaturitaApp: App {
|
||||||
MacRoot(vm: vm)
|
MacRoot(vm: vm)
|
||||||
}
|
}
|
||||||
.defaultSize(width: 1100, height: 720)
|
.defaultSize(width: 1100, height: 720)
|
||||||
|
.windowToolbarStyle(.unified)
|
||||||
.commands {
|
.commands {
|
||||||
CommandGroup(replacing: .newItem) {}
|
CommandGroup(replacing: .newItem) {}
|
||||||
CommandMenu(vm.tr("search_placeholder")) {
|
CommandGroup(after: .sidebar) {
|
||||||
Button(vm.tr("search_placeholder")) {
|
|
||||||
vm.tab = .search
|
|
||||||
}
|
|
||||||
.keyboardShortcut("k", modifiers: [.command])
|
|
||||||
}
|
|
||||||
CommandMenu(vm.tr("subjects_title")) {
|
|
||||||
Button(vm.tr("search_home")) {
|
Button(vm.tr("search_home")) {
|
||||||
vm.go(.subjects)
|
vm.tab = .practice
|
||||||
|
vm.practicePath = []
|
||||||
}
|
}
|
||||||
.keyboardShortcut("1", modifiers: [.command])
|
.keyboardShortcut("1", modifiers: [.command])
|
||||||
Button(vm.tr("stats")) {
|
Button(vm.tr("stats")) {
|
||||||
vm.tab = .progress
|
vm.tab = .progress
|
||||||
}
|
}
|
||||||
.keyboardShortcut("2", modifiers: [.command])
|
.keyboardShortcut("2", modifiers: [.command])
|
||||||
|
Button(vm.tr("search")) {
|
||||||
|
vm.tab = .search
|
||||||
|
}
|
||||||
|
.keyboardShortcut("k", modifiers: [.command])
|
||||||
Button(vm.tr("settings")) {
|
Button(vm.tr("settings")) {
|
||||||
vm.tab = .settings
|
vm.tab = .settings
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +50,31 @@ struct MacRoot: View {
|
||||||
MacSidebar(vm: vm)
|
MacSidebar(vm: vm)
|
||||||
.navigationSplitViewColumnWidth(min: 200, ideal: 240, max: 320)
|
.navigationSplitViewColumnWidth(min: 200, ideal: 240, max: 320)
|
||||||
} detail: {
|
} detail: {
|
||||||
|
MacDetail(vm: vm)
|
||||||
|
}
|
||||||
|
.navigationSplitViewStyle(.balanced)
|
||||||
|
.tint(vm.palette.tint)
|
||||||
|
.preferredColorScheme(vm.mode == .dark ? .dark : .light)
|
||||||
|
.overlay(alignment: .top) {
|
||||||
|
if showsUpdateAccessory {
|
||||||
|
UpdateBanner(vm: vm)
|
||||||
|
.padding(12)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onAppear { vm.checkUpdate(false) }
|
||||||
|
.frame(minWidth: 880, minHeight: 540)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var showsUpdateAccessory: Bool {
|
||||||
|
vm.update.canInstall || vm.update.status == "downloading" || vm.update.status == "staged"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct MacDetail: View {
|
||||||
|
@ObservedObject var vm: AppModel
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Group {
|
||||||
switch vm.tab {
|
switch vm.tab {
|
||||||
case .practice:
|
case .practice:
|
||||||
NavigationStack(path: $vm.practicePath) {
|
NavigationStack(path: $vm.practicePath) {
|
||||||
|
|
@ -72,21 +97,39 @@ struct MacRoot: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationSplitViewStyle(.balanced)
|
.toolbar {
|
||||||
.tint(vm.palette.tint)
|
MacWindowToolbar(vm: vm)
|
||||||
.preferredColorScheme(vm.mode == .dark ? .dark : .light)
|
|
||||||
.overlay(alignment: .top) {
|
|
||||||
if showsUpdateAccessory {
|
|
||||||
UpdateBanner(vm: vm)
|
|
||||||
.padding(12)
|
|
||||||
}
|
}
|
||||||
|
.toolbarBackgroundVisibility(.visible, for: .windowToolbar)
|
||||||
}
|
}
|
||||||
.onAppear { vm.checkUpdate(false) }
|
|
||||||
.frame(minWidth: 880, minHeight: 540)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private var showsUpdateAccessory: Bool {
|
private struct MacWindowToolbar: ToolbarContent {
|
||||||
vm.update.canInstall || vm.update.status == "downloading" || vm.update.status == "staged"
|
@ObservedObject var vm: AppModel
|
||||||
|
|
||||||
|
var body: some ToolbarContent {
|
||||||
|
ToolbarItemGroup(placement: .primaryAction) {
|
||||||
|
Button {
|
||||||
|
vm.tab = .search
|
||||||
|
} label: {
|
||||||
|
Label(vm.tr("search"), systemImage: "magnifyingglass")
|
||||||
|
}
|
||||||
|
.help(vm.tr("search"))
|
||||||
|
|
||||||
|
Button {
|
||||||
|
vm.tab = .progress
|
||||||
|
} label: {
|
||||||
|
Label(vm.tr("stats"), systemImage: "chart.bar.fill")
|
||||||
|
}
|
||||||
|
.help(vm.tr("stats"))
|
||||||
|
|
||||||
|
Button {
|
||||||
|
vm.tab = .settings
|
||||||
|
} label: {
|
||||||
|
Label(vm.tr("settings"), systemImage: "gearshape")
|
||||||
|
}
|
||||||
|
.help(vm.tr("settings"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue