Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
422 changes: 422 additions & 0 deletions Assets/AppShortcuts.xcstrings

Large diffs are not rendered by default.

270 changes: 270 additions & 0 deletions Assets/InfoPlist.xcstrings
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
{
"sourceLanguage" : "en",
"strings" : {
"CFBundleDisplayName" : {
"comment" : "Bundle display name",
"extractionState" : "extracted_with_value",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"de" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Solstice"
}
},
"es" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"fr" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"it" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"ja" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"nl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"pl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
}
}
},
"CFBundleName" : {
"comment" : "Bundle name",
"extractionState" : "extracted_with_value",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"de" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Solstice"
}
},
"es" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"fr" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"it" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"ja" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"nl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"pl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice"
}
}
}
},
"NSLocationUsageDescription" : {
"comment" : "Privacy - Location Usage Description",
"extractionState" : "extracted_with_value",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "يستخدم Solstice موقعك لحساب أوقات الشروق والغروب المحلية"
}
},
"de" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice verwendet deinen Standort, um die lokalen Zeiten für Sonnenauf- und -untergang zu berechnen"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Solstice uses your location to calculate local sunrise and sunset times"
}
},
"es" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice usa tu ubicación para calcular las horas locales de amanecer y puesta de sol"
}
},
"fr" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice utilise votre position pour calculer les heures locales de lever et de coucher du soleil."
}
},
"it" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice usa la tua posizione per calcolare gli orari locali di alba e tramonto"
}
},
"ja" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solsticeは、現地の日の出と日の入りの時刻を計算するために位置情報を使用します"
}
},
"nl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice gebruikt je locatie om de lokale tijden van zonsopkomst en zonsondergang te berekenen"
}
},
"pl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice używa Twojej lokalizacji, aby obliczyć lokalne godziny wschodu i zachodu słońca"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice 使用你的位置来计算当地的日出和日落时间"
}
}
}
},
"NSLocationWhenInUseUsageDescription" : {
"comment" : "Privacy - Location When In Use Usage Description",
"extractionState" : "extracted_with_value",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "يستخدم Solstice موقعك لحساب أوقات الشروق والغروب المحلية"
}
},
"de" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice verwendet deinen Standort, um die lokalen Zeiten für Sonnenauf- und -untergang zu berechnen"
}
},
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Solstice uses your location to calculate local sunrise and sunset times"
}
},
"es" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice usa tu ubicación para calcular las horas locales de amanecer y puesta de sol"
}
},
"fr" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice utilise votre position pour calculer les heures locales de lever et de coucher du soleil."
}
},
"it" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice usa la tua posizione per calcolare gli orari locali di alba e tramonto"
}
},
"ja" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solsticeは、現地の日の出と日の入りの時刻を計算するために位置情報を使用します"
}
},
"nl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice gebruikt je locatie om de lokale tijden van zonsopkomst en zonsondergang te berekenen"
}
},
"pl" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice używa Twojej lokalizacji, aby obliczyć lokalne godziny wschodu i zachodu słońca"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "machine_translated",
"value" : "Solstice 使用你的位置来计算当地的日出和日落时间"
}
}
}
}
},
"version" : "1.3"
}
42 changes: 21 additions & 21 deletions Data Model/Persistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CoreData

class PersistenceController {
static let shared = PersistenceController()

static var preview: PersistenceController = {
let result = PersistenceController(inMemory: true)
let viewContext = result.container.viewContext
Expand All @@ -32,28 +32,28 @@ class PersistenceController {
}
return result
}()

let container: NSPersistentCloudKitContainer

init(inMemory: Bool = false) {
container = NSPersistentCloudKitContainer(name: "Solstice")

if inMemory {
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
} else {
let fileUrl = NSPersistentContainer.defaultDirectoryURL().relativePath + "/Solstice.sqlite"
container.persistentStoreDescriptions.first?.url = URL(filePath: fileUrl)
}

container.persistentStoreDescriptions.first?.cloudKitContainerOptions = .init(containerIdentifier: Constants.iCloudContainerIdentifier)

container.viewContext.automaticallyMergesChangesFromParent = true
container.loadPersistentStores(completionHandler: { (storeDescription, error) in

container.loadPersistentStores(completionHandler: { _, error in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.

/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
Expand All @@ -65,18 +65,18 @@ class PersistenceController {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})

// Observe Core Data remote change notifications.
NotificationCenter.default.addObserver(self,
selector: #selector(storeRemoteChange(_:)),
name: .NSPersistentStoreRemoteChange,
object: container.persistentStoreCoordinator)
selector: #selector(storeRemoteChange(_:)),
name: .NSPersistentStoreRemoteChange,
object: container.persistentStoreCoordinator)
}
@objc func storeRemoteChange(_ notification: Notification) {

@objc func storeRemoteChange(_: Notification) {
deduplicateRecords()
}

func deduplicateRecords() {
container.performBackgroundTask { context in
for entry in SavedLocation.defaultData {
Expand All @@ -85,13 +85,13 @@ class PersistenceController {
let request = SavedLocation.fetchRequest()
request.predicate = NSPredicate(format: "uuid == %@", uuidString)
let results = try context.fetch(request)

for (index, result) in results.enumerated() {
if index != 0 {
context.delete(result)
}
}

try context.save()
} catch {
print(error.localizedDescription)
Expand All @@ -101,10 +101,10 @@ class PersistenceController {
}
}

extension SavedLocation {
public override func awakeFromInsert() {
public extension SavedLocation {
override func awakeFromInsert() {
super.awakeFromInsert()

if uuid == nil {
uuid = UUID()
}
Expand Down
4 changes: 2 additions & 2 deletions Data Model/SavedLocation++.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ extension SavedLocation {

extension SavedLocation {
static let nycUUIDString = "7AAA4D87-4402-4D0E-A35E-2D84641A71BE"

static var defaultData: [SavedLocation.CodableRepresentation] {
guard let defaultDataUrl = Bundle.main.url(forResource: "defaultData", withExtension: "json") else {
print("No URL for defaultData.json")
return []
}

do {
let defaultDataFileData = try Data(contentsOf: defaultDataUrl)
return try JSONDecoder().decode([SavedLocation.CodableRepresentation].self, from: defaultDataFileData)
Expand Down
Loading