Browse Source

Introducing CoreModelKit!

pull/92/head
Abhishek 4 years ago
parent
commit
cfa2c961b4
  1. 4
      Clocker/AppDelegate.swift
  2. 21
      Clocker/Clocker.xcodeproj/project.pbxproj
  3. 1
      Clocker/Clocker/LocationController.swift
  4. 40
      Clocker/ClockerUnitTests/ClockerUnitTests.swift
  5. 5
      Clocker/CoreModelKit/.gitignore
  6. 35
      Clocker/CoreModelKit/Package.swift
  7. 3
      Clocker/CoreModelKit/README.md
  8. 0
      Clocker/CoreModelKit/Sources/CoreModelKit/SearchResults.swift
  9. 48
      Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift
  10. 3
      Clocker/CoreModelKit/Tests/CoreModelKitTests/TimezoneDataEqualityTests.swift
  11. 9
      Clocker/CoreModelKit/Tests/CoreModelKitTests/XCTestManifests.swift
  12. 7
      Clocker/CoreModelKit/Tests/LinuxMain.swift
  13. 1
      Clocker/Onboarding/OnboardingSearchController.swift
  14. 1
      Clocker/Overall App/DataStore.swift
  15. 1
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  16. 1
      Clocker/Panel/Notes Popover/NotesPopover.swift
  17. 1
      Clocker/Panel/ParentPanelController.swift
  18. 1
      Clocker/Panel/UI/TimezoneDataSource.swift
  19. 1
      Clocker/Preferences/Appearance/AppearanceViewController.swift
  20. 1
      Clocker/Preferences/General/PreferencesDataSource.swift
  21. 1
      Clocker/Preferences/General/PreferencesViewController.swift
  22. 1
      Clocker/Preferences/General/SearchDataSource.swift
  23. 1
      Clocker/Preferences/Menu Bar/MenubarHandler.swift
  24. 1
      Clocker/Preferences/Menu Bar/StatusContainerView.swift
  25. 1
      Clocker/Preferences/Menu Bar/StatusItemHandler.swift
  26. 1
      Clocker/Preferences/Menu Bar/StatusItemView.swift

