From df89cd1984dfdb16a37be0a565679f3a9e44d2a4 Mon Sep 17 00:00:00 2001 From: pepaskopec-blip Date: Mon, 21 Sep 2026 12:30:05 +0200 Subject: [PATCH] Open search, stats, and settings from the Mac toolbar and View menu. Co-authored-by: Cursor --- macos/Maturita/MaturitaApp.swift | 83 ++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 20 deletions(-) diff --git a/macos/Maturita/MaturitaApp.swift b/macos/Maturita/MaturitaApp.swift index 3257b41..c84259a 100644 --- a/macos/Maturita/MaturitaApp.swift +++ b/macos/Maturita/MaturitaApp.swift @@ -9,23 +9,23 @@ struct MaturitaApp: App { MacRoot(vm: vm) } .defaultSize(width: 1100, height: 720) + .windowToolbarStyle(.unified) .commands { CommandGroup(replacing: .newItem) {} - CommandMenu(vm.tr("search_placeholder")) { - Button(vm.tr("search_placeholder")) { - vm.tab = .search - } - .keyboardShortcut("k", modifiers: [.command]) - } - CommandMenu(vm.tr("subjects_title")) { + CommandGroup(after: .sidebar) { Button(vm.tr("search_home")) { - vm.go(.subjects) + vm.tab = .practice + vm.practicePath = [] } .keyboardShortcut("1", modifiers: [.command]) Button(vm.tr("stats")) { vm.tab = .progress } .keyboardShortcut("2", modifiers: [.command]) + Button(vm.tr("search")) { + vm.tab = .search + } + .keyboardShortcut("k", modifiers: [.command]) Button(vm.tr("settings")) { vm.tab = .settings } @@ -50,6 +50,31 @@ struct MacRoot: View { MacSidebar(vm: vm) .navigationSplitViewColumnWidth(min: 200, ideal: 240, max: 320) } 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 { case .practice: NavigationStack(path: $vm.practicePath) { @@ -72,21 +97,39 @@ struct MacRoot: View { } } } - .navigationSplitViewStyle(.balanced) - .tint(vm.palette.tint) - .preferredColorScheme(vm.mode == .dark ? .dark : .light) - .overlay(alignment: .top) { - if showsUpdateAccessory { - UpdateBanner(vm: vm) - .padding(12) - } + .toolbar { + MacWindowToolbar(vm: vm) } - .onAppear { vm.checkUpdate(false) } - .frame(minWidth: 880, minHeight: 540) + .toolbarBackgroundVisibility(.visible, for: .windowToolbar) } +} - private var showsUpdateAccessory: Bool { - vm.update.canInstall || vm.update.status == "downloading" || vm.update.status == "staged" +private struct MacWindowToolbar: ToolbarContent { + @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")) + } } }