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 withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString)
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)
return "in \(withoutAgo.lowercased())"
// If the user has not turned on seconds granularity for one of the timezones,
// we return "in 12 seconds" which looks weird.
return withoutAgo.contains("seconds") ? "starts soon" : "in \(withoutAgo.lowercased())"
} else if event.startDate.isTomorrow {
let hoursUntil = event.startDate.hoursUntil
return "in \(hoursUntil)h"

13
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -251,10 +251,23 @@ class StatusItemHandler: NSObject {
} else {
let upcomingEventView = retrieveUpcomingEventStatusView()
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.
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() {
if currentState == .compactText {

Loading…
Cancel
Save