style: match action icons and input text to application rows
This commit is contained in:
@@ -38,16 +38,19 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
applicationLabel.lineBreakMode = .byTruncatingTail
|
||||
applicationLabel.font = .systemFont(ofSize: 12, weight: .medium)
|
||||
row.isSelected = true
|
||||
row.addGestureRecognizer(NSClickGestureRecognizer(target: self, action: #selector(chooseAction)))
|
||||
action.isBordered = false
|
||||
action.alignment = .left
|
||||
action.font = .systemFont(ofSize: 14, weight: .medium)
|
||||
action.font = .systemFont(ofSize: LauncherRowView.textSize, weight: .medium)
|
||||
action.contentTintColor = .systemRed
|
||||
action.attributedTitle = NSAttributedString(string: action.title, attributes: [
|
||||
.foregroundColor: NSColor.systemRed, .font: NSFont.systemFont(ofSize: 14, weight: .medium)
|
||||
.foregroundColor: NSColor.systemRed, .font: NSFont.systemFont(ofSize: LauncherRowView.textSize, weight: .medium)
|
||||
])
|
||||
action.image = NSImage(systemSymbolName: "trash", accessibilityDescription: nil)?
|
||||
.withSymbolConfiguration(NSImage.SymbolConfiguration(pointSize: 18, weight: .regular))
|
||||
action.imagePosition = .imageLeading
|
||||
let icon = ActionIconView()
|
||||
icon.image = NSImage(systemSymbolName: "trash", accessibilityDescription: nil)
|
||||
icon.contentTintColor = .systemRed
|
||||
icon.imageScaling = .scaleProportionallyDown
|
||||
icon.setAccessibilityElement(false)
|
||||
action.target = self
|
||||
action.action = #selector(chooseAction)
|
||||
action.setAccessibilityLabel("Uninstall application")
|
||||
@@ -59,10 +62,10 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
returnKey.layer?.cornerRadius = 5
|
||||
returnKey.layer?.borderWidth = 1
|
||||
returnKey.setAccessibilityElement(false)
|
||||
search.font = .systemFont(ofSize: 16)
|
||||
search.font = .systemFont(ofSize: LauncherRowView.textSize)
|
||||
search.textColor = SunsetPalette.text
|
||||
search.placeholderAttributedString = NSAttributedString(string: "Search for actions…", attributes: [
|
||||
.foregroundColor: SunsetPalette.secondaryText, .font: NSFont.systemFont(ofSize: 16)
|
||||
.foregroundColor: SunsetPalette.secondaryText, .font: NSFont.systemFont(ofSize: LauncherRowView.textSize)
|
||||
])
|
||||
search.isBordered = false
|
||||
search.drawsBackground = false
|
||||
@@ -84,7 +87,7 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
child.translatesAutoresizingMaskIntoConstraints = false
|
||||
if child !== background { content.addSubview(child) }
|
||||
}
|
||||
for child in [action, returnKey] {
|
||||
for child in [icon, action, returnKey] {
|
||||
child.translatesAutoresizingMaskIntoConstraints = false
|
||||
row.addSubview(child)
|
||||
}
|
||||
@@ -106,7 +109,11 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
row.trailingAnchor.constraint(equalTo: content.trailingAnchor, constant: -8),
|
||||
row.topAnchor.constraint(equalTo: applicationLabel.bottomAnchor, constant: 10),
|
||||
row.heightAnchor.constraint(equalToConstant: LauncherRowView.rowHeight),
|
||||
action.leadingAnchor.constraint(equalTo: row.leadingAnchor, constant: 8),
|
||||
icon.leadingAnchor.constraint(equalTo: row.leadingAnchor, constant: 8),
|
||||
icon.centerYAnchor.constraint(equalTo: row.centerYAnchor),
|
||||
icon.widthAnchor.constraint(equalToConstant: LauncherRowView.iconSize),
|
||||
icon.heightAnchor.constraint(equalToConstant: LauncherRowView.iconSize),
|
||||
action.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: LauncherRowView.iconToTextSpacing),
|
||||
action.centerYAnchor.constraint(equalTo: row.centerYAnchor),
|
||||
action.trailingAnchor.constraint(equalTo: returnKey.leadingAnchor, constant: -12),
|
||||
returnKey.trailingAnchor.constraint(equalTo: row.trailingAnchor, constant: -12),
|
||||
@@ -186,11 +193,18 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
}
|
||||
|
||||
@objc private func chooseAction() {
|
||||
guard isShown else { return }
|
||||
close()
|
||||
uninstall?()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private final class ActionIconView: NSImageView {
|
||||
// SF Symbol optical insets otherwise enlarge a 22-point icon box beyond application icon sizing.
|
||||
override var alignmentRectInsets: NSEdgeInsets { NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) }
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private final class ActionsSearchField: NSSearchField {
|
||||
var closeActions: (() -> Void)?
|
||||
|
||||
Reference in New Issue
Block a user