From 6e9115db087c106f26544ed42db6f59412a2c9fb Mon Sep 17 00:00:00 2001 From: Abhishek Banthia <8280282+n0shake@users.noreply.github.com> Date: Sun, 31 Mar 2024 14:24:41 -0400 Subject: [PATCH] Few changes - More compact display for timezone difference in panel / floating view (+7h instead of 7h ahead) - Hide notes label when not visible --- Clocker/Panel/Data Layer/TimezoneDataOperations.swift | 8 ++++---- Clocker/Panel/PanelController.swift | 5 +++-- Clocker/Panel/UI/TimezoneDataSource.swift | 4 ++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Clocker/Panel/Data Layer/TimezoneDataOperations.swift b/Clocker/Panel/Data Layer/TimezoneDataOperations.swift index 5039542..32fa726 100644 --- a/Clocker/Panel/Data Layer/TimezoneDataOperations.swift +++ b/Clocker/Panel/Data Layer/TimezoneDataOperations.swift @@ -300,7 +300,7 @@ extension TimezoneDataOperations { if (local as NSDate).earlierDate(timezoneDate) == local { var replaceAgo = CLEmptyString - replaceAgo.append(", ") + replaceAgo.append(", +") let agoString = timezoneDate.timeAgo(since: local, numericDates: true) replaceAgo.append(agoString.replacingOccurrences(of: "ago", with: CLEmptyString)) @@ -314,12 +314,12 @@ extension TimezoneDataOperations { } let minuteDifference = calculateTimeDifference(with: local as NSDate, timezoneDate: timezoneDate as NSDate) - minuteDifference == 0 ? replaceAgo.append("ahead") : replaceAgo.append("\(minuteDifference)m ahead") + minuteDifference == 0 ? replaceAgo.append("") : replaceAgo.append("\(minuteDifference)m") return replaceAgo.lowercased() } var replaceAgo = CLEmptyString - replaceAgo.append(", ") + replaceAgo.append(", -") let replaced = timeDifference.replacingOccurrences(of: "ago", with: CLEmptyString) replaceAgo.append(replaced) @@ -335,7 +335,7 @@ extension TimezoneDataOperations { let minuteDifference = calculateTimeDifference(with: local as NSDate, timezoneDate: timezoneDate as NSDate) - minuteDifference == 0 ? replaceAgo.append("behind") : replaceAgo.append("\(minuteDifference)m behind") + minuteDifference == 0 ? replaceAgo.append("") : replaceAgo.append("\(minuteDifference)m") return replaceAgo.lowercased() } diff --git a/Clocker/Panel/PanelController.swift b/Clocker/Panel/PanelController.swift index 1525785..cc87e97 100644 --- a/Clocker/Panel/PanelController.swift +++ b/Clocker/Panel/PanelController.swift @@ -95,14 +95,15 @@ class PanelController: ParentPanelController { sliderDatePicker.dateValue = Date() closestQuarterTimeRepresentation = findClosestQuarterTimeApproximation() modernSliderLabel.stringValue = "Time Scroller" - goForwardButton.alphaValue = 0 - goBackwardsButton.alphaValue = 0 resetModernSliderButton.isHidden = true if modernSlider != nil { let indexPaths: Set = Set([IndexPath(item: modernSlider.numberOfItems(inSection: 0) / 2, section: 0)]) modernSlider.scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally) } + + goForwardButton.alphaValue = 0 + goBackwardsButton.alphaValue = 0 setTimezoneDatasourceSlider(sliderValue: 0) diff --git a/Clocker/Panel/UI/TimezoneDataSource.swift b/Clocker/Panel/UI/TimezoneDataSource.swift index 602ae9e..8c183fe 100644 --- a/Clocker/Panel/UI/TimezoneDataSource.swift +++ b/Clocker/Panel/UI/TimezoneDataSource.swift @@ -71,10 +71,13 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate { cellView.relativeDate.setAccessibilityIdentifier("RelativeDate") if let note = currentModel.note, !note.isEmpty { cellView.noteLabel.stringValue = note + cellView.noteLabel.isHidden = false } else if let value = operation.nextDaylightSavingsTransitionIfAvailable(with: sliderValue) { cellView.noteLabel.stringValue = value + cellView.noteLabel.isHidden = false } else { cellView.noteLabel.stringValue = CLEmptyString + cellView.noteLabel.isHidden = true } cellView.layout(with: currentModel) cellView.setAccessibilityIdentifier(currentModel.formattedTimezoneLabel()) @@ -240,6 +243,7 @@ extension TimezoneCellView { if model.selectionType == .timezone, model.latitude == nil, model.longitude == nil { sunriseImage.isHidden = true } + setupLayout() }