Browse Source

Make things look good on older OSes for status item's button.

master
Abhishek Banthia 9 months ago
parent
commit
79ceb21b0c
  1. 12
      Clocker/Overall App/VersionUpdateHandler.swift
  2. 11
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  3. 7
      Clocker/Preferences/Menu Bar/StatusItemView.swift
  4. 7
      Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

12
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)
}

11
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
}

7
Clocker/Preferences/Menu Bar/StatusItemView.swift

@ -108,10 +108,15 @@ 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),
])

7
Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

@ -50,10 +50,15 @@ 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),
])

Loading…
Cancel
Save