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 {
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()
}

5
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<IndexPath> = 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)

4
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()
}

Loading…
Cancel
Save