native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
Swift
123456789101112131415161718192021222324252627282930313233343536373839import ComposableArchitectureimport SwiftUI
struct ShelfSidebarButton: View { let store: StoreOf<RepositoriesFeature> let isSelected: Bool @Environment(CommandKeyObserver.self) private var commandKeyObserver @Environment(\.resolvedKeybindings) private var resolvedKeybindings
var body: some View { Button { store.send(.toggleShelf) } label: { HStack(spacing: 6) { Label("Shelf", systemImage: "books.vertical") .font(.callout) .frame(maxWidth: .infinity, alignment: .leading) if commandKeyObserver.isPressed, let shortcut = AppShortcuts.display(for: AppShortcuts.CommandID.toggleShelf, in: resolvedKeybindings) { ShortcutHintView(text: shortcut, color: .secondary) } } .padding(.horizontal, 12) .padding(.vertical, 6) .contentShape(.rect) } .disabled(!store.isShelfActive && !store.canEnterShelf) .buttonStyle(.plain) .background(isSelected ? Color.accentColor.opacity(0.15) : .clear, in: .rect(cornerRadius: 6)) .help( AppShortcuts.helpText( title: "Shelf", commandID: AppShortcuts.CommandID.toggleShelf, in: resolvedKeybindings )) }}