Browse Source

Only create TimezoneDataOperations if DST transition option is enabled.

pull/92/head
Abhishek 4 years ago
parent
commit
187101e709
  1. 4
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  2. 11
      Clocker/Panel/ParentPanelController.swift
  3. 5
      Clocker/Panel/UI/TimezoneDataSource.swift

4
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -34,10 +34,6 @@ extension TimezoneDataOperations {
} }
func nextDaylightSavingsTransitionIfAvailable(with sliderValue: Int) -> String? { func nextDaylightSavingsTransitionIfAvailable(with sliderValue: Int) -> String? {
if DataStore.shared().shouldDisplay(.dstTransitionInfo) == false {
return nil
}
let currentTimezone = TimeZone(identifier: dataObject.timezone()) let currentTimezone = TimeZone(identifier: dataObject.timezone())
guard let nextDaylightSavingsTransition = currentTimezone?.nextDaylightSavingTimeTransition else { guard let nextDaylightSavingsTransition = currentTimezone?.nextDaylightSavingTimeTransition else {
return nil return nil

11
Clocker/Panel/ParentPanelController.swift

@ -169,7 +169,7 @@ class ParentPanelController: NSWindowController {
object: nil) object: nil)
if #available(OSX 11.0, *) { if #available(OSX 11.0, *) {
mainTableView.style = .fullWidth // mainTableView.style = .fullWidth
} }
if modernSlider != nil { if modernSlider != nil {
@ -384,7 +384,9 @@ class ParentPanelController: NSWindowController {
newHeight = userFontSize == 4 ? 68.0 : 68.0 newHeight = userFontSize == 4 ? 68.0 : 68.0
if let note = object?.note, note.isEmpty == false { if let note = object?.note, note.isEmpty == false {
newHeight += 20 newHeight += 20
} else if let obj = object, TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil { } else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil {
newHeight += 20 newHeight += 20
} }
} }
@ -393,7 +395,7 @@ class ParentPanelController: NSWindowController {
// Set it to 90 expicity in case the row height is calculated be higher. // Set it to 90 expicity in case the row height is calculated be higher.
newHeight = 88.0 newHeight = 88.0
if let note = object?.note, note.isEmpty, let obj = object, TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) == nil { if let note = object?.note, note.isEmpty, DataStore.shared().shouldDisplay(.dstTransitionInfo) == false, let obj = object, TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) == nil {
newHeight -= 20.0 newHeight -= 20.0
} }
} }
@ -565,7 +567,8 @@ class ParentPanelController: NSWindowController {
cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage() cellView.sunriseImage.image = model.isSunriseOrSunset ? Themer.shared().sunriseImage() : Themer.shared().sunsetImage()
if let note = model.note, !note.isEmpty { if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note cellView.noteLabel.stringValue = note
} else if let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) { } else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
cellView.noteLabel.stringValue = value cellView.noteLabel.stringValue = value
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = CLEmptyString

5
Clocker/Panel/UI/TimezoneDataSource.swift

@ -64,7 +64,7 @@ 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
} else if let value = operation.nextDaylightSavingsTransitionIfAvailable(with: sliderValue) { } else if DataStore.shared().shouldDisplay(.dstTransitionInfo), let value = operation.nextDaylightSavingsTransitionIfAvailable(with: sliderValue) {
cellView.noteLabel.stringValue = value cellView.noteLabel.stringValue = value
} else { } else {
cellView.noteLabel.stringValue = CLEmptyString cellView.noteLabel.stringValue = CLEmptyString
@ -84,7 +84,6 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, timezones.count > row, let relativeDisplay = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber { if let userFontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber, timezones.count > row, let relativeDisplay = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber {
let model = timezones[row] let model = timezones[row]
let operation = TimezoneDataOperations(with: model)
let shouldShowSunrise = DataStore.shared().shouldDisplay(.sunrise) let shouldShowSunrise = DataStore.shared().shouldDisplay(.sunrise)
var rowHeight: Int = userFontSize == 4 ? 60 : 65 var rowHeight: Int = userFontSize == 4 ? 60 : 65
@ -99,7 +98,7 @@ extension TimezoneDataSource: NSTableViewDataSource, NSTableViewDelegate {
if let note = model.note, !note.isEmpty { if let note = model.note, !note.isEmpty {
rowHeight += userFontSize.intValue + 15 rowHeight += userFontSize.intValue + 15
} else if operation.nextDaylightSavingsTransitionIfAvailable(with: sliderValue) != nil { } else if DataStore.shared().shouldDisplay(.dstTransitionInfo), TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: sliderValue) != nil {
rowHeight += userFontSize.intValue + 15 rowHeight += userFontSize.intValue + 15
} }

Loading…
Cancel
Save