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
3
4public struct SheetsDocumentMenu: View {
5 @FocusedValue(\.sheetEditor) private var editor
6 public init() {}
7 private var available: Bool { editor?.model.page != nil }
8 private var writable: Bool {
9 guard let model = editor?.model else { return false }
10 return model.mayWrite && !model.busy && !model.hasUnconfirmedChanges
11 }
12 public var body: some View {
13 Group {
14 Button(sheetsMacString("Save")) { if let model = editor?.model { Task { await model.saveAll() } } }
15 .keyboardShortcut("s").disabled(!available)
16 Button(sheetsMacString("Rename…")) { editor?.panel.wrappedValue = "Rename" }.disabled(!writable)
17 Button(sheetsMacString("Export workbook…")) { editor?.panel.wrappedValue = "Export" }.disabled(!available)
18 Button(sheetsMacString("Version history…")) { editor?.panel.wrappedValue = "History" }.disabled(!available)
19 Button(sheetsMacString("Share…")) { editor?.panel.wrappedValue = "Share" }.disabled(editor?.model.page?.MayShare != true)
20
21 }
22 }
23}
24#endif
25