Browse Source

Formatting.

pull/101/head
Abhishek Banthia 3 years ago
parent
commit
a47661665e
  1. 6
      Clocker/Overall App/Foundation + Additions.swift
  2. 3
      Clocker/Overall App/NetworkManager.swift
  3. 4
      Clocker/Overall App/Reach.swift
  4. 2
      Clocker/Overall App/VersionUpdateHandler.swift
  5. 20
      Clocker/Panel/Data Layer/TimezoneDataOperations.swift
  6. 2
      Clocker/Panel/FloatingWindowController.swift

6
Clocker/Overall App/Foundation + Additions.swift

@ -34,9 +34,9 @@ extension NSImage.Name {
static let menubarIcon = NSImage.Name("LightModeIcon")
}
extension Data {
public extension Data {
// Extracting this out for tests
public func decode() -> SearchResult? {
func decode() -> SearchResult? {
let jsonDecoder = JSONDecoder()
do {
let decodedObject = try jsonDecoder.decode(SearchResult.self, from: self)
@ -46,7 +46,7 @@ extension Data {
}
}
public func decodeTimezone() -> Timezone? {
func decodeTimezone() -> Timezone? {
let jsonDecoder = JSONDecoder()
do {
let decodedObject = try jsonDecoder.decode(Timezone.self, from: self)

3
Clocker/Overall App/NetworkManager.swift

@ -41,7 +41,8 @@ extension NetworkManager {
let session = URLSession(configuration: configuration)
guard let encodedPath = path.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
let url = URL(string: encodedPath) else {
let url = URL(string: encodedPath)
else {
completionHandler(nil, unableToGenerateURL)
return nil
}

4
Clocker/Overall App/Reach.swift

@ -54,8 +54,8 @@ open class Reach {
}
}
extension ReachabilityStatus {
fileprivate init(reachabilityFlags flags: SCNetworkReachabilityFlags) {
private extension ReachabilityStatus {
init(reachabilityFlags flags: SCNetworkReachabilityFlags) {
let connectionRequired = flags.contains(.connectionRequired)
let isReachable = flags.contains(.reachable)

2
Clocker/Overall App/VersionUpdateHandler.swift

@ -25,7 +25,7 @@ class VersionUpdateHandler: NSObject {
private var appStoreCountry: String!
private var applicationVersion: String!
private var applicationBundleID: String = Bundle.main.bundleIdentifier ?? "N/A"
private var updatePriority: VersionUpdateHandlerPriority = VersionUpdateHandlerPriority.defaultPri
private var updatePriority = VersionUpdateHandlerPriority.defaultPri
private var useAllAvailableLanguages: Bool = true
private var onlyPromptIfMainWindowIsAvailable: Bool = true
private var checkAtLaunch: Bool = true

20
Clocker/Panel/Data Layer/TimezoneDataOperations.swift

@ -7,7 +7,7 @@ import CoreModelKit
class TimezoneDataOperations: NSObject {
private var dataObject: TimezoneData!
private lazy var nsCalendar: Calendar = Calendar.autoupdatingCurrent
private lazy var nsCalendar = Calendar.autoupdatingCurrent
private static var gregorianCalendar = NSCalendar(calendarIdentifier: NSCalendar.Identifier.gregorian)
private static var swiftyCalendar = Calendar(identifier: .gregorian)
private static let currentLocale = Locale.current.identifier
@ -22,12 +22,13 @@ extension TimezoneDataOperations {
guard let newDate = TimezoneDataOperations.gregorianCalendar?.date(byAdding: .minute,
value: sliderValue,
to: Date(),
options: .matchFirst) else {
options: .matchFirst)
else {
assertionFailure("Data was unexpectedly nil")
return CLEmptyString
}
if (dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == DateFormat.epochTime) {
if dataObject.timezoneFormat(DataStore.shared().timezoneFormat()) == DateFormat.epochTime {
let timezone = TimeZone(identifier: dataObject.timezone())
let offset = timezone?.secondsFromGMT(for: newDate) ?? 0
let value = Int(Date().timeIntervalSince1970 + Double(offset))
@ -39,7 +40,6 @@ extension TimezoneDataOperations {
timezoneIdentifier: dataObject.timezone(),
locale: Locale.autoupdatingCurrent)
return dateFormatter.string(from: newDate)
}
@ -52,7 +52,8 @@ extension TimezoneDataOperations {
guard let newDate = TimezoneDataOperations.gregorianCalendar?.date(byAdding: .minute,
value: sliderValue,
to: Date(),
options: .matchFirst) else {
options: .matchFirst)
else {
assertionFailure("Data was unexpectedly nil")
return nil
}
@ -204,8 +205,8 @@ extension TimezoneDataOperations {
let sourceTimezone = TimeZone.current
let destinationTimezone = TimeZone(identifier: dataObject.timezone())
let sourceGMTOffset: Double = Double(sourceTimezone.secondsFromGMT(for: source))
let destinationGMTOffset: Double = Double(destinationTimezone?.secondsFromGMT(for: source) ?? 0)
let sourceGMTOffset = Double(sourceTimezone.secondsFromGMT(for: source))
let destinationGMTOffset = Double(destinationTimezone?.secondsFromGMT(for: source) ?? 0)
let interval = destinationGMTOffset - sourceGMTOffset
return Date(timeInterval: interval, since: source)
@ -367,12 +368,13 @@ extension TimezoneDataOperations {
to: Date())
guard let lat = dataObject.latitude,
let long = dataObject.longitude else {
let long = dataObject.longitude
else {
assertionFailure("Data was unexpectedly nil.")
return
}
let coordinates: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: lat, longitude: long)
let coordinates = CLLocationCoordinate2D(latitude: lat, longitude: long)
guard let dateForCalculation = currentDate, let solar = Solar(for: dateForCalculation, coordinate: coordinates) else {
return

2
Clocker/Panel/FloatingWindowController.swift

@ -5,7 +5,7 @@ import Cocoa
class FloatingWindowController: ParentPanelController {
private var repeater: Repeater?
static var sharedWindow: FloatingWindowController = FloatingWindowController(windowNibName: NSNib.Name.floatingWindowIdentifier)
static var sharedWindow = FloatingWindowController(windowNibName: NSNib.Name.floatingWindowIdentifier)
override func windowDidLoad() {
super.windowDidLoad()

Loading…
Cancel
Save