Browse Source

Formatting..

pull/113/head
Abhishek 3 years ago
parent
commit
d9d6b8beeb
  1. 2
      Clocker/AppDelegate.swift
  2. 4
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  3. 12
      Clocker/ClockerUnitTests/ThemerTests.swift
  4. 6
      Clocker/CoreModelKit/Sources/CoreModelKit/SearchResults.swift
  5. 6
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift
  6. 6
      Clocker/Dependencies/Date Additions/TimePeriodChain.swift
  7. 6
      Clocker/Events and Reminders/CalendarHandler.swift
  8. 3
      Clocker/Events and Reminders/RemindersHandler.swift
  9. 6
      Clocker/Menu Bar/StatusContainerView.swift
  10. 3
      Clocker/Menu Bar/StatusItemHandler.swift
  11. 3
      Clocker/Onboarding/OnboardingSearchController.swift
  12. 2
      Clocker/Overall App/DataStore.swift
  13. 18
      Clocker/Overall App/Themer.swift
  14. 2
      Clocker/Overall App/Timer.swift
  15. 2
      Clocker/Overall App/VersionUpdateHandler.swift
  16. 6
      Clocker/Panel/Notes Popover/NotesPopover.swift
  17. 3
      Clocker/Panel/PanelController.swift
  18. 21
      Clocker/Panel/ParentPanelController.swift
  19. 3
      Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift
  20. 5
      Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift
  21. 3
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  22. 6
      Clocker/Preferences/Calendar/CalendarViewController.swift
  23. 3
      Clocker/Preferences/General/PreferencesDataSource.swift
  24. 13
      Clocker/Preferences/General/PreferencesViewController.swift
  25. 6
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  26. 7
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  27. 1
      Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

2
Clocker/AppDelegate.swift

