Browse Source

Cleanup compact mode issues.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
c30ff88b68
  1. 5
      Clocker/Events and Reminders/CalendarHandler.swift
  2. 13
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift

5
Clocker/Events and Reminders/CalendarHandler.swift

@ -496,8 +496,9 @@ struct EventInfo {
let timeSince = Date().timeAgo(since: event.startDate) let timeSince = Date().timeAgo(since: event.startDate)
let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString) let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString)
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString) let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)
// If the user has not turned on seconds granularity for one of the timezones,
return "in \(withoutAgo.lowercased())" // we return "in 12 seconds" which looks weird.
return withoutAgo.contains("seconds") ? "starts soon" : "in \(withoutAgo.lowercased())"
} else if event.startDate.isTomorrow { } else if event.startDate.isTomorrow {
let hoursUntil = event.startDate.hoursUntil let hoursUntil = event.startDate.hoursUntil
return "in \(hoursUntil)h" return "in \(hoursUntil)h"

13
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -251,11 +251,24 @@ class StatusItemHandler: NSObject {
} else { } else {
let upcomingEventView = retrieveUpcomingEventStatusView() let upcomingEventView = retrieveUpcomingEventStatusView()
upcomingEventView?.removeFromSuperview() upcomingEventView?.removeFromSuperview()
constructCompactView() // So that Status Container View reclaims the space
} }
// This will internally call `statusItemViewSetNeedsDisplay` on all subviews ensuring all text in the menubar is up-to-date. // This will internally call `statusItemViewSetNeedsDisplay` on all subviews ensuring all text in the menubar is up-to-date.
statusContainerView?.updateTime() statusContainerView?.updateTime()
} }
private func removeUpcomingStatusItemView() {
NSAnimationContext.runAnimationGroup({ context in
context.duration = 0.2
let upcomingEventView = retrieveUpcomingEventStatusView()
upcomingEventView?.removeFromSuperview()
}) { [weak self] in
if let sSelf = self {
sSelf.constructCompactView()
}
}
}
func refresh() { func refresh() {
if currentState == .compactText { if currentState == .compactText {
updateCompactMenubar() updateCompactMenubar()

Loading…
Cancel
Save