diff --git a/Clocker/Overall App/VersionUpdateHandler.swift b/Clocker/Overall App/VersionUpdateHandler.swift index 8b6b90a..654aede 100644 --- a/Clocker/Overall App/VersionUpdateHandler.swift +++ b/Clocker/Overall App/VersionUpdateHandler.swift @@ -229,7 +229,7 @@ class VersionUpdateHandler: NSObject { } dataTask = NetworkManager.task(with: itunesServiceURL) { [weak self] response, error in - guard let self, let data = response else {return } + guard let self = self, let data = response else {return } if (error != nil || response == nil) { Logger.info("Response is nil or error is non-nil") @@ -258,7 +258,7 @@ class VersionUpdateHandler: NSObject { } newerVersionAvailable = latestVersion?.compareVersion(self.applicationVersion) == .orderedDescending - if (verboseLogging) { + if (self.verboseLogging) { if (newerVersionAvailable) { Logger.info("iVersion found a new version \(latestVersion ?? "N/A") of the app on iTunes. Current version is \(self.applicationVersion ?? "nil")") } else { @@ -266,7 +266,7 @@ class VersionUpdateHandler: NSObject { } } } else { - if (verboseLogging) { + if (self.verboseLogging) { Logger.info("iVersion found that the application bundle ID \(self.applicationBundleID) does not match the bundle ID of the app found on iTunes \(bundleID) with the specified App Store ID") } } @@ -276,13 +276,13 @@ class VersionUpdateHandler: NSObject { //TODO: Set download error Logger.info("Versions downloaded \(versions ?? [:])") - performSelector(onMainThread: #selector(setRemoteVersionsDict(_:)), + self.performSelector(onMainThread: #selector(VersionUpdateHandler.setRemoteVersionsDict(_:)), with: versions, waitUntilDone: true) - performSelector(onMainThread: #selector(setLastChecked(_:)), + self.performSelector(onMainThread: #selector(VersionUpdateHandler.setLastChecked(_:)), with: Date(), waitUntilDone: true) - performSelector(onMainThread: #selector(Self.downloadVersionsData), + self.performSelector(onMainThread: #selector(Self.downloadVersionsData), with: nil, waitUntilDone: true) } diff --git a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift index f403d6d..7d97c2c 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemHandler.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemHandler.swift @@ -154,6 +154,17 @@ class StatusItemHandler: NSObject { statusContainerView?.wantsLayer = true statusItem.button?.addSubview(statusContainerView!) statusItem.button?.frame = statusContainerView!.bounds + + // For OS < 11, we need to fix the sizing (width) on the button's window + // Otherwise, we won't be able to see the menu bar option at all. + if let window = statusItem.button?.window { + let currentFrame = window.frame + let newFrame = NSRect(x: currentFrame.origin.x, + y: currentFrame.origin.y, + width: statusItem.button?.bounds.size.width ?? 0, + height: currentFrame.size.height) + window.setFrame(newFrame, display: true) + } statusItem.button?.subviews.first?.window?.backgroundColor = NSColor.clear } diff --git a/Clocker/Preferences/Menu Bar/StatusItemView.swift b/Clocker/Preferences/Menu Bar/StatusItemView.swift index 2723a62..87fc168 100644 --- a/Clocker/Preferences/Menu Bar/StatusItemView.swift +++ b/Clocker/Preferences/Menu Bar/StatusItemView.swift @@ -107,11 +107,16 @@ class StatusItemView: NSView { } timeView.disableWrapping() + + var topAnchorConstant: CGFloat = 7.0 + if #available(macOS 11.0, *) { + topAnchorConstant = 0.0 + } NSLayoutConstraint.activate([ locationView.leadingAnchor.constraint(equalTo: leadingAnchor), locationView.trailingAnchor.constraint(equalTo: trailingAnchor), - locationView.topAnchor.constraint(equalTo: topAnchor, constant: 0), + locationView.topAnchor.constraint(equalTo: topAnchor, constant: topAnchorConstant), locationView.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.35), ]) diff --git a/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift b/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift index 1858145..f4495d5 100644 --- a/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift +++ b/Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift @@ -49,11 +49,16 @@ class UpcomingEventStatusItemView: NSView { } etaField.disableWrapping() + + var topAnchorConstant: CGFloat = 7 + if #available(macOS 11.0, *) { + topAnchorConstant = 0 + } NSLayoutConstraint.activate([ nextEventField.leadingAnchor.constraint(equalTo: leadingAnchor), nextEventField.trailingAnchor.constraint(equalTo: trailingAnchor), - nextEventField.topAnchor.constraint(equalTo: topAnchor, constant: 0), + nextEventField.topAnchor.constraint(equalTo: topAnchor, constant: topAnchorConstant), nextEventField.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.35), ])