|
@@ -43,6 +43,7 @@ final class ViewController: NSViewController {
|
|
|
private var sidebarPageByView = [ObjectIdentifier: SidebarPage]()
|
|
private var sidebarPageByView = [ObjectIdentifier: SidebarPage]()
|
|
|
private var meetingProviderByView = [ObjectIdentifier: MeetingProvider]()
|
|
private var meetingProviderByView = [ObjectIdentifier: MeetingProvider]()
|
|
|
private var settingsActionByView = [ObjectIdentifier: SettingsAction]()
|
|
private var settingsActionByView = [ObjectIdentifier: SettingsAction]()
|
|
|
|
|
+ private weak var centeredTitleLabel: NSTextField?
|
|
|
|
|
|
|
|
private let darkModeDefaultsKey = "settings.darkModeEnabled"
|
|
private let darkModeDefaultsKey = "settings.darkModeEnabled"
|
|
|
private var darkModeEnabled: Bool {
|
|
private var darkModeEnabled: Bool {
|
|
@@ -82,6 +83,9 @@ final class ViewController: NSViewController {
|
|
|
view.window?.setContentSize(NSSize(width: 1120, height: 690))
|
|
view.window?.setContentSize(NSSize(width: 1120, height: 690))
|
|
|
view.window?.minSize = NSSize(width: 940, height: 600)
|
|
view.window?.minSize = NSSize(width: 940, height: 600)
|
|
|
applyWindowTitle(for: selectedSidebarPage)
|
|
applyWindowTitle(for: selectedSidebarPage)
|
|
|
|
|
+ if let window = view.window {
|
|
|
|
|
+ installCenteredTitleIfNeeded(on: window)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override var representedObject: Any? {
|
|
override var representedObject: Any? {
|
|
@@ -241,18 +245,46 @@ private extension ViewController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private func applyWindowTitle(for page: SidebarPage) {
|
|
private func applyWindowTitle(for page: SidebarPage) {
|
|
|
|
|
+ let title: String
|
|
|
switch page {
|
|
switch page {
|
|
|
case .joinMeetings:
|
|
case .joinMeetings:
|
|
|
- view.window?.title = "App for Google Meet"
|
|
|
|
|
|
|
+ title = "App for Google Meet"
|
|
|
case .photo:
|
|
case .photo:
|
|
|
- view.window?.title = "Backgrounds — Photo"
|
|
|
|
|
|
|
+ title = "Backgrounds — Photo"
|
|
|
case .video:
|
|
case .video:
|
|
|
- view.window?.title = "Backgrounds — Video"
|
|
|
|
|
|
|
+ title = "Backgrounds — Video"
|
|
|
case .tutorials:
|
|
case .tutorials:
|
|
|
- view.window?.title = "Tutorials"
|
|
|
|
|
|
|
+ title = "Tutorials"
|
|
|
case .settings:
|
|
case .settings:
|
|
|
- view.window?.title = "Settings"
|
|
|
|
|
|
|
+ title = "Settings"
|
|
|
}
|
|
}
|
|
|
|
|
+ view.window?.title = title
|
|
|
|
|
+ centeredTitleLabel?.stringValue = title
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func installCenteredTitleIfNeeded(on window: NSWindow) {
|
|
|
|
|
+ guard centeredTitleLabel == nil else { return }
|
|
|
|
|
+ guard let titlebarView = window.standardWindowButton(.closeButton)?.superview else { return }
|
|
|
|
|
+
|
|
|
|
|
+ let label = NSTextField(labelWithString: window.title)
|
|
|
|
|
+ label.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
+ label.alignment = .center
|
|
|
|
|
+ label.font = NSFont.titleBarFont(ofSize: 0)
|
|
|
|
|
+ label.textColor = .labelColor
|
|
|
|
|
+ label.lineBreakMode = .byTruncatingTail
|
|
|
|
|
+ label.maximumNumberOfLines = 1
|
|
|
|
|
+
|
|
|
|
|
+ titlebarView.addSubview(label)
|
|
|
|
|
+
|
|
|
|
|
+ NSLayoutConstraint.activate([
|
|
|
|
|
+ label.centerXAnchor.constraint(equalTo: titlebarView.centerXAnchor),
|
|
|
|
|
+ label.centerYAnchor.constraint(equalTo: titlebarView.centerYAnchor),
|
|
|
|
|
+ label.leadingAnchor.constraint(greaterThanOrEqualTo: titlebarView.leadingAnchor, constant: 90),
|
|
|
|
|
+ label.trailingAnchor.constraint(lessThanOrEqualTo: titlebarView.trailingAnchor, constant: -90)
|
|
|
|
|
+ ])
|
|
|
|
|
+
|
|
|
|
|
+ window.titleVisibility = .hidden
|
|
|
|
|
+ centeredTitleLabel = label
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private func updateSidebarAppearance() {
|
|
private func updateSidebarAppearance() {
|