style: correct translation header and footer layout
This commit is contained in:
@@ -4,6 +4,8 @@ import ConjureKit
|
||||
@MainActor
|
||||
final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSearchFieldDelegate, NSTableViewDataSource, NSTableViewDelegate {
|
||||
private let searchField = NSSearchField()
|
||||
private let searchSymbol = IconView(font: .systemFont(ofSize: 20))
|
||||
private let translationBack = NSButton(title: "", target: nil, action: nil)
|
||||
private let tableView = ApplicationTableView()
|
||||
private let statusLabel = NSTextField(labelWithString: "Finding applications…")
|
||||
private let emptyLabel = NSTextField(labelWithString: "Finding applications…")
|
||||
@@ -226,10 +228,20 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
searchField.delegate = self
|
||||
searchField.setAccessibilityLabel("Search applications, calculate, or convert units and currencies")
|
||||
|
||||
let symbol = IconView(font: searchFont)
|
||||
symbol.image = NSImage(systemSymbolName: "sparkles", accessibilityDescription: nil)
|
||||
symbol.contentTintColor = SunsetPalette.accent
|
||||
let header = NSStackView(views: [symbol, searchField])
|
||||
searchSymbol.image = NSImage(systemSymbolName: "sparkles", accessibilityDescription: nil)
|
||||
searchSymbol.contentTintColor = SunsetPalette.accent
|
||||
translationBack.image = IconStyle.symbol("chevron.left", for: searchFont)
|
||||
translationBack.imageScaling = .scaleProportionallyDown
|
||||
translationBack.isBordered = false
|
||||
translationBack.contentTintColor = SunsetPalette.secondaryText
|
||||
translationBack.setAccessibilityLabel("Back to applications")
|
||||
translationBack.toolTip = "Back to applications (Escape)"
|
||||
translationBack.isHidden = true
|
||||
NSLayoutConstraint.activate([
|
||||
translationBack.widthAnchor.constraint(equalToConstant: IconStyle.applicationSize(for: searchFont)),
|
||||
translationBack.heightAnchor.constraint(equalToConstant: IconStyle.applicationSize(for: searchFont)),
|
||||
])
|
||||
let header = NSStackView(views: [searchSymbol, translationBack, searchField])
|
||||
header.orientation = .horizontal
|
||||
header.alignment = .centerY
|
||||
header.spacing = 12
|
||||
@@ -780,6 +792,9 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
guard let self, let controller else { return }
|
||||
controller.view.removeFromSuperview()
|
||||
self.translation = nil
|
||||
self.translationBack.isHidden = true
|
||||
self.translationBack.target = nil
|
||||
self.searchSymbol.isHidden = false
|
||||
for view in self.launcherViews.dropFirst() {
|
||||
view.isHidden = false
|
||||
view.setAccessibilityHidden(false)
|
||||
@@ -795,6 +810,10 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
|
||||
actions.close()
|
||||
(window as? LauncherPanel)?.resetNumberHints()
|
||||
openButton.keyEquivalent = ""
|
||||
searchSymbol.isHidden = true
|
||||
translationBack.target = controller
|
||||
translationBack.action = #selector(TranslationController.goBack)
|
||||
translationBack.isHidden = false
|
||||
searchField.stringValue = ""
|
||||
searchField.placeholderAttributedString = NSAttributedString(
|
||||
string: "Enter English text to translate…",
|
||||
|
||||
@@ -26,16 +26,6 @@ final class TranslationController: NSViewController, NSTextFieldDelegate, NSText
|
||||
let title = NSTextField(labelWithString: "Conjure Translate · English → Japanese")
|
||||
title.font = .systemFont(ofSize: 13, weight: .semibold)
|
||||
title.textColor = SunsetPalette.text
|
||||
let back = NSButton(title: "", target: self, action: #selector(goBack))
|
||||
back.image = IconStyle.symbol("chevron.left", for: title.font!)
|
||||
back.imageScaling = .scaleProportionallyDown
|
||||
back.isBordered = false
|
||||
back.contentTintColor = SunsetPalette.secondaryText
|
||||
back.setAccessibilityLabel("Back to applications")
|
||||
back.toolTip = "Back to applications (Escape)"
|
||||
let heading = NSStackView(views: [back, title, NSView()])
|
||||
heading.alignment = .centerY
|
||||
heading.spacing = 12
|
||||
provider.addItems(withTitles: ["MyMemory (no key)", "OpenAI · gpt-6-luna"])
|
||||
provider.selectItem(at: UserDefaults.standard.string(forKey: "translationProvider") == "openai" ? 1 : 0)
|
||||
provider.setAccessibilityLabel("Translation provider")
|
||||
@@ -75,8 +65,10 @@ final class TranslationController: NSViewController, NSTextFieldDelegate, NSText
|
||||
returnKey.centerYAnchor.constraint(equalTo: actionPill.centerYAnchor),
|
||||
returnKey.trailingAnchor.constraint(equalTo: actionPill.trailingAnchor, constant: -12),
|
||||
])
|
||||
let footer = NSStackView(views: [NSView(), actionPill])
|
||||
let footer = NSStackView(views: [status, NSView(), actionPill])
|
||||
footer.orientation = .horizontal
|
||||
footer.alignment = .centerY
|
||||
footer.spacing = 12
|
||||
footer.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(footer)
|
||||
output.isEditable = false
|
||||
@@ -98,7 +90,8 @@ final class TranslationController: NSViewController, NSTextFieldDelegate, NSText
|
||||
disclosure.setAccessibilityLabel("Translation provider, privacy, and limits")
|
||||
status.font = .systemFont(ofSize: 12)
|
||||
status.setAccessibilityLabel("Translation status and errors")
|
||||
let stack = NSStackView(views: [heading, provider, disclosure, credentials, scroll, status])
|
||||
status.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||
let stack = NSStackView(views: [title, provider, disclosure, credentials, scroll])
|
||||
stack.orientation = .vertical
|
||||
stack.alignment = .leading
|
||||
stack.spacing = 12
|
||||
@@ -106,8 +99,6 @@ final class TranslationController: NSViewController, NSTextFieldDelegate, NSText
|
||||
stack.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(stack)
|
||||
NSLayoutConstraint.activate([
|
||||
back.widthAnchor.constraint(equalToConstant: 22),
|
||||
back.heightAnchor.constraint(equalToConstant: 22),
|
||||
stack.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
|
||||
stack.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
|
||||
stack.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
@@ -120,7 +111,6 @@ final class TranslationController: NSViewController, NSTextFieldDelegate, NSText
|
||||
disclosure.widthAnchor.constraint(equalTo: stack.widthAnchor),
|
||||
scroll.widthAnchor.constraint(equalTo: stack.widthAnchor),
|
||||
scroll.heightAnchor.constraint(greaterThanOrEqualToConstant: 100),
|
||||
status.widthAnchor.constraint(equalTo: stack.widthAnchor),
|
||||
])
|
||||
updateProvider()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user