macos: command palette entries support leading color
parent
c84113d199
commit
7e46200d31
|
|
@ -6,6 +6,7 @@ struct CommandOption: Identifiable, Hashable {
|
||||||
let description: String?
|
let description: String?
|
||||||
let symbols: [String]?
|
let symbols: [String]?
|
||||||
let leadingIcon: String?
|
let leadingIcon: String?
|
||||||
|
let leadingColor: Color?
|
||||||
let badge: String?
|
let badge: String?
|
||||||
let emphasis: Bool
|
let emphasis: Bool
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
|
@ -15,6 +16,7 @@ struct CommandOption: Identifiable, Hashable {
|
||||||
description: String? = nil,
|
description: String? = nil,
|
||||||
symbols: [String]? = nil,
|
symbols: [String]? = nil,
|
||||||
leadingIcon: String? = nil,
|
leadingIcon: String? = nil,
|
||||||
|
leadingColor: Color? = nil,
|
||||||
badge: String? = nil,
|
badge: String? = nil,
|
||||||
emphasis: Bool = false,
|
emphasis: Bool = false,
|
||||||
action: @escaping () -> Void
|
action: @escaping () -> Void
|
||||||
|
|
@ -23,6 +25,7 @@ struct CommandOption: Identifiable, Hashable {
|
||||||
self.description = description
|
self.description = description
|
||||||
self.symbols = symbols
|
self.symbols = symbols
|
||||||
self.leadingIcon = leadingIcon
|
self.leadingIcon = leadingIcon
|
||||||
|
self.leadingColor = leadingColor
|
||||||
self.badge = badge
|
self.badge = badge
|
||||||
self.emphasis = emphasis
|
self.emphasis = emphasis
|
||||||
self.action = action
|
self.action = action
|
||||||
|
|
@ -283,6 +286,12 @@ fileprivate struct CommandRow: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: action) {
|
Button(action: action) {
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
|
if let color = option.leadingColor {
|
||||||
|
Circle()
|
||||||
|
.fill(color)
|
||||||
|
.frame(width: 8, height: 8)
|
||||||
|
}
|
||||||
|
|
||||||
if let icon = option.leadingIcon {
|
if let icon = option.leadingIcon {
|
||||||
Image(systemName: icon)
|
Image(systemName: icon)
|
||||||
.foregroundStyle(option.emphasis ? Color.accentColor : .secondary)
|
.foregroundStyle(option.emphasis ? Color.accentColor : .secondary)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ struct TerminalCommandPaletteView: View {
|
||||||
return CommandOption(
|
return CommandOption(
|
||||||
title: c.title,
|
title: c.title,
|
||||||
description: c.description,
|
description: c.description,
|
||||||
symbols: ghosttyConfig.keyboardShortcut(for: c.action)?.keyList
|
symbols: ghosttyConfig.keyboardShortcut(for: c.action)?.keyList,
|
||||||
) {
|
) {
|
||||||
onAction(c.action)
|
onAction(c.action)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue