|
|
@@ -31,7 +31,7 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
|
private let backButton = NSButton()
|
|
|
private let forwardButton = NSButton()
|
|
|
private let reloadButton = NSButton()
|
|
|
- private let dismissEmbeddedButton = NSButton(title: L("Home"), target: nil, action: nil)
|
|
|
+ private let dismissEmbeddedButton = NSButton()
|
|
|
private let toolbarContainer = NSView()
|
|
|
private var appearanceObserver: NSObjectProtocol?
|
|
|
private var languageObserver: NSObjectProtocol?
|
|
|
@@ -47,16 +47,15 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
|
webView.uiDelegate = self
|
|
|
webView.customUserAgent = Self.desktopSafariLikeUserAgent
|
|
|
|
|
|
- configureToolbarButton(backButton, symbolName: "chevron.backward", action: #selector(goBack))
|
|
|
- configureToolbarButton(forwardButton, symbolName: "chevron.forward", action: #selector(goForward))
|
|
|
- configureToolbarButton(reloadButton, symbolName: "arrow.clockwise", action: #selector(reload))
|
|
|
-
|
|
|
- dismissEmbeddedButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- dismissEmbeddedButton.bezelStyle = .rounded
|
|
|
- dismissEmbeddedButton.isBordered = true
|
|
|
- dismissEmbeddedButton.target = self
|
|
|
- dismissEmbeddedButton.action = #selector(dismissEmbedded)
|
|
|
- dismissEmbeddedButton.toolTip = L("Return to the previous screen")
|
|
|
+ configureSymbolToolbarButton(backButton, symbolName: "chevron.backward", action: #selector(goBack))
|
|
|
+ configureSymbolToolbarButton(forwardButton, symbolName: "chevron.forward", action: #selector(goForward))
|
|
|
+ configureSymbolToolbarButton(reloadButton, symbolName: "arrow.clockwise", action: #selector(reload))
|
|
|
+ configureSymbolToolbarButton(
|
|
|
+ dismissEmbeddedButton,
|
|
|
+ symbolName: "house.fill",
|
|
|
+ action: #selector(dismissEmbedded),
|
|
|
+ toolTipKey: "Return to the previous screen"
|
|
|
+ )
|
|
|
|
|
|
toolbarContainer.translatesAutoresizingMaskIntoConstraints = false
|
|
|
toolbarContainer.wantsLayer = true
|
|
|
@@ -100,10 +99,15 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
|
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
|
|
]
|
|
|
if onDismissEmbedded != nil {
|
|
|
- layoutConstraints.append(dismissEmbeddedButton.heightAnchor.constraint(equalToConstant: 28))
|
|
|
+ layoutConstraints.append(contentsOf: [
|
|
|
+ dismissEmbeddedButton.widthAnchor.constraint(equalToConstant: 32),
|
|
|
+ dismissEmbeddedButton.heightAnchor.constraint(equalToConstant: 28)
|
|
|
+ ])
|
|
|
}
|
|
|
NSLayoutConstraint.activate(layoutConstraints)
|
|
|
|
|
|
+ applyLocalizedStrings()
|
|
|
+
|
|
|
updateNavigationButtons()
|
|
|
applyCurrentAppearance()
|
|
|
appearanceObserver = NotificationCenter.default.addObserver(
|
|
|
@@ -158,40 +162,75 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
|
])
|
|
|
}
|
|
|
|
|
|
- private func configureToolbarButton(_ button: NSButton, symbolName: String, action: Selector) {
|
|
|
- button.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- button.bezelStyle = .texturedRounded
|
|
|
+ private func applyHomeToolbarButtonStyle(to button: NSButton) {
|
|
|
+ button.bezelStyle = .rounded
|
|
|
button.isBordered = true
|
|
|
- button.image = NSImage(systemSymbolName: symbolName, accessibilityDescription: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ private func configureSymbolToolbarButton(
|
|
|
+ _ button: NSButton,
|
|
|
+ symbolName: String,
|
|
|
+ action: Selector,
|
|
|
+ toolTipKey: String? = nil
|
|
|
+ ) {
|
|
|
+ button.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ applyHomeToolbarButtonStyle(to: button)
|
|
|
button.imagePosition = .imageOnly
|
|
|
+ button.title = ""
|
|
|
button.target = self
|
|
|
button.action = action
|
|
|
+ if let toolTipKey {
|
|
|
+ button.toolTip = L(toolTipKey)
|
|
|
+ }
|
|
|
+ updateSymbolToolbarButtonImage(button, symbolName: symbolName, accessibilityLabelKey: toolTipKey)
|
|
|
+ }
|
|
|
+
|
|
|
+ private func updateSymbolToolbarButtonImage(
|
|
|
+ _ button: NSButton,
|
|
|
+ symbolName: String,
|
|
|
+ accessibilityLabelKey: String? = nil
|
|
|
+ ) {
|
|
|
+ let label = accessibilityLabelKey.map { L($0) }
|
|
|
+ button.image = NSImage(systemSymbolName: symbolName, accessibilityDescription: label)
|
|
|
}
|
|
|
|
|
|
private func applyCurrentAppearance() {
|
|
|
toolbarContainer.layer?.backgroundColor = AppDashboardTheme.chromeBackground.cgColor
|
|
|
- let accent = AppDashboardTheme.brandBlue
|
|
|
- dismissEmbeddedButton.contentTintColor = accent
|
|
|
- backButton.contentTintColor = accent
|
|
|
- forwardButton.contentTintColor = accent
|
|
|
- reloadButton.contentTintColor = accent
|
|
|
+ let labelColor = AppDashboardTheme.primaryText
|
|
|
+ dismissEmbeddedButton.contentTintColor = labelColor
|
|
|
+ reloadButton.contentTintColor = labelColor
|
|
|
+ updateNavigationButtons()
|
|
|
}
|
|
|
|
|
|
private func applyLocalizedStrings() {
|
|
|
- dismissEmbeddedButton.title = L("Home")
|
|
|
dismissEmbeddedButton.toolTip = L("Return to the previous screen")
|
|
|
+ updateSymbolToolbarButtonImage(
|
|
|
+ dismissEmbeddedButton,
|
|
|
+ symbolName: "house.fill",
|
|
|
+ accessibilityLabelKey: "Return to the previous screen"
|
|
|
+ )
|
|
|
+ updateSymbolToolbarButtonImage(backButton, symbolName: "chevron.backward")
|
|
|
+ updateSymbolToolbarButtonImage(forwardButton, symbolName: "chevron.forward")
|
|
|
+ updateSymbolToolbarButtonImage(reloadButton, symbolName: "arrow.clockwise")
|
|
|
}
|
|
|
|
|
|
private func updateNavigationButtons() {
|
|
|
- backButton.isEnabled = webView.canGoBack
|
|
|
- forwardButton.isEnabled = webView.canGoForward
|
|
|
+ // Keep buttons enabled so the rounded chrome matches Home; dim only the chevrons when unavailable.
|
|
|
+ backButton.isEnabled = true
|
|
|
+ forwardButton.isEnabled = true
|
|
|
+ let active = AppDashboardTheme.primaryText
|
|
|
+ let inactive = AppDashboardTheme.secondaryText
|
|
|
+ backButton.contentTintColor = webView.canGoBack ? active : inactive
|
|
|
+ forwardButton.contentTintColor = webView.canGoForward ? active : inactive
|
|
|
}
|
|
|
|
|
|
@objc private func goBack() {
|
|
|
+ guard webView.canGoBack else { return }
|
|
|
webView.goBack()
|
|
|
}
|
|
|
|
|
|
@objc private func goForward() {
|
|
|
+ guard webView.canGoForward else { return }
|
|
|
webView.goForward()
|
|
|
}
|
|
|
|