|
|
@@ -43,6 +43,7 @@ final class ViewController: NSViewController {
|
|
43
|
43
|
private var sidebarPageByView = [ObjectIdentifier: SidebarPage]()
|
|
44
|
44
|
private var meetingProviderByView = [ObjectIdentifier: MeetingProvider]()
|
|
45
|
45
|
private var settingsActionByView = [ObjectIdentifier: SettingsAction]()
|
|
|
46
|
+ private weak var centeredTitleLabel: NSTextField?
|
|
46
|
47
|
|
|
47
|
48
|
private let darkModeDefaultsKey = "settings.darkModeEnabled"
|
|
48
|
49
|
private var darkModeEnabled: Bool {
|
|
|
@@ -82,6 +83,9 @@ final class ViewController: NSViewController {
|
|
82
|
83
|
view.window?.setContentSize(NSSize(width: 1120, height: 690))
|
|
83
|
84
|
view.window?.minSize = NSSize(width: 940, height: 600)
|
|
84
|
85
|
applyWindowTitle(for: selectedSidebarPage)
|
|
|
86
|
+ if let window = view.window {
|
|
|
87
|
+ installCenteredTitleIfNeeded(on: window)
|
|
|
88
|
+ }
|
|
85
|
89
|
}
|
|
86
|
90
|
|
|
87
|
91
|
override var representedObject: Any? {
|
|
|
@@ -241,18 +245,46 @@ private extension ViewController {
|
|
241
|
245
|
}
|
|
242
|
246
|
|
|
243
|
247
|
private func applyWindowTitle(for page: SidebarPage) {
|
|
|
248
|
+ let title: String
|
|
244
|
249
|
switch page {
|
|
245
|
250
|
case .joinMeetings:
|
|
246
|
|
- view.window?.title = "App for Google Meet"
|
|
|
251
|
+ title = "App for Google Meet"
|
|
247
|
252
|
case .photo:
|
|
248
|
|
- view.window?.title = "Backgrounds — Photo"
|
|
|
253
|
+ title = "Backgrounds — Photo"
|
|
249
|
254
|
case .video:
|
|
250
|
|
- view.window?.title = "Backgrounds — Video"
|
|
|
255
|
+ title = "Backgrounds — Video"
|
|
251
|
256
|
case .tutorials:
|
|
252
|
|
- view.window?.title = "Tutorials"
|
|
|
257
|
+ title = "Tutorials"
|
|
253
|
258
|
case .settings:
|
|
254
|
|
- view.window?.title = "Settings"
|
|
|
259
|
+ title = "Settings"
|
|
255
|
260
|
}
|
|
|
261
|
+ view.window?.title = title
|
|
|
262
|
+ centeredTitleLabel?.stringValue = title
|
|
|
263
|
+ }
|
|
|
264
|
+
|
|
|
265
|
+ private func installCenteredTitleIfNeeded(on window: NSWindow) {
|
|
|
266
|
+ guard centeredTitleLabel == nil else { return }
|
|
|
267
|
+ guard let titlebarView = window.standardWindowButton(.closeButton)?.superview else { return }
|
|
|
268
|
+
|
|
|
269
|
+ let label = NSTextField(labelWithString: window.title)
|
|
|
270
|
+ label.translatesAutoresizingMaskIntoConstraints = false
|
|
|
271
|
+ label.alignment = .center
|
|
|
272
|
+ label.font = NSFont.titleBarFont(ofSize: 0)
|
|
|
273
|
+ label.textColor = .labelColor
|
|
|
274
|
+ label.lineBreakMode = .byTruncatingTail
|
|
|
275
|
+ label.maximumNumberOfLines = 1
|
|
|
276
|
+
|
|
|
277
|
+ titlebarView.addSubview(label)
|
|
|
278
|
+
|
|
|
279
|
+ NSLayoutConstraint.activate([
|
|
|
280
|
+ label.centerXAnchor.constraint(equalTo: titlebarView.centerXAnchor),
|
|
|
281
|
+ label.centerYAnchor.constraint(equalTo: titlebarView.centerYAnchor),
|
|
|
282
|
+ label.leadingAnchor.constraint(greaterThanOrEqualTo: titlebarView.leadingAnchor, constant: 90),
|
|
|
283
|
+ label.trailingAnchor.constraint(lessThanOrEqualTo: titlebarView.trailingAnchor, constant: -90)
|
|
|
284
|
+ ])
|
|
|
285
|
+
|
|
|
286
|
+ window.titleVisibility = .hidden
|
|
|
287
|
+ centeredTitleLabel = label
|
|
256
|
288
|
}
|
|
257
|
289
|
|
|
258
|
290
|
private func updateSidebarAppearance() {
|