Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import SwiftUI
struct MenuPanelView: View { let content: MenuPanelContent let height: CGFloat @Environment(\.accessibilityReduceTransparency) private var reduceTransparency
var body: some View { VStack(spacing: 0) { ScrollView { VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 8) { HStack { Text(UIStrings.text("Parcel")).font(.title3).fontWeight(.semibold) Spacer() if let automatic = content.command(.toggleAutomaticTiling) { MenuPanelToggle(item: automatic, content: content) .font(.subheadline) .fixedSize(horizontal: false, vertical: true) } } Text(content.status) .font(.caption) .foregroundStyle(.secondary) .fixedSize(horizontal: false, vertical: true) } if let problem = content.item("menu.problem") { MenuPanelNotice(item: problem, content: content) } if content.canArrange { MenuPanelArrangement(content: content) } else { HStack { Menu(UIStrings.text("Layout")) { MenuPanelCommands(items: content.layoutItems, content: content) } Menu(MenuText.text("Tile count")) { MenuPanelCommands(items: content.countItems, content: content) } } } MenuPanelModes(content: content)
} .padding(16) } .scrollBounceBehavior(.basedOnSize) Divider().padding(.horizontal, 16) footer.padding(16).fixedSize(horizontal: false, vertical: true) } .frame(width: 380, height: height) .background(reduceTransparency ? Color(nsColor: .windowBackgroundColor) : .clear) .onExitCommand(perform: content.dismiss) }
private var footer: some View { HStack { if let settings = content.command(.openSettings) { Button { content.perform(settings) } label: { Label(settings.title, systemImage: "gearshape") } .buttonStyle(.borderless) } Spacer() if let shortcuts = content.item("menu.shortcuts") { Button { content.perform(shortcuts) } label: { Image(systemName: "keyboard") } .buttonStyle(.borderless) .help(shortcuts.title) .accessibilityLabel(shortcuts.title) } Menu(MenuText.text("More")) { MenuPanelCommands( items: [content.item("menu.tour")].compactMap { $0 } + (content.item("menu.more")?.submenu?.items ?? []) + [content.command(.quit)].compactMap { $0 }, content: content) } .fixedSize() .menuStyle(.borderlessButton) } .font(.subheadline) }}