oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2import SwiftUI
3import SheetsKit
4
5struct SheetsWindowCommands: Commands {
6 let windows: SheetsWindows
7 @FocusedValue(\.sheetsWindowAccount) private var account
8 @FocusedValue(\.sheetsAccountActions) private var accountActions
9 @Environment(\.openWindow) private var openWindow
10 var body: some Commands {
11 CommandGroup(after: .appSettings) {
12 Button(sheetsMacString("Accounts")) {
13 if let action = accountActions?.accounts { action() }
14 else { windows.accountsRequested = true; openWindow(id: "home") }
15 }.disabled(accountActions?.canManage == false)
16 Button(sheetsMacString("Sign out")) { accountActions?.signOut() }
17 .disabled(accountActions?.canSignOut != true)
18 Divider()
19 }
20
21 CommandGroup(replacing: .newItem) {
22 Button(sheetsMacString("New spreadsheet")) {
23 windows.createRequested = true
24 openWindow(id: "home")
25 }.keyboardShortcut("n")
26 Menu(sheetsMacString("Recent")) {
27 ForEach(windows.entries.filter { $0.account == (account ?? windows.activeAccount) }.prefix(20)) { entry in
28 Button(entry.title) {
29 windows.setOpen(entry.id, true)
30 openWindow(id: "document", value: entry.id)
31 }
32 }
33 if !windows.entries.contains(where: { $0.account == (account ?? windows.activeAccount) }) {
34 Text(sheetsMacString("No recent documents"))
35 }
36 }
37 Divider()
38 SheetsDocumentMenu()
39 }
40
41 }
42}
43#endif
44