From 908e24214341f39868028ff675bb51d7675359b8 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 3 Dec 2020 23:26:06 -0600 Subject: [PATCH] minor changes. --- Clocker/Panel/Data Layer/TimezoneData.swift | 19 +++++++++++-------- .../Panel/Notes Popover/NotesPopover.swift | 19 ++++++++++++++----- Clocker/Panel/Notes Popover/NotesPopover.xib | 6 +++--- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Clocker/Panel/Data Layer/TimezoneData.swift b/Clocker/Panel/Data Layer/TimezoneData.swift index c259185..0dce65a 100644 --- a/Clocker/Panel/Data Layer/TimezoneData.swift +++ b/Clocker/Panel/Data Layer/TimezoneData.swift @@ -28,14 +28,14 @@ class TimezoneData: NSObject, NSCoding { enum TimezoneOverride: Int { case globalFormat = 0 - case twelveHourFormat - case twentyFourFormat - case twelveHourWithSeconds - case twentyHourWithSeconds - case twelveHourPrecedingZero - case twelveHourPrecedingZeroSeconds - case twelveHourWithoutSuffix - case twelveHourWithoutSuffixAndSeconds + case twelveHourFormat = 1 + case twentyFourFormat = 2 + case twelveHourWithSeconds = 4 + case twentyHourWithSeconds = 5 + case twelveHourPrecedingZero = 7 + case twelveHourPrecedingZeroSeconds = 8 + case twelveHourWithoutSuffix = 10 + case twelveHourWithoutSuffixAndSeconds = 11 } static let values = [ @@ -335,6 +335,7 @@ class TimezoneData: NSObject, NSCoding { } else if shouldOverride == 4 { overrideFormat = .twelveHourWithSeconds } else if shouldOverride == 5 { + print("Setting override format to five") overrideFormat = .twentyHourWithSeconds } else if shouldOverride == 7 { overrideFormat = .twelveHourPrecedingZero @@ -344,6 +345,8 @@ class TimezoneData: NSObject, NSCoding { overrideFormat = .twelveHourWithoutSuffix } else if shouldOverride == 11 { overrideFormat = .twelveHourWithoutSuffixAndSeconds + } else { + assertionFailure("Chosen a wrong timezone format") } } diff --git a/Clocker/Panel/Notes Popover/NotesPopover.swift b/Clocker/Panel/Notes Popover/NotesPopover.swift index ce10a05..df9fb7b 100644 --- a/Clocker/Panel/Notes Popover/NotesPopover.swift +++ b/Clocker/Panel/Notes Popover/NotesPopover.swift @@ -38,6 +38,18 @@ class NotesPopover: NSViewController { @IBOutlet var notesTextView: TextViewWithPlaceholder! + private func convertOverrideFormatToPopupControlSelection() -> Int { + var chosenFormat: Int = dataObject?.overrideFormat.rawValue ?? 0 + if chosenFormat == 3 { + chosenFormat = 4 + } else if chosenFormat == 6 { + chosenFormat = 7 + } else if chosenFormat == 9 { + chosenFormat = 10 + } + return chosenFormat + } + override func viewDidLoad() { super.viewDidLoad() @@ -67,7 +79,6 @@ class NotesPopover: NSViewController { alertPopupButton.selectItem(at: 1) // Set up time control - let chosenFormat: Int = dataObject?.overrideFormat.rawValue ?? 0 let supportedTimeFormats = ["Respect Global Preference", "h:mm a (7:08 PM)", "HH:mm (19:08)", @@ -87,7 +98,7 @@ class NotesPopover: NSViewController { timeFormatControl.item(at: 6)?.isEnabled = false timeFormatControl.item(at: 9)?.isEnabled = false timeFormatControl.autoenablesItems = false - timeFormatControl.selectItem(at: chosenFormat) + timeFormatControl.selectItem(at: convertOverrideFormatToPopupControlSelection()) // Set Accessibility Identifiers for UI tests customLabel.setAccessibilityIdentifier("CustomLabel") @@ -474,9 +485,7 @@ extension NotesPopover { } private func updateTimeFormat() { - if let overrideFormat = dataObject?.overrideFormat.rawValue { - timeFormatControl.selectItem(at: overrideFormat) - } + timeFormatControl.selectItem(at: convertOverrideFormatToPopupControlSelection()) } private func enableReminderView(_ shouldEnable: Bool) { diff --git a/Clocker/Panel/Notes Popover/NotesPopover.xib b/Clocker/Panel/Notes Popover/NotesPopover.xib index 0e727c3..85d59ab 100644 --- a/Clocker/Panel/Notes Popover/NotesPopover.xib +++ b/Clocker/Panel/Notes Popover/NotesPopover.xib @@ -186,10 +186,10 @@ - + - + @@ -213,7 +213,7 @@ - +