Skip to content

Commit

Permalink
Use PentabarfKit
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Jul 1, 2024
1 parent 5ace0b7 commit 202e197
Show file tree
Hide file tree
Showing 41 changed files with 1,200 additions and 48,292 deletions.
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- empty_count
analyzer_rules: # Rules run by `swiftlint analyze`
- explicit_self
included:
- Fosdem
- FosdemTests
- FosdemUITests
148 changes: 66 additions & 82 deletions Fosdem.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Fosdem.xcodeproj/xcshareddata/xcschemes/Fosdem.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
71 changes: 21 additions & 50 deletions Fosdem/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,31 @@
// Copyright © 2019 Sean Molenaar. All rights reserved.
//

import CoreData
import SwiftUI
import SwiftData

@main
struct Fosdem: App {

// inject into SwiftUI life-cycle via adaptor !!!
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
let container: ModelContainer

var body: some Scene {
WindowGroup {
EventListView().environment(\.managedObjectContext, appDelegate.persistentContainer.viewContext)
EventListView()
}.modelContainer(container)
}

init() {
do {
container = try ModelContainer(for: Conference.self,
Room.self,
Event.self,
Link.self,
Person.self,
Track.self)
RemoteScheduleFetcher.context = ModelContext(container)
} catch {
fatalError("Failed to create ModelContainer for Conference.")
}
}
}
Expand All @@ -25,66 +39,23 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

static let year = YearHelper().year
static let year = SettingsHelper().year

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
debugPrint(paths[0])

DataImporter.context = persistentContainer.newBackgroundContext()
RemoteScheduleFetcher.fetchScheduleForYear(YearHelper().year)

return true
}

func applicationWillResignActive(_ application: UIApplication) {}

func applicationDidEnterBackground(_ application: UIApplication) {}

func applicationWillEnterForeground(_ application: UIApplication) {
RoomStatusFetcher.fetchRoomStatus()
RemoteScheduleFetcher.fetchScheduleForYear(YearHelper().year)
}
func applicationWillEnterForeground(_ application: UIApplication) {}

func applicationDidBecomeActive(_ application: UIApplication) {}

func applicationWillTerminate(_ application: UIApplication) {
self.saveContext()
}

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "Fosdem")
container.loadPersistentStores(completionHandler: { (_, error) in
container.viewContext.mergePolicy = NSMergePolicy(merge: .overwriteMergePolicyType)
container.viewContext.automaticallyMergesChangesFromParent = true
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()

// MARK: - Core Data Saving support

func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
func applicationWillTerminate(_ application: UIApplication) {}
}
8 changes: 0 additions & 8 deletions Fosdem/Fosdem.xcdatamodeld/.xccurrentversion

This file was deleted.

60 changes: 0 additions & 60 deletions Fosdem/Fosdem.xcdatamodeld/Fosdem 1.1.xcdatamodel/contents

This file was deleted.

60 changes: 0 additions & 60 deletions Fosdem/Fosdem.xcdatamodeld/Fosdem.xcdatamodel/contents

This file was deleted.

52 changes: 0 additions & 52 deletions Fosdem/Import/DataImporter.swift

This file was deleted.

Loading

0 comments on commit 202e197

Please sign in to comment.