Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import AppKitimport SwiftUI
struct MenuPanelChoice: View { let item: NSMenuItem let content: MenuPanelContent var showsImage = true @Environment(\.colorSchemeContrast) private var contrast
var body: some View { Button { content.perform(item) } label: { VStack(spacing: 6) { if showsImage, let image = item.image { Image(nsImage: image) .resizable() .interpolation(.high) .scaledToFit() .frame(width: 28, height: 22) .accessibilityHidden(true) } Text(item.title) .font(.caption) .fontWeight(item.state == .on ? .semibold : .regular) .multilineTextAlignment(.center) .fixedSize(horizontal: false, vertical: true) } .frame(maxWidth: .infinity, minHeight: showsImage ? 52 : 28) .padding(.horizontal, 4) .padding(.vertical, 5) .background( item.state == .on ? Color.accentColor.opacity(0.14) : Color.primary.opacity(0.035), in: .rect(cornerRadius: 8) ) .overlay { RoundedRectangle(cornerRadius: 8) .strokeBorder( item.state == .on ? Color.accentColor : Color.primary.opacity(contrast == .increased ? 0.5 : 0.08), lineWidth: item.state == .on ? 2 : 1) } } .buttonStyle(.plain) .disabled(!item.isEnabled) .opacity(item.isEnabled ? 1 : 0.5) .accessibilityLabel(item.title) .accessibilityAddTraits(item.state == .on ? .isSelected : []) .accessibilityIdentifier(item.identifier?.rawValue ?? item.title) .help(item.toolTip ?? item.title) }}