Browse Source

Few changes

- More compact display for timezone difference in panel / floating view (+7h instead of 7h ahead)
- Hide notes label when not visible
master
Abhishek Banthia 9 months ago
parent
commit
6e9115db08
  1. 8
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  2. 5
      Clocker/Panel/PanelController.swift
  3. 4
      Clocker/Panel/UI/TimezoneDataSource.swift

8
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -300,7 +300,7 @@ extension TimezoneDataOperations {
if (local as NSDate).earlierDate(timezoneDate) == local { if (local as NSDate).earlierDate(timezoneDate) == local {
var replaceAgo = CLEmptyString var replaceAgo = CLEmptyString
replaceAgo.append(", ") replaceAgo.append(", +")
let agoString = timezoneDate.timeAgo(since: local, numericDates: true) let agoString = timezoneDate.timeAgo(since: local, numericDates: true)
replaceAgo.append(agoString.replacingOccurrences(of: "ago", with: CLEmptyString)) 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) 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() return replaceAgo.lowercased()
} }
var replaceAgo = CLEmptyString var replaceAgo = CLEmptyString
replaceAgo.append(", ") replaceAgo.append(", -")
let replaced = timeDifference.replacingOccurrences(of: "ago", with: CLEmptyString) let replaced = timeDifference.replacingOccurrences(of: "ago", with: CLEmptyString)
replaceAgo.append(replaced) replaceAgo.append(replaced)
@ -335,7 +335,7 @@ extension TimezoneDataOperations {
let minuteDifference = calculateTimeDifference(with: local as NSDate, timezoneDate: timezoneDate as NSDate) 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() return replaceAgo.lowercased()
} }

5
Clocker/Panel/PanelController.swift

@ -95,8 +95,6 @@ class PanelController: ParentPanelController {
sliderDatePicker.dateValue = Date() sliderDatePicker.dateValue = Date()
closestQuarterTimeRepresentation = findClosestQuarterTimeApproximation() closestQuarterTimeRepresentation = findClosestQuarterTimeApproximation()
modernSliderLabel.stringValue = "Time Scroller" modernSliderLabel.stringValue = "Time Scroller"
goForwardButton.alphaValue = 0
goBackwardsButton.alphaValue = 0
resetModernSliderButton.isHidden = true resetModernSliderButton.isHidden = true
if modernSlider != nil { if modernSlider != nil {
@ -104,6 +102,9 @@ class PanelController: ParentPanelController {
modernSlider.scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally) modernSlider.scrollToItems(at: indexPaths, scrollPosition: .centeredHorizontally)
} }
goForwardButton.alphaValue = 0
goBackwardsButton.alphaValue = 0
setTimezoneDatasourceSlider(sliderValue: 0) setTimezoneDatasourceSlider(sliderValue: 0)
reviewView.isHidden = !ReviewController.canPrompt() reviewView.isHidden = !ReviewController.canPrompt()

4
Clocker/Panel/UI/TimezoneDataSource.swift

@ -71,10 +71,13 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
cellView.relativeDate.setAccessibilityIdentifier("RelativeDate") cellView.relativeDate.setAccessibilityIdentifier("RelativeDate")
if let note = currentModel.note, !note.isEmpty { if let note = currentModel.note, !note.isEmpty {
cellView.noteLabel.stringValue = note cellView.noteLabel.stringValue = note
cellView.noteLabel.isHidden = false
} else if let value = operation.nextDaylightSavingsTransitionIfAvailable(with: sliderValue) { } else if let value = operation.nextDaylightSavingsTransitionIfAvailable(with: sliderValue) {
cellView.noteLabel.stringValue = value cellView.noteLabel.stringValue = value
cellView.noteLabel.isHidden = false
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = CLEmptyString
cellView.noteLabel.isHidden = true
} }
cellView.layout(with: currentModel) cellView.layout(with: currentModel)
cellView.setAccessibilityIdentifier(currentModel.formattedTimezoneLabel()) cellView.setAccessibilityIdentifier(currentModel.formattedTimezoneLabel())
@ -241,6 +244,7 @@ extension TimezoneCellView {
sunriseImage.isHidden = true sunriseImage.isHidden = true
} }
setupLayout() setupLayout()
} }
} }

Loading…
Cancel
Save