feat: complete translation language controls and styling
This commit is contained in:
@@ -12,7 +12,10 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
ActionEntry(title: "Reset ranking", symbol: "arrow.counterclockwise", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Quit application", symbol: "stop.circle", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Uninstall application", symbol: "trash", color: .systemRed),
|
||||
ActionEntry(title: "Copy Emoji", symbol: "doc.on.doc", color: SunsetPalette.text)
|
||||
ActionEntry(title: "Copy Emoji", symbol: "doc.on.doc", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Change source language…", symbol: "character.bubble", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Change target language…", symbol: "character.bubble", color: SunsetPalette.text),
|
||||
ActionEntry(title: "Swap languages", symbol: "arrow.left.arrow.right", color: SunsetPalette.text)
|
||||
]
|
||||
private var visibleEntries: [Int] = []
|
||||
private var availableEntries = Array(0..<6)
|
||||
@@ -35,6 +38,9 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
var resetRanking: (() -> Void)?
|
||||
var quit: (() -> Void)?
|
||||
var uninstall: (() -> Void)?
|
||||
var changeSourceLanguage: (() -> Void)?
|
||||
var changeTargetLanguage: (() -> Void)?
|
||||
var swapLanguages: (() -> Void)?
|
||||
var closed: (() -> Void)?
|
||||
var isShown: Bool { viewIfLoaded?.superview != nil && !isClosing }
|
||||
|
||||
@@ -128,10 +134,17 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
}
|
||||
|
||||
func showEmoji(named name: String, relativeTo anchor: NSView) {
|
||||
show(title: name, relativeTo: anchor, available: [0, 6, 1], emoji: true)
|
||||
show(title: name, relativeTo: anchor, available: [0, 6, 1], emoji: true,
|
||||
searchAccessibilityLabel: "Search emoji actions")
|
||||
}
|
||||
|
||||
private func show(title: String, relativeTo anchor: NSView, available: [Int], emoji: Bool = false) {
|
||||
func showTranslation(relativeTo anchor: NSView) {
|
||||
show(title: "Translation", relativeTo: anchor, available: [7, 8, 9],
|
||||
searchAccessibilityLabel: "Search translation actions")
|
||||
}
|
||||
|
||||
private func show(title: String, relativeTo anchor: NSView, available: [Int], emoji: Bool = false,
|
||||
searchAccessibilityLabel: String = "Search application actions") {
|
||||
if isShown { close(); return }
|
||||
guard let window = anchor.window, let host = window.contentView else { return }
|
||||
let pill = anchor.superview ?? anchor
|
||||
@@ -142,7 +155,7 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
entries[0].button.title = openTitle
|
||||
entries[0].button.setAccessibilityLabel(openTitle)
|
||||
entries[0].icon.image = NSImage(systemSymbolName: emoji ? "doc.on.clipboard" : "arrow.up.forward.app", accessibilityDescription: nil)
|
||||
search.setAccessibilityLabel(emoji ? "Search emoji actions" : "Search application actions")
|
||||
search.setAccessibilityLabel(searchAccessibilityLabel)
|
||||
let favorite = entries[1]
|
||||
let favoriteTitle = isFavorite ? "Remove Favorite" : "Favorite"
|
||||
favorite.button.attributedTitle = NSAttributedString(string: favoriteTitle, attributes: [
|
||||
@@ -294,6 +307,9 @@ final class ApplicationActionsController: NSViewController, NSSearchFieldDelegat
|
||||
case 4: quit?()
|
||||
case 5: uninstall?()
|
||||
case 6: copyEmoji?()
|
||||
case 7: changeSourceLanguage?()
|
||||
case 8: changeTargetLanguage?()
|
||||
case 9: swapLanguages?()
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user