Browse Source

More changes for customized time formats..

pull/92/head
Abhishek 4 years ago
parent
commit
e94194a672
  1. 8
      Clocker/Menu Bar/StatusContainerView.swift
  2. 2
      Clocker/Onboarding/OnboardingSearchController.swift
  3. 3
      Clocker/Overall App/AppDefaults.swift
  4. 3
      Clocker/Overall App/DataStore.swift
  5. 1
      Clocker/Overall App/Strings.swift
  6. 10
      Clocker/Panel/Data Layer/TimezoneData.swift
  7. 2
      Clocker/Panel/Notes Popover/NotesPopover.xib
  8. 2
      Clocker/Panel/PanelController.swift
  9. 20
      Clocker/Preferences/Appearance/AppearanceViewController.swift

8
Clocker/Menu Bar/StatusContainerView.swift

@ -13,10 +13,6 @@ func bufferCalculatedWidth() -> Int {
totalWidth += 20
}
if DataStore.shared().shouldDisplay(.seconds) {
totalWidth += 15
}
if DataStore.shared().shouldShowDateInMenubar() {
totalWidth += 20
}
@ -85,7 +81,9 @@ class StatusContainerView: NSView {
let operationObject = TimezoneDataOperations(with: timezoneObject)
let calculatedSubtitleSize = compactModeTimeFont.size(operationObject.compactMenuSubtitle(), precalculatedWidth, attributes: timeBasedAttributes)
let calculatedTitleSize = compactModeTimeFont.size(operationObject.compactMenuTitle(), precalculatedWidth, attributes: timeBasedAttributes)
return result + max(calculatedTitleSize.width, calculatedSubtitleSize.width) + bufferWidth
let showSeconds = timezoneObject.shouldShowSeconds()
let secondsBuffer: CGFloat = showSeconds ? 7 : 0
return result + max(calculatedTitleSize.width, calculatedSubtitleSize.width) + bufferWidth + secondsBuffer
}
return result + CGFloat(bufferCalculatedWidth())

2
Clocker/Onboarding/OnboardingSearchController.swift

