diff --git a/Clocker/ClockerUITests/PermissionsTests.swift b/Clocker/ClockerUITests/PermissionsTests.swift index f348055..3ccc58d 100644 --- a/Clocker/ClockerUITests/PermissionsTests.swift +++ b/Clocker/ClockerUITests/PermissionsTests.swift @@ -15,7 +15,7 @@ class PermissionsTests: XCTestCase { func testAcceptingCalendarPermissions() { app.tapMenubarIcon() - app/*@START_MENU_TOKEN@*/.buttons["Preferences"]/*[[".dialogs[\"Clocker Panel\"].buttons[\"Preferences\"]",".buttons[\"Preferences\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.click() + app/*@START_MENU_TOKEN@*/ .buttons["Preferences"]/*[[".dialogs[\"Clocker Panel\"].buttons[\"Preferences\"]",".buttons[\"Preferences\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .click() let clockerWindow = app.windows["Clocker"] @@ -53,7 +53,7 @@ class PermissionsTests: XCTestCase { func testAcceptingRemindersPermissions() { app.tapMenubarIcon() - app/*@START_MENU_TOKEN@*/.buttons["Preferences"]/*[[".dialogs[\"Clocker Panel\"].buttons[\"Preferences\"]",".buttons[\"Preferences\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.click() + app/*@START_MENU_TOKEN@*/ .buttons["Preferences"]/*[[".dialogs[\"Clocker Panel\"].buttons[\"Preferences\"]",".buttons[\"Preferences\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/ .click() let clockerWindow = app.windows["Clocker"] diff --git a/Clocker/Events and Reminders/CalendarHandler.swift b/Clocker/Events and Reminders/CalendarHandler.swift index 7cbd564..14a301f 100644 --- a/Clocker/Events and Reminders/CalendarHandler.swift +++ b/Clocker/Events and Reminders/CalendarHandler.swift @@ -494,11 +494,8 @@ struct EventInfo { return "in \(withoutAgo.lowercased())" } else if event.startDate.isTomorrow { - let timeSince = event.startDate.shortTimeAgoSinceNow - let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString) - let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString) - - return "in \(withoutAgo.lowercased())" + let hoursUntil = event.startDate.hoursUntil + return "in \(hoursUntil)h" } return "Error" diff --git a/Clocker/Overall App/Themer.swift b/Clocker/Overall App/Themer.swift index d8e51ec..42f7027 100644 --- a/Clocker/Overall App/Themer.swift +++ b/Clocker/Overall App/Themer.swift @@ -210,8 +210,8 @@ extension Themer { return themeIndex == .light - ? NSImage(named: NSImage.Name("Settings"))! - : NSImage(named: NSImage.Name("Settings-White"))! + ? NSImage(named: NSImage.Name("Settings"))! + : NSImage(named: NSImage.Name("Settings-White"))! } func pinImage() -> NSImage { diff --git a/Clocker/Panel/ParentPanelController.swift b/Clocker/Panel/ParentPanelController.swift index 5d33de9..b01cfc7 100644 --- a/Clocker/Panel/ParentPanelController.swift +++ b/Clocker/Panel/ParentPanelController.swift @@ -310,7 +310,7 @@ class ParentPanelController: NSWindowController { if eventCenter.calendarAccessGranted() { // Nice. Events will be retrieved when we open the panel } else if eventCenter.calendarAccessNotDetermined() { - upcomingEventCollectionView.reloadData() + upcomingEventCollectionView.reloadData() } else { removeUpcomingEventView() } @@ -344,7 +344,7 @@ class ParentPanelController: NSWindowController { let sharedThemer = Themer.shared() if upcomingEventContainerView?.isHidden == false { - upcomingEventContainerView?.layer?.backgroundColor = NSColor.clear.cgColor + upcomingEventContainerView?.layer?.backgroundColor = NSColor.clear.cgColor } shutdownButton.image = sharedThemer.shutdownImage() diff --git a/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift b/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift index 9a0402e..8fb8a80 100644 --- a/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift +++ b/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift @@ -9,6 +9,7 @@ class UpcomingEventViewItem: NSCollectionViewItem { @IBOutlet var leadingConstraint: NSLayoutConstraint! @IBOutlet var eventTitleLabel: NSTextField! @IBOutlet var eventSubtitleButton: NSButton! + @IBOutlet var supplementaryButtonWidthConstraint: NSLayoutConstraint! @IBOutlet var zoomButton: NSButton! private var meetingLink: URL? @@ -34,8 +35,13 @@ class UpcomingEventViewItem: NSCollectionViewItem { panelDelegate = delegate if meetingURL != nil { + zoomButton.isHidden = false meetingLink = meetingURL zoomButton.image = Themer.shared().videoCallImage() + supplementaryButtonWidthConstraint.constant = 24.0 + } else { + zoomButton.image = nil + supplementaryButtonWidthConstraint.constant = 0.0 } } @@ -66,7 +72,7 @@ class UpcomingEventViewItem: NSCollectionViewItem { let style = NSMutableParagraphStyle() style.alignment = .left style.lineBreakMode = .byTruncatingTail - + if let boldFont = NSFont(name: "Avenir", size: 11) { let attributes = [NSAttributedString.Key.foregroundColor: NSColor.gray, NSAttributedString.Key.paragraphStyle: style, NSAttributedString.Key.font: boldFont] diff --git a/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.xib b/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.xib index 5a86147..003c22c 100644 --- a/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.xib +++ b/Clocker/Panel/Upcoming Events/UpcomingEventViewItem.xib @@ -87,6 +87,7 @@ + diff --git a/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift b/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift index 127baea..ceb80cb 100644 --- a/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift +++ b/Clocker/Panel/Upcoming Events/UpcomingEventsDataSource.swift @@ -6,6 +6,7 @@ class UpcomingEventsDataSource: NSObject, NSCollectionViewDataSource, NSCollecti private var upcomingEvents: [EventInfo] = [] private var eventCenter: EventCenter! private weak var delegate: UpcomingEventPanelDelegate? + private static let panelWidth: CGFloat = 350.0 init(_ panelDelegate: UpcomingEventPanelDelegate?, _ center: EventCenter) { super.init() @@ -45,14 +46,15 @@ class UpcomingEventsDataSource: NSObject, NSCollectionViewDataSource, NSCollecti func collectionView(_ collectionView: NSCollectionView, layout _: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize { if eventCenter.calendarAccessNotDetermined() { - return NSSize(width: collectionView.frame.width - 40, height: collectionView.frame.height - 15) + return NSSize(width: UpcomingEventsDataSource.panelWidth - 25, height: collectionView.frame.height - 15) } else if upcomingEvents.isEmpty { - return NSSize(width: collectionView.frame.width - 25, height: collectionView.frame.height - 15) + return NSSize(width: UpcomingEventsDataSource.panelWidth - 25, height: collectionView.frame.height - 15) } else { - let currentEventInfo = upcomingEvents[indexPath.item] - let attributedString = NSAttributedString(string: currentEventInfo.event.title, attributes: [NSAttributedString.Key.font : avenirBookFont]) - let maxWidth = max(attributedString.size().width + 60.0, collectionView.frame.width / 2) - return NSSize(width: maxWidth, height: collectionView.frame.height - 15) + let currentEventInfo = upcomingEvents[indexPath.item] + let bufferWidth: CGFloat = currentEventInfo.meetingURL != nil ? 60.0 : 20.0 + let attributedString = NSAttributedString(string: currentEventInfo.event.title, attributes: [NSAttributedString.Key.font: avenirBookFont]) + let maxWidth = min(attributedString.size().width + bufferWidth, UpcomingEventsDataSource.panelWidth / 2) + return NSSize(width: maxWidth, height: collectionView.frame.height - 20) } } }