import SwiftUI struct SheetFormatMenu: View { @Bindable var model: SheetModel @State private var columnWidth = 110 @State private var rowHeight = 32 var body: some View { Menu("Format", systemImage: "textformat") { Button("Bold") { Task { await model.format([ "bold": !model.selection.coordinates.allSatisfy { model.styles[model.cells[$0]?.f ?? ""]?.b == true } ]) } }.keyboardShortcut("b") Button("Italic") { Task { await model.format([ "italic": !model.selection.coordinates.allSatisfy { model.styles[model.cells[$0]?.f ?? ""]?.i == true } ]) } }.keyboardShortcut("i") Menu("Alignment") { Button("Automatic") { Task { await model.format(["align": ""]) } } ForEach(["left", "center", "right"], id: \.self) { value in Button(value.capitalized) { Task { await model.format(["align": value]) } } } } Menu("Number format") { ForEach(model.page?.NumberFormats ?? []) { value in Button(value.Label) { Task { await model.format(["numfmt": value.Code]) } } } } Menu("Fill colour") { Button("No fill") { Task { await model.format(["fill": "none"]) } } ForEach(model.page?.FillSwatches ?? []) { value in Button(value.Label) { Task { await model.format(["fill": value.Name]) } } } } Menu("Text colour") { Button("Default") { Task { await model.format(["ink": "none"]) } } ForEach(model.page?.InkSwatches ?? []) { value in Button(value.Label) { Task { await model.format(["ink": value.Name]) } } } } Button("Clear formatting") { Task { await model.format([ "bold": false, "italic": false, "align": "", "numfmt": "", "fill": "none", "ink": "none", ]) } } }.disabled(!model.mayWrite || model.hasUnconfirmedChanges || model.busy) } }