|
|
@ -55,20 +55,12 @@ class ParentPanelController: NSWindowController { |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var scrollViewHeight: NSLayoutConstraint! |
|
|
|
@IBOutlet var scrollViewHeight: NSLayoutConstraint! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var calendarColorView: NSView! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var futureSliderView: NSView! |
|
|
|
@IBOutlet var futureSliderView: NSView! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var upcomingEventView: NSView? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var reviewView: NSView! |
|
|
|
@IBOutlet var reviewView: NSView! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var leftField: NSTextField! |
|
|
|
@IBOutlet var leftField: NSTextField! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var nextEventLabel: NSTextField! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var whiteRemoveButton: NSButton! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var sharingButton: NSButton! |
|
|
|
@IBOutlet var sharingButton: NSButton! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var leftButton: NSButton! |
|
|
|
@IBOutlet var leftButton: NSButton! |
|
|
@ -81,8 +73,6 @@ class ParentPanelController: NSWindowController { |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var pinButton: NSButton! |
|
|
|
@IBOutlet var pinButton: NSButton! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var calendarButton: NSButton! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var sliderDatePicker: NSDatePicker! |
|
|
|
@IBOutlet var sliderDatePicker: NSDatePicker! |
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet var roundedDateView: NSView! |
|
|
|
@IBOutlet var roundedDateView: NSView! |
|
|
@ -170,7 +160,7 @@ class ParentPanelController: NSWindowController { |
|
|
|
pinButton.image = sharedThemer.pinImage() |
|
|
|
pinButton.image = sharedThemer.pinImage() |
|
|
|
sharingButton.image = sharedThemer.sharingImage() |
|
|
|
sharingButton.image = sharedThemer.sharingImage() |
|
|
|
|
|
|
|
|
|
|
|
if let upcomingView = upcomingEventView { |
|
|
|
if let upcomingView = upcomingEventContainerView { |
|
|
|
upcomingView.setAccessibility("UpcomingEventView") |
|
|
|
upcomingView.setAccessibility("UpcomingEventView") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -287,9 +277,9 @@ class ParentPanelController: NSWindowController { |
|
|
|
let showUpcomingEventView = DataStore.shared().shouldDisplay(ViewType.upcomingEventView) |
|
|
|
let showUpcomingEventView = DataStore.shared().shouldDisplay(ViewType.upcomingEventView) |
|
|
|
|
|
|
|
|
|
|
|
if showUpcomingEventView == false { |
|
|
|
if showUpcomingEventView == false { |
|
|
|
upcomingEventView?.isHidden = true |
|
|
|
upcomingEventContainerView?.isHidden = true |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
upcomingEventView?.isHidden = false |
|
|
|
upcomingEventContainerView?.isHidden = false |
|
|
|
setupUpcomingEventView() |
|
|
|
setupUpcomingEventView() |
|
|
|
eventStoreChangedNotification = NotificationCenter.default.addObserver(forName: NSNotification.Name.EKEventStoreChanged, object: self, queue: OperationQueue.main) { _ in |
|
|
|
eventStoreChangedNotification = NotificationCenter.default.addObserver(forName: NSNotification.Name.EKEventStoreChanged, object: self, queue: OperationQueue.main) { _ in |
|
|
|
self.fetchCalendarEvents() |
|
|
|
self.fetchCalendarEvents() |
|
|
@ -320,13 +310,7 @@ class ParentPanelController: NSWindowController { |
|
|
|
if eventCenter.calendarAccessGranted() { |
|
|
|
if eventCenter.calendarAccessGranted() { |
|
|
|
// Nice. Events will be retrieved when we open the panel |
|
|
|
// Nice. Events will be retrieved when we open the panel |
|
|
|
} else if eventCenter.calendarAccessNotDetermined() { |
|
|
|
} else if eventCenter.calendarAccessNotDetermined() { |
|
|
|
if nextEventLabel != nil { |
|
|
|
upcomingEventCollectionView.reloadData() |
|
|
|
nextEventLabel.stringValue = NSLocalizedString("See your next Calendar event here.", |
|
|
|
|
|
|
|
comment: "Next Event Label for no Calendar access") |
|
|
|
|
|
|
|
setCalendarButtonTitle(buttonTitle: NSLocalizedString("Click here to start.", |
|
|
|
|
|
|
|
comment: "Button Title for no Calendar access")) |
|
|
|
|
|
|
|
calendarColorView.layer?.backgroundColor = NSColor(red: 97 / 255.0, green: 194 / 255.0, blue: 80 / 255.0, alpha: 1.0).cgColor |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
removeUpcomingEventView() |
|
|
|
removeUpcomingEventView() |
|
|
|
} |
|
|
|
} |
|
|
@ -359,8 +343,8 @@ class ParentPanelController: NSWindowController { |
|
|
|
@objc func themeChanged() { |
|
|
|
@objc func themeChanged() { |
|
|
|
let sharedThemer = Themer.shared() |
|
|
|
let sharedThemer = Themer.shared() |
|
|
|
|
|
|
|
|
|
|
|
if upcomingEventView?.isHidden == false { |
|
|
|
if upcomingEventContainerView?.isHidden == false { |
|
|
|
upcomingEventView?.layer?.backgroundColor = NSColor.clear.cgColor |
|
|
|
upcomingEventContainerView?.layer?.backgroundColor = NSColor.clear.cgColor |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
shutdownButton.image = sharedThemer.shutdownImage() |
|
|
|
shutdownButton.image = sharedThemer.shutdownImage() |
|
|
@ -382,20 +366,6 @@ class ParentPanelController: NSWindowController { |
|
|
|
morePopover = NSPopover() |
|
|
|
morePopover = NSPopover() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func setCalendarButtonTitle(buttonTitle: String) { |
|
|
|
|
|
|
|
let style = NSMutableParagraphStyle() |
|
|
|
|
|
|
|
style.alignment = .left |
|
|
|
|
|
|
|
style.lineBreakMode = .byTruncatingTail |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let boldFont = NSFont(name: "Avenir", size: 12) { |
|
|
|
|
|
|
|
let attributes = [NSAttributedString.Key.foregroundColor: NSColor.lightGray, NSAttributedString.Key.paragraphStyle: style, NSAttributedString.Key.font: boldFont] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let attributedString = NSAttributedString(string: buttonTitle, attributes: attributes) |
|
|
|
|
|
|
|
calendarButton.attributedTitle = attributedString |
|
|
|
|
|
|
|
calendarButton.toolTip = attributedString.string |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func screenHeight() -> CGFloat { |
|
|
|
func screenHeight() -> CGFloat { |
|
|
|
guard let main = NSScreen.main else { return 100 } |
|
|
|
guard let main = NSScreen.main else { return 100 } |
|
|
|
|
|
|
|
|
|
|
@ -737,10 +707,6 @@ class ParentPanelController: NSWindowController { |
|
|
|
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView) |
|
|
|
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView) |
|
|
|
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View") |
|
|
|
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View") |
|
|
|
} |
|
|
|
} |
|
|
|
} else if self.stackView.arrangedSubviews.contains(self.upcomingEventView!), self.upcomingEventView?.isHidden == false { |
|
|
|
|
|
|
|
self.upcomingEventView?.isHidden = true |
|
|
|
|
|
|
|
UserDefaults.standard.set("NO", forKey: CLShowUpcomingEventView) |
|
|
|
|
|
|
|
Logger.log(object: ["Removed": "YES"], for: "Removed Upcoming Event View") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -818,8 +784,8 @@ class ParentPanelController: NSWindowController { |
|
|
|
|
|
|
|
|
|
|
|
func showUpcomingEventView() { |
|
|
|
func showUpcomingEventView() { |
|
|
|
OperationQueue.main.addOperation { |
|
|
|
OperationQueue.main.addOperation { |
|
|
|
if let upcomingView = self.upcomingEventView, upcomingView.isHidden { |
|
|
|
if let upcomingView = self.upcomingEventContainerView, upcomingView.isHidden { |
|
|
|
self.upcomingEventView?.isHidden = false |
|
|
|
self.upcomingEventContainerView?.isHidden = false |
|
|
|
UserDefaults.standard.set("YES", forKey: CLShowUpcomingEventView) |
|
|
|
UserDefaults.standard.set("YES", forKey: CLShowUpcomingEventView) |
|
|
|
Logger.log(object: ["Shown": "YES"], for: "Added Upcoming Event View") |
|
|
|
Logger.log(object: ["Shown": "YES"], for: "Added Upcoming Event View") |
|
|
|
self.themeChanged() |
|
|
|
self.themeChanged() |
|
|
@ -844,32 +810,6 @@ class ParentPanelController: NSWindowController { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
guard let upcomingEvent = eventCenter.nextOccuring(events) else { |
|
|
|
|
|
|
|
self.setPlaceholdersForUpcomingCalendarView() |
|
|
|
|
|
|
|
if #available(OSX 10.14, *) { |
|
|
|
|
|
|
|
PerfLogger.endMarker("Fetch Calendar Events") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.calendarColorView.layer?.backgroundColor = upcomingEvent.event.calendar.color.cgColor |
|
|
|
|
|
|
|
self.nextEventLabel.stringValue = upcomingEvent.event.title |
|
|
|
|
|
|
|
self.nextEventLabel.toolTip = upcomingEvent.event.title |
|
|
|
|
|
|
|
if upcomingEvent.isAllDay == true { |
|
|
|
|
|
|
|
let title = events.count == 1 ? "All-Day" : "All Day - Total \(events.count) events today" |
|
|
|
|
|
|
|
self.setCalendarButtonTitle(buttonTitle: title) |
|
|
|
|
|
|
|
if #available(OSX 10.14, *) { |
|
|
|
|
|
|
|
PerfLogger.endMarker("Fetch Calendar Events") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setCalendarButtonTitle(buttonTitle: upcomingEvent.metadataForMeeting()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if upcomingEvent.meetingURL != nil { |
|
|
|
|
|
|
|
self.whiteRemoveButton.image = Themer.shared().videoCallImage() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if #available(OSX 10.14, *) { |
|
|
|
if #available(OSX 10.14, *) { |
|
|
|
PerfLogger.endMarker("Fetch Calendar Events") |
|
|
|
PerfLogger.endMarker("Fetch Calendar Events") |
|
|
|
} |
|
|
|
} |
|
|
@ -880,41 +820,12 @@ class ParentPanelController: NSWindowController { |
|
|
|
upcomingEventCollectionView.reloadData() |
|
|
|
upcomingEventCollectionView.reloadData() |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setPlaceholdersForUpcomingCalendarView() |
|
|
|
|
|
|
|
if #available(OSX 10.14, *) { |
|
|
|
if #available(OSX 10.14, *) { |
|
|
|
PerfLogger.endMarker("Fetch Calendar Events") |
|
|
|
PerfLogger.endMarker("Fetch Calendar Events") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func setPlaceholdersForUpcomingCalendarView() { |
|
|
|
|
|
|
|
let eventCenter = EventCenter.sharedCenter() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tomorrow = DateComponents() |
|
|
|
|
|
|
|
tomorrow.day = 1 |
|
|
|
|
|
|
|
guard let tomorrowDate = Calendar.autoupdatingCurrent.date(byAdding: tomorrow, to: Date()) else { |
|
|
|
|
|
|
|
setCalendarButtonTitle(buttonTitle: "You have no events scheduled for tomorrow.") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nextEventLabel.stringValue = NSLocalizedString("No upcoming event.", |
|
|
|
|
|
|
|
comment: "Title when there's no upcoming event") |
|
|
|
|
|
|
|
calendarColorView.layer?.backgroundColor = NSColor(red: 97 / 255.0, green: 194 / 255.0, blue: 80 / 255.0, alpha: 1.0).cgColor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let events = eventCenter.filteredEvents[NSCalendar.autoupdatingCurrent.startOfDay(for: tomorrowDate)] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let count = events?.count, count > 1 { |
|
|
|
|
|
|
|
let suffix = "events coming up tomorrow." |
|
|
|
|
|
|
|
setCalendarButtonTitle(buttonTitle: "\(count) \(suffix)") |
|
|
|
|
|
|
|
} else if let first = events?.first?.event.title { |
|
|
|
|
|
|
|
setCalendarButtonTitle(buttonTitle: "\(first) coming up.") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setCalendarButtonTitle(buttonTitle: NSLocalizedString("You have no events scheduled for tomorrow.", |
|
|
|
|
|
|
|
comment: "Title when there's no event scheduled for tomorrow")) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If the popover is displayed, close it |
|
|
|
// If the popover is displayed, close it |
|
|
|
// Called when preferences are going to be displayed! |
|
|
|
// Called when preferences are going to be displayed! |
|
|
|
func updatePopoverDisplayState() { |
|
|
|
func updatePopoverDisplayState() { |
|
|
|