@ -16,7 +16,7 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
panelObserver?.invalidate()
}
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
if let path = keyPath, path == PreferencesConstants.hotKeyPathIdentifier {
let hotKeyCenter = PTHotKeyCenter.shared()

4
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -284,13 +284,13 @@ class ClockerUnitTests: XCTestCase {
UserDefaults.standard.set(NSNumber(value: 1), forKey: CLSelectedTimeZoneFormatKey) // Set to 24-Hour Format
// Test default behaviour
let timezoneWithSecondsKeys = [4,5,8,11]
let timezoneWithSecondsKeys = [4, 5, 8, 11]
for timezoneKey in timezoneWithSecondsKeys {
dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey)
XCTAssertTrue(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat()))
}
let timezoneWithoutSecondsKeys = [1,2,7,10]
let timezoneWithoutSecondsKeys = [1, 2, 7, 10]
for timezoneKey in timezoneWithoutSecondsKeys {
dataObject.setShouldOverrideGlobalTimeFormat(timezoneKey)
XCTAssertFalse(dataObject.shouldShowSeconds(DataStore.shared().timezoneFormat()))

12
Clocker/ClockerUnitTests/ThemerTests.swift

@ -5,7 +5,6 @@ import XCTest
@testable import Clocker
class ThemerTests: XCTestCase {
@available(macOS 10.14, *)
func testSettingTheme() {
// Set to some random number should set to 0
@ -29,7 +28,6 @@ class ThemerTests: XCTestCase {
let expectedTextColor = NSColor.black
let expectedTextBackgroundColor = NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle"
@ -55,7 +53,6 @@ class ThemerTests: XCTestCase {
let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
@ -97,7 +94,6 @@ class ThemerTests: XCTestCase {
let expectedTextColor = NSColor.white
let expectedTextBackgroundColor = NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle"
@ -123,7 +119,6 @@ class ThemerTests: XCTestCase {
let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
@ -166,7 +161,6 @@ class ThemerTests: XCTestCase {
let expectedTextColor = NSColor.textColor
let expectedTextBackgroundColor = currentSystemTheme == .dark ? NSColor(deviceRed: 42.0 / 255.0, green: 55.0 / 255.0, blue: 62.0 / 255.0, alpha: 1.0) : NSColor(deviceRed: 241.0 / 255.0, green: 241.0 / 255.0, blue: 241.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle"
@ -192,7 +186,6 @@ class ThemerTests: XCTestCase {
let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
@ -233,7 +226,6 @@ class ThemerTests: XCTestCase {
let expectedTextColor = NSColor.black
let expectedTextBackgroundColor = NSColor(deviceRed: 238.0 / 255.0, green: 232.0 / 255.0, blue: 213.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle"
@ -259,7 +251,6 @@ class ThemerTests: XCTestCase {
let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
@ -301,7 +292,6 @@ class ThemerTests: XCTestCase {
let expectedTextColor = NSColor.white
let expectedTextBackgroundColor = NSColor(deviceRed: 88.0 / 255.0, green: 110.0 / 255.0, blue: 117.0 / 255.0, alpha: 1.0)
let expectedShutdownImageName = "ellipsis.circle"
let expectedPreferenceImageName = "plus"
let expectedPinImageName = "macwindow.on.rectangle"
@ -327,7 +317,6 @@ class ThemerTests: XCTestCase {
let expectedForwardsImage = "goforward.15"
let expectedResetSliderImage = "xmark.circle.fill"
XCTAssertEqual(subject.sliderKnobColor(), expectedSliderKnobColor)
XCTAssertEqual(subject.sliderRightColor(), expectedSliderRightColor)
XCTAssertEqual(subject.mainBackgroundColor(), expectedBackgroundColor)
@ -358,5 +347,4 @@ class ThemerTests: XCTestCase {
XCTAssertEqual(subject.goForwardsImage()?.accessibilityDescription, expectedForwardsImage)
XCTAssertEqual(subject.resetModernSliderImage()?.accessibilityDescription, expectedResetSliderImage)
}
}

6
Clocker/CoreModelKit/Sources/CoreModelKit/SearchResults.swift

@ -2,7 +2,7 @@
import Cocoa
public struct ResultStatus {
public enum ResultStatus {
public static let okay = "OK"
public static let zeroResults = "ZERO_RESULTS"
public static let requestDenied = "REQUEST_DENIED"
@ -57,8 +57,8 @@ public struct SearchResult: Codable {
}
private enum CodingKeys: String, CodingKey {
case results = "results"
case status = "status"
case results
case status
case errorMessage = "error_message"
}
}

6
Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -85,7 +85,7 @@ public class TimezoneData: NSObject, NSCoding {
public var isSystemTimezone = false
public var overrideFormat: TimezoneOverride = .globalFormat
public override init() {
override public init() {
selectionType = .timezone
isFavourite = 0
note = ModelConstants.emptyString
@ -268,7 +268,7 @@ public class TimezoneData: NSObject, NSCoding {
return formatInString.contains("ss")
}
public override var hash: Int {
override public var hash: Int {
guard let placeIdentifier = placeID, let timezone = timezoneID else {
return -1
}
@ -276,7 +276,7 @@ public class TimezoneData: NSObject, NSCoding {
return placeIdentifier.hashValue ^ timezone.hashValue
}
public override func isEqual(_ object: Any?) -> Bool {
override public func isEqual(_ object: Any?) -> Bool {
guard let compared = object as? TimezoneData else {
return false
}

6
Clocker/Dependencies/Date Additions/TimePeriodChain.swift

@ -138,15 +138,15 @@ open class TimePeriodChain: TimePeriodGroup {
_end = _end?.addingTimeInterval(duration)
}
public override func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
override public func map<T>(_ transform: (TimePeriodProtocol) throws -> T) rethrows -> [T] {
return try periods.map(transform)
}
public override func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
override public func filter(_ isIncluded: (TimePeriodProtocol) throws -> Bool) rethrows -> [TimePeriodProtocol] {
return try periods.filter(isIncluded)
}
internal override func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result {
override internal func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, TimePeriodProtocol) throws -> Result) rethrows -> Result {
return try periods.reduce(initialResult, nextPartialResult)
}

6
Clocker/Events and Reminders/CalendarHandler.swift

@ -391,7 +391,8 @@ extension EventCenter {
// Check for Zoom links
if actualLink.contains("zoom.us/j/")
|| actualLink.contains("zoom.us/s/")
|| actualLink.contains("zoom.us/w/") {
|| actualLink.contains("zoom.us/w/")
{
// Create a Zoom App link
let workspace = NSWorkspace.shared
if workspace.urlForApplication(toOpen: URL(string: "zoommtg://")!) != nil {
@ -417,7 +418,8 @@ extension EventCenter {
|| actualLink.contains("public.senfcall.de")
|| actualLink.contains("youcanbook.me/zoom/")
|| actualLink.contains("workplace.com/groupcall")
|| actualLink.contains("bluejeans.com/") {
|| actualLink.contains("bluejeans.com/")
{
if let meetingLink = result.url {
return meetingLink
}

3
Clocker/Events and Reminders/RemindersHandler.swift

@ -51,7 +51,8 @@ extension EventCenter {
timezone: String,
alertIndex: Int,
reminderDate: Date,
additionalNotes: String?) -> Bool {
additionalNotes: String?) -> Bool
{
initializeStoreIfNeccesary()
if reminderAccessNotDetermined() || reminderAccessDenied() {

6
Clocker/Menu Bar/StatusContainerView.swift

@ -31,10 +31,12 @@ func compactWidth(for timezone: TimezoneData) -> Int {
if timeFormat == DateFormat.twelveHour
|| timeFormat == DateFormat.twelveHourWithSeconds
|| timeFormat == DateFormat.twelveHourWithZero
|| timeFormat == DateFormat.twelveHourWithSeconds {
|| timeFormat == DateFormat.twelveHourWithSeconds
{
totalWidth += 20
} else if timeFormat == DateFormat.twentyFourHour
|| timeFormat == DateFormat.twentyFourHourWithSeconds {
|| timeFormat == DateFormat.twentyFourHourWithSeconds
{
totalWidth += 0
}

3
Clocker/Menu Bar/StatusItemHandler.swift

@ -112,7 +112,8 @@ class StatusItemHandler: NSObject {
userNotificationsDidChangeNotif = center.addObserver(forName: UserDefaults.didChangeNotification,
object: self,
queue: mainQueue) { _ in
queue: mainQueue)
{ _ in
self.setupStatusItem()
}
}

3
Clocker/Onboarding/OnboardingSearchController.swift

@ -135,7 +135,8 @@ class OnboardingSearchController: NSViewController {
private func setupLabelHidingTimer() {
Timer.scheduledTimer(withTimeInterval: 5,
repeats: false) { _ in
repeats: false)
{ _ in
OperationQueue.main.addOperation {
self.setInfoLabel(CLEmptyString)
}

2
Clocker/Overall App/DataStore.swift

@ -165,7 +165,7 @@ class DataStore: NSObject {
}
}
//MARK: Private
// MARK: Private
private func shouldDisplayHelper(_ key: String) -> Bool {
guard let value = retrieve(key: key) as? NSNumber else {

18
Clocker/Overall App/Themer.swift

@ -15,6 +15,7 @@ class Themer: NSObject {
case solarizedLight
case solarizedDark
}
private static var sharedInstance = Themer(index: UserDefaults.standard.integer(forKey: CLThemeKey))
private var effectiveApperanceObserver: NSKeyValueObservation?
private var themeIndex: Theme {
@ -49,7 +50,7 @@ class Themer: NSObject {
object: nil)
if #available(macOS 10.14, *) {
effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { [weak self] (app, _) in
effectiveApperanceObserver = NSApp.observe(\.effectiveAppearance) { [weak self] _, _ in
if let sSelf = self {
sSelf.setAppAppearance()
NotificationCenter.default.post(name: .themeDidChangeNotification, object: nil)
@ -93,7 +94,8 @@ extension Themer {
}
}
//MARK: Color
// MARK: Color
func sliderKnobColor() -> NSColor {
switch themeIndex {
case .light:
@ -173,7 +175,8 @@ extension Themer {
return themeIndex == .light ? NSColor.black : NSColor.white
}
//MARK: Images
// MARK: Images
func shutdownImage() -> NSImage {
if let symbolImageForShutdown = symbolImage(for: "ellipsis.circle") {
return symbolImageForShutdown
@ -403,7 +406,7 @@ extension Themer {
return removeImage()
}
//MARK: Debug Description
// MARK: Debug Description
override var debugDescription: String {
if themeIndex == .system {
@ -416,7 +419,7 @@ extension Themer {
return debugDescription
}
//MARK: Private
// MARK: Private
private func symbolImage(for name: String) -> NSImage? {
assert(name.isEmpty == false)
@ -457,7 +460,8 @@ extension Themer {
_ darkImage: NSImage,
_ systemImage: NSImage,
_ solarizedLightImage: NSImage,
_ solarizedDarkImage: NSImage) -> NSImage {
_ solarizedDarkImage: NSImage) -> NSImage
{
if #available(macOS 10.14, *) {
switch themeIndex {
case .light:
@ -474,7 +478,5 @@ extension Themer {
}
return themeIndex == .light ? lightImage : darkImage
}
}

2
Clocker/Overall App/Timer.swift

@ -118,7 +118,7 @@ open class Repeater: Equatable {
}
/// Handler typealias
public typealias Observer = ((Repeater) -> Void)
public typealias Observer = (Repeater) -> Void
/// Token assigned to the observer
public typealias ObserverToken = UInt64

2
Clocker/Overall App/VersionUpdateHandler.swift

@ -172,7 +172,7 @@ class VersionUpdateHandler: NSObject {
lastVersionCopy = "0"
}
var newVersionFound = false
var details: String = ""
var details = ""
let versions = dict.keys.sorted()

6
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -322,7 +322,8 @@ class NotesPopover: NSViewController {
}
private func updateTimezoneInDefaultPreferences(with override: Int,
_: OverrideType) {
_: OverrideType)
{
let timezones = DataStore.shared().timezones()
var timezoneObjects: [TimezoneData] = []
@ -391,7 +392,8 @@ class NotesPopover: NSViewController {
timezone: model.timezone(),
alertIndex: alertIndex,
reminderDate: reminderPicker.dateValue,
additionalNotes: model.note) {
additionalNotes: model.note)
{
showSuccessMessage()
}
}

3
Clocker/Panel/PanelController.swift

@ -154,7 +154,8 @@ class PanelController: ParentPanelController {
}
if let statusWindow = statusBackgroundWindow,
let statusButton = statusView {
let statusButton = statusView
{
var statusItemFrame = statusWindow.convertToScreen(statusButton.frame)
var statusItemScreen = NSScreen.main
var testPoint = statusItemFrame.origin

21
Clocker/Panel/ParentPanelController.swift

@ -188,7 +188,8 @@ class ParentPanelController: NSWindowController {
object: nil)
NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification,
object: self,
queue: OperationQueue.main) { [weak self] _ in
queue: OperationQueue.main)
{ [weak self] _ in
if let sSelf = self {
sSelf.mainTableView.reloadData()
sSelf.setScrollViewConstraint()
@ -416,7 +417,8 @@ class ParentPanelController: NSWindowController {
newHeight += 20
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let obj = object,
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil {
TimezoneDataOperations(with: obj).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) != nil
{
newHeight += 20
}
}
@ -604,7 +606,8 @@ class ParentPanelController: NSWindowController {
if $0 < mainTableView.numberOfRows,
let cellView = mainTableView.view(atColumn: 0, row: $0, makeIfNecessary: false) as? TimezoneCellView,
let model = TimezoneData.customObject(from: current) {
let model = TimezoneData.customObject(from: current)
{
if let futureSliderCell = futureSlider.cell as? CustomSliderCell, futureSliderCell.tracking == true {
return
}
@ -624,7 +627,8 @@ class ParentPanelController: NSWindowController {
if let note = model.note, !note.isEmpty {
cellView.noteLabel.stringValue = note
} else if DataStore.shared().shouldDisplay(.dstTransitionInfo),
let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue) {
let value = TimezoneDataOperations(with: model).nextDaylightSavingsTransitionIfAvailable(with: futureSliderValue)
{
cellView.noteLabel.stringValue = value
} else {
cellView.noteLabel.stringValue = CLEmptyString
@ -724,7 +728,8 @@ class ParentPanelController: NSWindowController {
@IBAction func calendarButtonAction(_ sender: NSButton) {
if sender.title == NSLocalizedString("Click here to start.",
comment: "Button Title for no Calendar access") {
comment: "Button Title for no Calendar access")
{
showPermissionsWindow()
} else {
retrieveCalendarEvents()
@ -815,7 +820,8 @@ class ParentPanelController: NSWindowController {
if let events = eventCenter.eventsForDate[NSCalendar.autoupdatingCurrent.startOfDay(for: now)], events.isEmpty == false {
OperationQueue.main.addOperation {
if self.upcomingEventCollectionView != nil,
let upcomingEvents = eventCenter.upcomingEventsForDay(events) {
let upcomingEvents = eventCenter.upcomingEventsForDay(events)
{
self.upcomingEventsDataSource.updateEventsDataSource(upcomingEvents)
self.upcomingEventCollectionView.reloadData()
return
@ -1115,7 +1121,8 @@ extension ParentPanelController: NSSharingServicePickerDelegate {
stride(from: 0, to: sortedByTime.count, by: 1).forEach {
if $0 < sortedByTime.count,
let dataModel = TimezoneData.customObject(from: sortedByTime[$0]) {
let dataModel = TimezoneData.customObject(from: sortedByTime[$0])
{
let dataOperations = TimezoneDataOperations(with: dataModel)
let date = dataOperations.todaysDate(with: 0)
let time = dataOperations.time(with: 0)

3
Clocker/Panel/Upcoming Events/UpcomingEventViewItem.swift

@ -40,7 +40,8 @@ class UpcomingEventViewItem: NSCollectionViewItem {
_ color: NSColor,
_ link: URL?,
_ delegate: UpcomingEventPanelDelegate?,
_ isCancelled: Bool) {
_ isCancelled: Bool)
{
if leadingConstraint.constant != UpcomingEventViewItem.EventLeadingConstraint / 2 {
leadingConstraint.animator().constant = UpcomingEventViewItem.EventLeadingConstraint / 2
}

5
Clocker/Preferences/App Feedback/AppFeedbackWindowController.swift

@ -80,7 +80,8 @@ class AppFeedbackWindowController: NSWindowController {
themeDidChangeNotification = NotificationCenter.default.addObserver(forName: .themeDidChangeNotification,
object: nil,
queue: OperationQueue.main) { _ in
queue: OperationQueue.main)
{ _ in
self.window?.backgroundColor = Themer.shared().mainBackgroundColor()
self.setup()
}
@ -311,7 +312,7 @@ extension AppFeedbackWindowController: NSWindowDelegate {
func bringPreferencesWindowToFront() {
let windows = NSApplication.shared.windows
let prefWindow = windows.first(where: { window in
return window.identifier == NSUserInterfaceItemIdentifier("Preferences")
window.identifier == NSUserInterfaceItemIdentifier("Preferences")
})
if let prefW = prefWindow {
prefW.makeKeyAndOrderFront(self)

3
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -188,7 +188,8 @@ class AppearanceViewController: ParentViewController {
refresh(panel: true, floating: true)
if let selectedFormat = sender.selectedItem?.title,
selectedFormat.contains("ss") {
selectedFormat.contains("ss")
{
Logger.info("Selected format contains timezone format")
guard let panelController = PanelController.panel() else { return }
panelController.pauseTimer()

6
Clocker/Preferences/Calendar/CalendarViewController.swift

@ -243,13 +243,15 @@ extension CalendarViewController: NSTableViewDelegate {
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
if let currentSource = calendars[row] as? String,
let message = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "sourceCellView"), owner: self) as? SourceTableViewCell {
let message = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "sourceCellView"), owner: self) as? SourceTableViewCell
{
message.sourceName.stringValue = currentSource
return message
}
if let currentSource = calendars[row] as? CalendarInfo,
let calendarCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "calendarCellView"), owner: self) as? CalendarTableViewCell {
let calendarCell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "calendarCellView"), owner: self) as? CalendarTableViewCell
{
calendarCell.calendarName.stringValue = currentSource.calendar.title
calendarCell.calendarSelected.state = currentSource.selected ? NSControl.StateValue.on : NSControl.StateValue.off
calendarCell.calendarSelected.target = self

3
Clocker/Preferences/General/PreferencesDataSource.swift

@ -104,7 +104,8 @@ extension PreferencesDataSource: NSTableViewDataSource {
var selectedDataSource: TimezoneData?
if selectedTimezones.count > row,
let model = TimezoneData.customObject(from: selectedTimezones[row]) {
let model = TimezoneData.customObject(from: selectedTimezones[row])
{
selectedDataSource = model
}

13
Clocker/Preferences/General/PreferencesViewController.swift

@ -19,7 +19,6 @@ struct PreferencesConstants {
}
class PreferencesViewController: ParentViewController {
@IBOutlet private var placeholderLabel: NSTextField!
@IBOutlet private var timezoneTableView: NSTableView!
@IBOutlet private var availableTimezoneTableView: NSTableView!
@ -73,9 +72,7 @@ class PreferencesViewController: ParentViewController {
private lazy var startupManager = StartupManager()
private var dataTask: URLSessionDataTask? = .none
private lazy var notimezoneView: NoTimezoneView? = {
NoTimezoneView(frame: tableview.frame)
}()
private lazy var notimezoneView: NoTimezoneView? = NoTimezoneView(frame: tableview.frame)
private var geocodingKey: String = {
guard let path = Bundle.main.path(forResource: "Keys", ofType: "plist"),
@ -88,8 +85,6 @@ class PreferencesViewController: ParentViewController {
return apiKey
}()
override func viewDidLoad() {
super.viewDidLoad()
@ -100,7 +95,8 @@ class PreferencesViewController: ParentViewController {
NotificationCenter.default.addObserver(forName: NSUbiquitousKeyValueStore.didChangeExternallyNotification,
object: self,
queue: OperationQueue.main) { [weak self] _ in
queue: OperationQueue.main)
{ [weak self] _ in
if let sSelf = self {
sSelf.refreshTimezoneTableView()
}
@ -349,7 +345,8 @@ extension PreferencesViewController: NSTableViewDataSource, NSTableViewDelegate
if let appDelegate = NSApplication.shared.delegate as? AppDelegate,
let menubarFavourites = DataStore.shared().menubarTimezones(),
menubarFavourites.isEmpty,
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false {
DataStore.shared().shouldDisplay(.showMeetingInMenubar) == false
{
appDelegate.invalidateMenubarTimer(true)
}

6
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -33,10 +33,12 @@ func compactWidth(for timezone: TimezoneData) -> Int {
if timeFormat == DateFormat.twelveHour
|| timeFormat == DateFormat.twelveHourWithSeconds
|| timeFormat == DateFormat.twelveHourWithZero
|| timeFormat == DateFormat.twelveHourWithSeconds {
|| timeFormat == DateFormat.twelveHourWithSeconds
{
totalWidth += 20
} else if timeFormat == DateFormat.twentyFourHour
|| timeFormat == DateFormat.twentyFourHourWithSeconds {
|| timeFormat == DateFormat.twentyFourHourWithSeconds
{
totalWidth += 0
}

7
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -115,15 +115,16 @@ class StatusItemHandler: NSObject {
userNotificationsDidChangeNotif = center.addObserver(forName: UserDefaults.didChangeNotification,
object: self,
queue: mainQueue) { _ in
queue: mainQueue)
{ _ in
self.setupStatusItem()
}
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.willSleepNotification, object: nil, queue: OperationQueue.main) { notification in
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.willSleepNotification, object: nil, queue: OperationQueue.main) { _ in
self.menubarTimer?.invalidate()
}
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: OperationQueue.main) { notification in
NSWorkspace.shared.notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: OperationQueue.main) { _ in
self.setupStatusItem()
}
}

1
Clocker/Preferences/Menu Bar/UpcomingEventStatusItemView.swift

@ -65,6 +65,7 @@ class UpcomingEventStatusItemView: NSView {
])
}
@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Loading…
Cancel
Save