4
Clocker/AppDelegate.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
open class AppDelegate: NSObject, NSApplicationDelegate {
private lazy var floatingWindow: FloatingWindowController = FloatingWindowController.shared()
@ -45,6 +46,9 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
// Initializing the event store takes really long
EventCenter.sharedCenter()
// Required for migrating our model type to CoreModelKit
NSKeyedUnarchiver.setClass(CoreModelKit.TimezoneData.classForKeyedUnarchiver(), forClassName: "Clocker.TimezoneData")
AppDefaults.initialize()
// Check if we can show the onboarding flow!

21
Clocker/Clocker.xcodeproj/project.pbxproj

@ -16,6 +16,7 @@
3595FAD0227F88BC0044A12A /* UserDefaults + KVOExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3595FACF227F88BC0044A12A /* UserDefaults + KVOExtensions.swift */; };
35B2FEC0259A186F005DA84D /* StartupKit in Frameworks */ = {isa = PBXBuildFile; productRef = 35B2FEBF259A186F005DA84D /* StartupKit */; };
35B2FEDD259A2291005DA84D /* CoreLoggerKit in Frameworks */ = {isa = PBXBuildFile; productRef = 35B2FEDC259A2291005DA84D /* CoreLoggerKit */; };
35B2FEF1259A2DB1005DA84D /* CoreModelKit in Frameworks */ = {isa = PBXBuildFile; productRef = 35B2FEF0259A2DB1005DA84D /* CoreModelKit */; };
35C11E2124873A550031F18C /* VersionUpdateHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C11E2024873A550031F18C /* VersionUpdateHandler.swift */; };
35C36EF122595F14002FA5C6 /* OnboardingPermissionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36EE822595F13002FA5C6 /* OnboardingPermissionsViewController.swift */; };
35C36EF222595F14002FA5C6 /* OnboardingWelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36EE922595F13002FA5C6 /* OnboardingWelcomeViewController.swift */; };
@ -62,7 +63,6 @@
35C36F592259DD8A002FA5C6 /* TimezoneCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F552259DD8A002FA5C6 /* TimezoneCellView.swift */; };
35C36F5A2259DD8A002FA5C6 /* Panelr.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F562259DD8A002FA5C6 /* Panelr.swift */; };
35C36F5D2259DD96002FA5C6 /* TimezoneDataOperations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F5B2259DD96002FA5C6 /* TimezoneDataOperations.swift */; };
35C36F5E2259DD96002FA5C6 /* TimezoneData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F5C2259DD96002FA5C6 /* TimezoneData.swift */; };
35C36F612259DE67002FA5C6 /* NotesPopover.xib in Resources */ = {isa = PBXBuildFile; fileRef = 35C36F5F2259DE67002FA5C6 /* NotesPopover.xib */; };
35C36F622259DE67002FA5C6 /* NotesPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F602259DE67002FA5C6 /* NotesPopover.swift */; };
35C36F662259DF4C002FA5C6 /* ReviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F642259DF4C002FA5C6 /* ReviewView.swift */; };
@ -83,7 +83,6 @@
35C36FA12259ED6D002FA5C6 /* EventCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F9E2259ED6D002FA5C6 /* EventCenter.swift */; };
35C36FA22259ED6D002FA5C6 /* RemindersHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36F9F2259ED6D002FA5C6 /* RemindersHandler.swift */; };
35C36FA42259EEC2002FA5C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C36FA32259EEC2002FA5C6 /* AppDelegate.swift */; };
35EB537325310FD200311068 /* TimezoneDataEqualityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3545C52A22612BCC00121E25 /* TimezoneDataEqualityTests.swift */; };
9A0A1C8C20903DBD0012003B /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A9E87651C1FEDC500A7A2DF /* CoreLocation.framework */; };
9A13BAD61CA87F08007C6CBE /* Panel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A13BAD81CA87F08007C6CBE /* Panel.xib */; };
9A13BAE01CA882FA007C6CBE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9A13BAE21CA882FA007C6CBE /* InfoPlist.strings */; };
@ -122,7 +121,6 @@
9AB6F1622259D1B000A44663 /* PreferencesDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AB6F1602259D1B000A44663 /* PreferencesDataSource.swift */; };
9AB6F1642259D1B900A44663 /* ParentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AB6F1632259D1B800A44663 /* ParentViewController.swift */; };
9AB6F1672259D23200A44663 /* PermissionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AB6F1662259D23200A44663 /* PermissionsViewController.swift */; };
9AB6F16A2259D2A600A44663 /* SearchResults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AB6F1692259D2A600A44663 /* SearchResults.swift */; };
9AB89E031CE97A4900EC8EB1 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9AB89E021CE97A4900EC8EB1 /* Media.xcassets */; };
9ABFB3801CA6882000E10745 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ABFB37F1CA6882000E10745 /* ApplicationServices.framework */; };
9AC678E41C1ABAB9003B4F6B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9AC678E31C1ABAB9003B4F6B /* QuartzCore.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
@ -229,7 +227,6 @@
3508CCA9259A0027000E3530 /* StatusContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusContainerView.swift; sourceTree = "<group>"; };
352AF497232E07B400D96FA7 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/InfoPlist.strings; sourceTree = "<group>"; };
352AF499232E07B400D96FA7 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Localizable.strings; sourceTree = "<group>"; };
3545C52A22612BCC00121E25 /* TimezoneDataEqualityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimezoneDataEqualityTests.swift; sourceTree = "<group>"; };
354BB0842574810500097121 /* Keys.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Keys.plist; path = ../Internal/Keys.plist; sourceTree = "<group>"; };
3569A44E25441F320087E254 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
357391852507277500D30819 /* HourMarkerViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HourMarkerViewItem.swift; sourceTree = "<group>"; };
@ -237,6 +234,7 @@
3595FACF227F88BC0044A12A /* UserDefaults + KVOExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults + KVOExtensions.swift"; sourceTree = "<group>"; };
35B2FEB1259A1649005DA84D /* StartupKit */ = {isa = PBXFileReference; lastKnownFileType = folder; path = StartupKit; sourceTree = "<group>"; };
35B2FED4259A2244005DA84D /* CoreLoggerKit */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreLoggerKit; sourceTree = "<group>"; };
35B2FEE4259A2C25005DA84D /* CoreModelKit */ = {isa = PBXFileReference; lastKnownFileType = folder; path = CoreModelKit; sourceTree = "<group>"; };
35C11E2024873A550031F18C /* VersionUpdateHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionUpdateHandler.swift; sourceTree = "<group>"; };
35C36EE822595F13002FA5C6 /* OnboardingPermissionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingPermissionsViewController.swift; sourceTree = "<group>"; };
35C36EE922595F13002FA5C6 /* OnboardingWelcomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingWelcomeViewController.swift; sourceTree = "<group>"; };
@ -283,7 +281,6 @@
35C36F552259DD8A002FA5C6 /* TimezoneCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimezoneCellView.swift; sourceTree = "<group>"; };
35C36F562259DD8A002FA5C6 /* Panelr.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Panelr.swift; sourceTree = "<group>"; };
35C36F5B2259DD96002FA5C6 /* TimezoneDataOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimezoneDataOperations.swift; sourceTree = "<group>"; };
35C36F5C2259DD96002FA5C6 /* TimezoneData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimezoneData.swift; sourceTree = "<group>"; };
35C36F5F2259DE67002FA5C6 /* NotesPopover.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NotesPopover.xib; sourceTree = "<group>"; };
35C36F602259DE67002FA5C6 /* NotesPopover.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotesPopover.swift; sourceTree = "<group>"; };
35C36F642259DF4C002FA5C6 /* ReviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReviewView.swift; sourceTree = "<group>"; };
@ -380,7 +377,6 @@
9AB6F1602259D1B000A44663 /* PreferencesDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesDataSource.swift; sourceTree = "<group>"; };
9AB6F1632259D1B800A44663 /* ParentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParentViewController.swift; sourceTree = "<group>"; };
9AB6F1662259D23200A44663 /* PermissionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PermissionsViewController.swift; sourceTree = "<group>"; };
9AB6F1692259D2A600A44663 /* SearchResults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResults.swift; sourceTree = "<group>"; };
9AB89E021CE97A4900EC8EB1 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
9ABFB37F1CA6882000E10745 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
9AC678E31C1ABAB9003B4F6B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
@ -447,6 +443,7 @@
9ACF469D1DCBD45200C49B51 /* Quartz.framework in Frameworks */,
9AC678E41C1ABAB9003B4F6B /* QuartzCore.framework in Frameworks */,
9A5E75E4204CC39700119939 /* ShortcutRecorder.framework in Frameworks */,
35B2FEF1259A2DB1005DA84D /* CoreModelKit in Frameworks */,
35B2FEDD259A2291005DA84D /* CoreLoggerKit in Frameworks */,
35B2FEC0259A186F005DA84D /* StartupKit in Frameworks */,
9A6D93371CF3E82F005A8690 /* CoreImage.framework in Frameworks */,
@ -585,7 +582,6 @@
35C36F512259DC85002FA5C6 /* Data Layer */ = {
isa = PBXGroup;
children = (
35C36F5C2259DD96002FA5C6 /* TimezoneData.swift */,
35C36F5B2259DD96002FA5C6 /* TimezoneDataOperations.swift */,
);
path = "Data Layer";
@ -758,7 +754,6 @@
9AB6F1682259D26400A44663 /* Models */ = {
isa = PBXGroup;
children = (
9AB6F1692259D2A600A44663 /* SearchResults.swift */,
);
path = Models;
sourceTree = "<group>";
@ -796,7 +791,6 @@
children = (
C20839C921515C1E00C86589 /* ClockerUnitTests.swift */,
C20839CB21515C1F00C86589 /* Info.plist */,
3545C52A22612BCC00121E25 /* TimezoneDataEqualityTests.swift */,
);
path = ClockerUnitTests;
sourceTree = "<group>";
@ -824,6 +818,7 @@
DD4F7BF913C30F9F00825C6E = {
isa = PBXGroup;
children = (
35B2FEE4259A2C25005DA84D /* CoreModelKit */,
35B2FED4259A2244005DA84D /* CoreLoggerKit */,
35B2FEB1259A1649005DA84D /* StartupKit */,
354BB0842574810500097121 /* Keys.plist */,
@ -966,6 +961,7 @@
packageProductDependencies = (
35B2FEBF259A186F005DA84D /* StartupKit */,
35B2FEDC259A2291005DA84D /* CoreLoggerKit */,
35B2FEF0259A2DB1005DA84D /* CoreModelKit */,
);
productName = Popup;
productReference = DD4F7C0413C30F9F00825C6E /* Clocker.app */;
@ -1180,7 +1176,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
35EB537325310FD200311068 /* TimezoneDataEqualityTests.swift in Sources */,
C20839CA21515C1E00C86589 /* ClockerUnitTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -1246,7 +1241,6 @@
35C36F2C2259D6FA002FA5C6 /* PanelController.swift in Sources */,
35C36F10225961DA002FA5C6 /* Constants.swift in Sources */,
35C36FA42259EEC2002FA5C6 /* AppDelegate.swift in Sources */,
35C36F5E2259DD96002FA5C6 /* TimezoneData.swift in Sources */,
35C36F19225961DA002FA5C6 /* Enums.swift in Sources */,
35C36F5A2259DD8A002FA5C6 /* Panelr.swift in Sources */,
35C36F712259E185002FA5C6 /* NoTimezoneView.swift in Sources */,
@ -1275,7 +1269,6 @@
35C36EF922595F14002FA5C6 /* OnboardingParentViewController.swift in Sources */,
35C36F4E2259D981002FA5C6 /* DateFormatterManager.swift in Sources */,
35C36F0D225961DA002FA5C6 /* TimePeriod.swift in Sources */,
9AB6F16A2259D2A600A44663 /* SearchResults.swift in Sources */,
35C36EFB2259616B002FA5C6 /* Solar.swift in Sources */,
35C36F662259DF4C002FA5C6 /* ReviewView.swift in Sources */,
35C36EF522595F14002FA5C6 /* OnboardingSearchController.swift in Sources */,
@ -2176,6 +2169,10 @@
isa = XCSwiftPackageProductDependency;
productName = CoreLoggerKit;
};
35B2FEF0259A2DB1005DA84D /* CoreModelKit */ = {
isa = XCSwiftPackageProductDependency;
productName = CoreModelKit;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = DD4F7BFB13C30F9F00825C6E /* Project object */;

1
Clocker/Clocker/LocationController.swift

@ -3,6 +3,7 @@
import Cocoa
import CoreLocation
import CoreLoggerKit
import CoreModelKit
class LocationController: NSObject {
public static let sharedInstance = LocationController()

40
Clocker/ClockerUnitTests/ClockerUnitTests.swift

@ -1,5 +1,7 @@
// Copyright © 2015 Abhishek Banthia
import CoreModelKit
@testable import Clocker
import XCTest
@ -164,34 +166,34 @@ class ClockerUnitTests: XCTestCase {
UserDefaults.standard.set(NSNumber(value: 0), forKey: CLSelectedTimeZoneFormatKey) // Set to 12 hour format
dataObject.setShouldOverrideGlobalTimeFormat(0) // Respect Global Preference
XCTAssertTrue(dataObject.timezoneFormat() == "h:mm a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "h:mm a")
dataObject.setShouldOverrideGlobalTimeFormat(1) // 12-Hour Format
XCTAssertTrue(dataObject.timezoneFormat() == "h:mm a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "h:mm a")
dataObject.setShouldOverrideGlobalTimeFormat(2) // 24-Hour format
XCTAssertTrue(dataObject.timezoneFormat() == "HH:mm")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm")
// Skip 3 since it's a placeholder
dataObject.setShouldOverrideGlobalTimeFormat(4) // 12-Hour with seconds
XCTAssertTrue(dataObject.timezoneFormat() == "h:mm:ss a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "h:mm:ss a")
dataObject.setShouldOverrideGlobalTimeFormat(5) // 24-Hour format with seconds
XCTAssertTrue(dataObject.timezoneFormat() == "HH:mm:ss")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm:ss")
// Skip 6 since it's a placeholder
dataObject.setShouldOverrideGlobalTimeFormat(7) // 12-hour with preceding zero and no seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm a")
dataObject.setShouldOverrideGlobalTimeFormat(8) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm:ss a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss a")
// Skip 9 since it's a placeholder
dataObject.setShouldOverrideGlobalTimeFormat(10) // 12-hour without am/pm and seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm")
dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm:ss")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss")
}
func testTimezoneFormatWithDefaultSetAs24HourFormat() {
@ -199,34 +201,34 @@ class ClockerUnitTests: XCTestCase {
UserDefaults.standard.set(NSNumber(value: 1), forKey: CLSelectedTimeZoneFormatKey) // Set to 24-Hour Format
dataObject.setShouldOverrideGlobalTimeFormat(0)
XCTAssertTrue(dataObject.timezoneFormat() == "HH:mm")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm")
dataObject.setShouldOverrideGlobalTimeFormat(1) // 12-Hour Format
XCTAssertTrue(dataObject.timezoneFormat() == "h:mm a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "h:mm a")
dataObject.setShouldOverrideGlobalTimeFormat(2) // 24-Hour format
XCTAssertTrue(dataObject.timezoneFormat() == "HH:mm")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm")
// Skip 3 since it's a placeholder
dataObject.setShouldOverrideGlobalTimeFormat(4) // 12-Hour with seconds
XCTAssertTrue(dataObject.timezoneFormat() == "h:mm:ss a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "h:mm:ss a")
dataObject.setShouldOverrideGlobalTimeFormat(5) // 24-Hour format with seconds
XCTAssertTrue(dataObject.timezoneFormat() == "HH:mm:ss")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "HH:mm:ss")
// Skip 6 since it's a placeholder
dataObject.setShouldOverrideGlobalTimeFormat(7) // 12-hour with preceding zero and no seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm a")
dataObject.setShouldOverrideGlobalTimeFormat(8) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm:ss a")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss a")
// Skip 9 since it's a placeholder
dataObject.setShouldOverrideGlobalTimeFormat(10) // 12-hour without am/pm and seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm")
dataObject.setShouldOverrideGlobalTimeFormat(11) // 12-hour with preceding zero and seconds
XCTAssertTrue(dataObject.timezoneFormat() == "hh:mm:ss")
XCTAssertTrue(dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == "hh:mm:ss")
}
func testFormattedLabel() {
@ -281,7 +283,7 @@ class ClockerUnitTests: XCTestCase {
for locale in Locale.availableIdentifiers {
let currentLocale = Locale(identifier: locale)
let dateFormatter = DateFormatterManager.dateFormatterWithFormat(with: .none,
format: dataObject.timezoneFormat(),
format: dataObject.timezoneFormat(DataStore.shared().timezoneFormat()),
timezoneIdentifier: dataObject.timezone(),
locale: currentLocale)
let convertedDate = dateFormatter.string(from: newDate)

5
Clocker/CoreModelKit/.gitignore vendored

@ -0,0 +1,5 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/

35
Clocker/CoreModelKit/Package.swift

@ -0,0 +1,35 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "CoreModelKit",
platforms: [
.macOS(.v10_12),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "CoreModelKit",
targets: ["CoreModelKit"]
),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(path: "../CoreLoggerKit/"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "CoreModelKit",
dependencies: ["CoreLoggerKit"]
),
.testTarget(
name: "CoreModelKitTests",
dependencies: ["CoreModelKit", "CoreLoggerKit"]
),
]
)

3
Clocker/CoreModelKit/README.md

@ -0,0 +1,3 @@
# CoreModelKit
A description of this package.

0
Clocker/Preferences/General/Models/SearchResults.swift → Clocker/CoreModelKit/Sources/CoreModelKit/SearchResults.swift

48
Clocker/Panel/Data Layer/TimezoneData.swift → Clocker/CoreModelKit/Sources/CoreModelKit/TimezoneData.swift

@ -3,6 +3,14 @@
import Cocoa
import CoreLoggerKit
struct ModelConstants {
static let customLabel = "customLabel"
static let timezoneName = "formattedAddress"
static let placeIdentifier = "place_id"
static let timezoneID = "timezoneID"
static let emptyString = ""
}
public struct DateFormat {
public static let twelveHour = "h:mm a"
public static let twelveHourWithSeconds = "h:mm:ss a"
@ -15,7 +23,7 @@ public struct DateFormat {
}
// Non-class type cannot conform to NSCoding!
class TimezoneData: NSObject, NSCoding {
public class TimezoneData: NSObject, NSCoding {
public enum SelectionType: Int {
case city
case timezone
@ -26,7 +34,7 @@ class TimezoneData: NSObject, NSCoding {
case menu
}
enum TimezoneOverride: Int {
public enum TimezoneOverride: Int {
case globalFormat = 0
case twelveHourFormat = 1
case twentyFourFormat = 2
@ -58,10 +66,10 @@ class TimezoneData: NSObject, NSCoding {
public var customLabel: String?
public var formattedAddress: String?
public var placeID: String?
public var timezoneID: String? = CLEmptyString
public var timezoneID: String? = ModelConstants.emptyString
public var latitude: Double?
public var longitude: Double?
public var note: String? = CLEmptyString
public var note: String? = ModelConstants.emptyString
public var nextUpdate: Date? = Date()
public var sunriseTime: Date?
public var sunsetTime: Date?
@ -74,20 +82,20 @@ class TimezoneData: NSObject, NSCoding {
public override init() {
selectionType = .timezone
isFavourite = 0
note = CLEmptyString
note = ModelConstants.emptyString
isSystemTimezone = false
overrideFormat = .globalFormat
placeID = UUID().uuidString
}
public init(with dictionary: [String: Any]) {
if let label = dictionary[CLCustomLabel] as? String {
if let label = dictionary[ModelConstants.customLabel] as? String {
customLabel = label
} else {
customLabel = nil
}
if let timezone = dictionary[CLTimezoneID] as? String {
if let timezone = dictionary[ModelConstants.timezoneID] as? String {
timezoneID = timezone
} else {
timezoneID = "Error"
@ -105,13 +113,13 @@ class TimezoneData: NSObject, NSCoding {
longitude = -0.0
}
if let placeIdentifier = dictionary[CLPlaceIdentifier] as? String {
if let placeIdentifier = dictionary[ModelConstants.placeIdentifier] as? String {
placeID = placeIdentifier
} else {
placeID = "Error"
}
if let address = dictionary[CLTimezoneName] as? String {
if let address = dictionary[ModelConstants.timezoneName] as? String {
formattedAddress = address
} else {
formattedAddress = "Error"
@ -124,7 +132,7 @@ class TimezoneData: NSObject, NSCoding {
if let noteString = dictionary["note"] as? String {
note = noteString
} else {
note = CLEmptyString
note = ModelConstants.emptyString
}
isSystemTimezone = false
@ -132,7 +140,7 @@ class TimezoneData: NSObject, NSCoding {
overrideFormat = .globalFormat
}
required init?(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
customLabel = aDecoder.decodeObject(forKey: "customLabel") as? String
formattedAddress = aDecoder.decodeObject(forKey: "formattedAddress") as? String
@ -176,7 +184,7 @@ class TimezoneData: NSObject, NSCoding {
return nil
}
func encode(with aCoder: NSCoder) {
public func encode(with aCoder: NSCoder) {
aCoder.encode(placeID, forKey: "place_id")
aCoder.encode(formattedAddress, forKey: "formattedAddress")
@ -235,7 +243,7 @@ class TimezoneData: NSObject, NSCoding {
}
public func setLabel(_ label: String) {
customLabel = !label.isEmpty ? label : CLEmptyString
customLabel = !label.isEmpty ? label : ModelConstants.emptyString
}
public func setShouldOverrideGlobalTimeFormat(_ shouldOverride: Int) {
@ -354,21 +362,11 @@ class TimezoneData: NSObject, NSCoding {
}
extension TimezoneData {
private func adjustStatusBarAppearance() {
guard let statusItem = (NSApplication.shared.delegate as? AppDelegate)?.statusItemForPanel() else {
return
}
statusItem.setupStatusItem()
}
}
extension TimezoneData {
override var description: String {
public override var description: String {
return objectDescription()
}
override var debugDescription: String {
public override var debugDescription: String {
return objectDescription()
}

3
Clocker/ClockerUnitTests/TimezoneDataEqualityTests.swift → Clocker/CoreModelKit/Tests/CoreModelKitTests/TimezoneDataEqualityTests.swift

@ -1,8 +1,7 @@
// Copyright © 2015 Abhishek Banthia
import CoreModelKit
import Foundation
@testable import Clocker
import XCTest
class TimezoneDataEqualityTests: XCTestCase {

9
Clocker/CoreModelKit/Tests/CoreModelKitTests/XCTestManifests.swift

@ -0,0 +1,9 @@
import XCTest
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(CoreModelKitTests.allTests),
]
}
#endif

7
Clocker/CoreModelKit/Tests/LinuxMain.swift

@ -0,0 +1,7 @@
import XCTest
import CoreModelKitTests
var tests = [XCTestCaseEntry]()
tests += CoreModelKitTests.allTests()
XCTMain(tests)

1
Clocker/Onboarding/OnboardingSearchController.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
class OnboardingSearchController: NSViewController {
@IBOutlet private var appName: NSTextField!

1
Clocker/Overall App/DataStore.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
enum ViewType {
case futureSlider

1
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -3,6 +3,7 @@
import Cocoa
import CoreLocation
import CoreLoggerKit
import CoreModelKit
class TimezoneDataOperations: NSObject {
private var dataObject: TimezoneData!

1
Clocker/Panel/Notes Popover/NotesPopover.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
class NotesPopover: NSViewController {
private enum OverrideType {

1
Clocker/Panel/ParentPanelController.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
import EventKit
struct PanelConstants {

1
Clocker/Panel/UI/TimezoneDataSource.swift

@ -1,6 +1,7 @@
// Copyright © 2015 Abhishek Banthia
import Cocoa
import CoreModelKit
class TimezoneDataSource: NSObject {
var timezones: [TimezoneData] = []

1
Clocker/Preferences/Appearance/AppearanceViewController.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
class AppearanceViewController: ParentViewController {
@IBOutlet var timeFormat: NSPopUpButton!

1
Clocker/Preferences/General/PreferencesDataSource.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
struct PreferencesDataSourceConstants {
static let timezoneNameIdentifier = "formattedAddress"

1
Clocker/Preferences/General/PreferencesViewController.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
import StartupKit
struct PreferencesConstants {

1
Clocker/Preferences/General/SearchDataSource.swift

@ -1,6 +1,7 @@
// Copyright © 2015 Abhishek Banthia
import Cocoa
import CoreModelKit
enum RowType {
case timezoneHeader

1
Clocker/Preferences/Menu Bar/MenubarHandler.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
import EventKit
class MenubarHandler: NSObject {

1
Clocker/Preferences/Menu Bar/StatusContainerView.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
func bufferCalculatedWidth() -> Int {
var totalWidth = 55

1
Clocker/Preferences/Menu Bar/StatusItemHandler.swift

@ -2,6 +2,7 @@
import Cocoa
import CoreLoggerKit
import CoreModelKit
private enum MenubarState {
case compactText

1
Clocker/Preferences/Menu Bar/StatusItemView.swift

@ -1,6 +1,7 @@
// Copyright © 2015 Abhishek Banthia
import Cocoa
import CoreModelKit
var defaultParagraphStyle: NSMutableParagraphStyle {
let paragraphStyle = NSMutableParagraphStyle()

Loading…
Cancel
Save