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