|
|
@@ -31,7 +31,7 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
31
|
31
|
private let backButton = NSButton()
|
|
32
|
32
|
private let forwardButton = NSButton()
|
|
33
|
33
|
private let reloadButton = NSButton()
|
|
34
|
|
- private let dismissEmbeddedButton = NSButton(title: L("Home"), target: nil, action: nil)
|
|
|
34
|
+ private let dismissEmbeddedButton = NSButton()
|
|
35
|
35
|
private let toolbarContainer = NSView()
|
|
36
|
36
|
private var appearanceObserver: NSObjectProtocol?
|
|
37
|
37
|
private var languageObserver: NSObjectProtocol?
|
|
|
@@ -47,16 +47,15 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
47
|
47
|
webView.uiDelegate = self
|
|
48
|
48
|
webView.customUserAgent = Self.desktopSafariLikeUserAgent
|
|
49
|
49
|
|
|
50
|
|
- configureToolbarButton(backButton, symbolName: "chevron.backward", action: #selector(goBack))
|
|
51
|
|
- configureToolbarButton(forwardButton, symbolName: "chevron.forward", action: #selector(goForward))
|
|
52
|
|
- configureToolbarButton(reloadButton, symbolName: "arrow.clockwise", action: #selector(reload))
|
|
53
|
|
-
|
|
54
|
|
- dismissEmbeddedButton.translatesAutoresizingMaskIntoConstraints = false
|
|
55
|
|
- dismissEmbeddedButton.bezelStyle = .rounded
|
|
56
|
|
- dismissEmbeddedButton.isBordered = true
|
|
57
|
|
- dismissEmbeddedButton.target = self
|
|
58
|
|
- dismissEmbeddedButton.action = #selector(dismissEmbedded)
|
|
59
|
|
- dismissEmbeddedButton.toolTip = L("Return to the previous screen")
|
|
|
50
|
+ configureSymbolToolbarButton(backButton, symbolName: "chevron.backward", action: #selector(goBack))
|
|
|
51
|
+ configureSymbolToolbarButton(forwardButton, symbolName: "chevron.forward", action: #selector(goForward))
|
|
|
52
|
+ configureSymbolToolbarButton(reloadButton, symbolName: "arrow.clockwise", action: #selector(reload))
|
|
|
53
|
+ configureSymbolToolbarButton(
|
|
|
54
|
+ dismissEmbeddedButton,
|
|
|
55
|
+ symbolName: "house.fill",
|
|
|
56
|
+ action: #selector(dismissEmbedded),
|
|
|
57
|
+ toolTipKey: "Return to the previous screen"
|
|
|
58
|
+ )
|
|
60
|
59
|
|
|
61
|
60
|
toolbarContainer.translatesAutoresizingMaskIntoConstraints = false
|
|
62
|
61
|
toolbarContainer.wantsLayer = true
|
|
|
@@ -100,10 +99,15 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
100
|
99
|
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
|
101
|
100
|
]
|
|
102
|
101
|
if onDismissEmbedded != nil {
|
|
103
|
|
- layoutConstraints.append(dismissEmbeddedButton.heightAnchor.constraint(equalToConstant: 28))
|
|
|
102
|
+ layoutConstraints.append(contentsOf: [
|
|
|
103
|
+ dismissEmbeddedButton.widthAnchor.constraint(equalToConstant: 32),
|
|
|
104
|
+ dismissEmbeddedButton.heightAnchor.constraint(equalToConstant: 28)
|
|
|
105
|
+ ])
|
|
104
|
106
|
}
|
|
105
|
107
|
NSLayoutConstraint.activate(layoutConstraints)
|
|
106
|
108
|
|
|
|
109
|
+ applyLocalizedStrings()
|
|
|
110
|
+
|
|
107
|
111
|
updateNavigationButtons()
|
|
108
|
112
|
applyCurrentAppearance()
|
|
109
|
113
|
appearanceObserver = NotificationCenter.default.addObserver(
|
|
|
@@ -158,40 +162,75 @@ final class IndeedJobBrowserViewController: NSViewController, WKNavigationDelega
|
|
158
|
162
|
])
|
|
159
|
163
|
}
|
|
160
|
164
|
|
|
161
|
|
- private func configureToolbarButton(_ button: NSButton, symbolName: String, action: Selector) {
|
|
162
|
|
- button.translatesAutoresizingMaskIntoConstraints = false
|
|
163
|
|
- button.bezelStyle = .texturedRounded
|
|
|
165
|
+ private func applyHomeToolbarButtonStyle(to button: NSButton) {
|
|
|
166
|
+ button.bezelStyle = .rounded
|
|
164
|
167
|
button.isBordered = true
|
|
165
|
|
- button.image = NSImage(systemSymbolName: symbolName, accessibilityDescription: nil)
|
|
|
168
|
+ }
|
|
|
169
|
+
|
|
|
170
|
+ private func configureSymbolToolbarButton(
|
|
|
171
|
+ _ button: NSButton,
|
|
|
172
|
+ symbolName: String,
|
|
|
173
|
+ action: Selector,
|
|
|
174
|
+ toolTipKey: String? = nil
|
|
|
175
|
+ ) {
|
|
|
176
|
+ button.translatesAutoresizingMaskIntoConstraints = false
|
|
|
177
|
+ applyHomeToolbarButtonStyle(to: button)
|
|
166
|
178
|
button.imagePosition = .imageOnly
|
|
|
179
|
+ button.title = ""
|
|
167
|
180
|
button.target = self
|
|
168
|
181
|
button.action = action
|
|
|
182
|
+ if let toolTipKey {
|
|
|
183
|
+ button.toolTip = L(toolTipKey)
|
|
|
184
|
+ }
|
|
|
185
|
+ updateSymbolToolbarButtonImage(button, symbolName: symbolName, accessibilityLabelKey: toolTipKey)
|
|
|
186
|
+ }
|
|
|
187
|
+
|
|
|
188
|
+ private func updateSymbolToolbarButtonImage(
|
|
|
189
|
+ _ button: NSButton,
|
|
|
190
|
+ symbolName: String,
|
|
|
191
|
+ accessibilityLabelKey: String? = nil
|
|
|
192
|
+ ) {
|
|
|
193
|
+ let label = accessibilityLabelKey.map { L($0) }
|
|
|
194
|
+ button.image = NSImage(systemSymbolName: symbolName, accessibilityDescription: label)
|
|
169
|
195
|
}
|
|
170
|
196
|
|
|
171
|
197
|
private func applyCurrentAppearance() {
|
|
172
|
198
|
toolbarContainer.layer?.backgroundColor = AppDashboardTheme.chromeBackground.cgColor
|
|
173
|
|
- let accent = AppDashboardTheme.brandBlue
|
|
174
|
|
- dismissEmbeddedButton.contentTintColor = accent
|
|
175
|
|
- backButton.contentTintColor = accent
|
|
176
|
|
- forwardButton.contentTintColor = accent
|
|
177
|
|
- reloadButton.contentTintColor = accent
|
|
|
199
|
+ let labelColor = AppDashboardTheme.primaryText
|
|
|
200
|
+ dismissEmbeddedButton.contentTintColor = labelColor
|
|
|
201
|
+ reloadButton.contentTintColor = labelColor
|
|
|
202
|
+ updateNavigationButtons()
|
|
178
|
203
|
}
|
|
179
|
204
|
|
|
180
|
205
|
private func applyLocalizedStrings() {
|
|
181
|
|
- dismissEmbeddedButton.title = L("Home")
|
|
182
|
206
|
dismissEmbeddedButton.toolTip = L("Return to the previous screen")
|
|
|
207
|
+ updateSymbolToolbarButtonImage(
|
|
|
208
|
+ dismissEmbeddedButton,
|
|
|
209
|
+ symbolName: "house.fill",
|
|
|
210
|
+ accessibilityLabelKey: "Return to the previous screen"
|
|
|
211
|
+ )
|
|
|
212
|
+ updateSymbolToolbarButtonImage(backButton, symbolName: "chevron.backward")
|
|
|
213
|
+ updateSymbolToolbarButtonImage(forwardButton, symbolName: "chevron.forward")
|
|
|
214
|
+ updateSymbolToolbarButtonImage(reloadButton, symbolName: "arrow.clockwise")
|
|
183
|
215
|
}
|
|
184
|
216
|
|
|
185
|
217
|
private func updateNavigationButtons() {
|
|
186
|
|
- backButton.isEnabled = webView.canGoBack
|
|
187
|
|
- forwardButton.isEnabled = webView.canGoForward
|
|
|
218
|
+ // Keep buttons enabled so the rounded chrome matches Home; dim only the chevrons when unavailable.
|
|
|
219
|
+ backButton.isEnabled = true
|
|
|
220
|
+ forwardButton.isEnabled = true
|
|
|
221
|
+ let active = AppDashboardTheme.primaryText
|
|
|
222
|
+ let inactive = AppDashboardTheme.secondaryText
|
|
|
223
|
+ backButton.contentTintColor = webView.canGoBack ? active : inactive
|
|
|
224
|
+ forwardButton.contentTintColor = webView.canGoForward ? active : inactive
|
|
188
|
225
|
}
|
|
189
|
226
|
|
|
190
|
227
|
@objc private func goBack() {
|
|
|
228
|
+ guard webView.canGoBack else { return }
|
|
191
|
229
|
webView.goBack()
|
|
192
|
230
|
}
|
|
193
|
231
|
|
|
194
|
232
|
@objc private func goForward() {
|
|
|
233
|
+ guard webView.canGoForward else { return }
|
|
195
|
234
|
webView.goForward()
|
|
196
|
235
|
}
|
|
197
|
236
|
|