@ -18,7 +18,7 @@ class OnboardingSearchController: NSViewController {
guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"),
let dictionary = NSDictionary(contentsOfFile: path),
let apiKey = dictionary["GeocodingKey"] as? String else {
assertionFailure("Unable to find the API key")
// assertionFailure("Unable to find the API key")
return ""
}
return apiKey

3
Clocker/Overall App/AppDefaults.swift

@ -99,14 +99,13 @@ class AppDefaults {
private class func defaultsDictionary() -> [String: Any] {
return [CLThemeKey: 0,
CLDisplayFutureSliderKey: 0,
CL24hourFormatSelectedKey: 1,
CL24hourFormatSelectedKey: 0, // 12-hour format
CLRelativeDateKey: 0,
CLShowDayInMenu: 0,
CLShowDateInMenu: 1,
CLShowPlaceInMenu: 0,
CLStartAtLogin: 0,
CLSunriseSunsetTime: 1,
CLShowSecondsInMenubar: 1,
CLUserFontSizePreference: 4,
CLShowUpcomingEventView: "YES",
CLShowAppInForeground: 0,

3
Clocker/Overall App/DataStore.swift

@ -7,7 +7,6 @@ enum ViewType {
case upcomingEventView
case twelveHour
case sunrise
case seconds
case showMeetingInMenubar
case showAllDayEventsInMenubar
case showAppInForeground
@ -126,8 +125,6 @@ class DataStore: NSObject {
return shouldDisplayHelper(CLShowAllDayEventsInUpcomingView)
case .sunrise:
return shouldDisplayHelper(CLSunriseSunsetTime)
case .seconds:
return shouldDisplayHelper(CLShowSecondsInMenubar)
case .showMeetingInMenubar:
return shouldDisplayHelper(CLShowMeetingInMenubar)
case .showAppInForeground:

1
Clocker/Overall App/Strings.swift

@ -19,7 +19,6 @@ let CLDisplayFutureSliderKey = "displayFutureSlider"
let CLStartAtLogin = "startAtLogin"
let CLShowAppInForeground = "displayAppAsForegroundApp"
let CLSunriseSunsetTime = "showSunriseSetTime"
let CLShowSecondsInMenubar = "showSeconds"
let CLUserFontSizePreference = "userFontSize"
let CLShowUpcomingEventView = "ShowUpcomingEventView"
let CLShowAllDayEventsInUpcomingView = "showAllDayEventsInUpcomingView"

10
Clocker/Panel/Data Layer/TimezoneData.swift

@ -40,11 +40,17 @@ class TimezoneData: NSObject, NSCoding {
static let values = [
NSNumber(integerLiteral: 0): DateFormat.twelveHour,
NSNumber(integerLiteral: 1): DateFormat.twelveHourWithSeconds,
NSNumber(integerLiteral: 2): DateFormat.twentyFourHour,
NSNumber(integerLiteral: 1): DateFormat.twentyFourHour,
// Seconds
NSNumber(integerLiteral: 2): DateFormat.twelveHourWithSeconds,
NSNumber(integerLiteral: 3): DateFormat.twentyFourHourWithSeconds,
// Preceding Zero
NSNumber(integerLiteral: 4): DateFormat.twelveHourWithZero,
NSNumber(integerLiteral: 5): DateFormat.twelveHourWithZeroSeconds,
// Suffix
NSNumber(integerLiteral: 6): DateFormat.twelveHourWithoutSuffix,
NSNumber(integerLiteral: 7): DateFormat.twelveHourWithoutSuffixAndSeconds,
]

2
Clocker/Panel/Notes Popover/NotesPopover.xib

@ -304,7 +304,7 @@
<constraint firstAttribute="width" constant="50" id="n5J-f7-aqy"/>
<constraint firstAttribute="height" constant="25" id="oQ5-uv-Gfg"/>
</constraints>
<buttonCell key="cell" type="push" title="Done" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="xa4-rw-FBZ">
<buttonCell key="cell" type="push" title="Save" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="xa4-rw-FBZ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="12" name="Avenir-Light"/>
</buttonCell>

2
Clocker/Panel/PanelController.swift

@ -171,7 +171,6 @@ class PanelController: ParentPanelController {
let displayFutureSliderKey = DataStore.shared().retrieve(key: CLThemeKey) as? NSNumber,
let showAppInForeground = DataStore.shared().retrieve(key: CLShowAppInForeground) as? NSNumber,
let relativeDateKey = DataStore.shared().retrieve(key: CLRelativeDateKey) as? NSNumber,
let showSecondsInMenubar = DataStore.shared().retrieve(key: CLShowSecondsInMenubar) as? NSNumber,
let fontSize = DataStore.shared().retrieve(key: CLUserFontSizePreference) as? NSNumber,
let sunriseTime = DataStore.shared().retrieve(key: CLSunriseSunsetTime) as? NSNumber,
let showDayInMenu = DataStore.shared().retrieve(key: CLShowDayInMenu) as? NSNumber,
@ -195,7 +194,6 @@ class PanelController: ParentPanelController {
"Display Future Slider": displayFutureSliderKey.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No",
"Clocker mode": showAppInForeground.isEqual(to: NSNumber(value: 0)) ? "Menubar" : "Floating",
"Relative Date": relativeDate,
"Show Seconds in Menubar": showSecondsInMenubar.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No",
"Font Size": fontSize,
"Sunrise Sunset": sunriseTime.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No",
"Show Day in Menu": showDayInMenu.isEqual(to: NSNumber(value: 0)) ? "Yes" : "No",

20
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -181,8 +181,14 @@ class AppearanceViewController: ParentViewController {
refresh(panel: true, floating: true)
updateStatusItem()
if let selectedFormat = sender.selectedItem?.title,
selectedFormat.contains("ss") {
print("Seconds are contained")
guard let panelController = PanelController.panel() else { return }
panelController.pauseTimer()
}
updateStatusItem()
previewPanelTableView.reloadData()
}
@ -257,18 +263,6 @@ class AppearanceViewController: ParentViewController {
previewPanelTableView.reloadData()
}
@IBAction func displayTimeWithSeconds(_ sender: NSSegmentedControl) {
Logger.log(object: ["Displayed": sender.selectedSegment == 0 ? "YES" : "NO"], for: "Display Time With Seconds")
if DataStore.shared().shouldDisplay(.seconds) {
guard let panelController = PanelController.panel() else { return }
panelController.pauseTimer()
}
updateStatusItem()
previewPanelTableView.reloadData()
}
@IBAction func changeAppDisplayOptions(_ sender: NSSegmentedControl) {
if sender.selectedSegment == 0 {
Logger.log(object: ["Selection": "Menubar"], for: "Dock Mode")

Loading…
Cancel
Save