From 9319e8904b0f9706b8f14a2a8f2ebf858e7eaa22 Mon Sep 17 00:00:00 2001 From: june Date: Fri, 14 Feb 2025 23:34:59 +1300 Subject: [PATCH] idek what i was doing bruh --- OnCue.xcodeproj/project.pbxproj | 4 +- OnCue/OnCueApp.swift | 54 +++++++++---------- .../OnCuePresenterApp.swift | 54 +++++++++---------- .../View/MainViewPresenter.swift | 43 ++++++++------- 4 files changed, 81 insertions(+), 74 deletions(-) diff --git a/OnCue.xcodeproj/project.pbxproj b/OnCue.xcodeproj/project.pbxproj index e38f32d..650a110 100644 --- a/OnCue.xcodeproj/project.pbxproj +++ b/OnCue.xcodeproj/project.pbxproj @@ -509,7 +509,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = OnCue/OnCue.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"OnCue/Preview Content\""; DEVELOPMENT_TEAM = 9MP5435PRF; ENABLE_PREVIEWS = YES; @@ -546,7 +546,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = OnCue/OnCue.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_ASSET_PATHS = "\"OnCue/Preview Content\""; DEVELOPMENT_TEAM = 9MP5435PRF; ENABLE_PREVIEWS = YES; diff --git a/OnCue/OnCueApp.swift b/OnCue/OnCueApp.swift index cafe1f1..cb2a8f8 100644 --- a/OnCue/OnCueApp.swift +++ b/OnCue/OnCueApp.swift @@ -20,33 +20,33 @@ struct OnCueApp: App { let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { - #if DEBUG - // Use an autorelease pool to make sure Swift deallocates the persistent - // container before setting up the SwiftData stack. - try autoreleasepool { - let desc = NSPersistentStoreDescription(url: modelConfiguration.url) - let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue") - desc.cloudKitContainerOptions = opts - // Load the store synchronously so it completes before initializing the - // CloudKit schema. - desc.shouldAddStoreAsynchronously = false - if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) { - let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom) - container.persistentStoreDescriptions = [desc] - container.loadPersistentStores {_, err in - if let err { - fatalError(err.localizedDescription) - } - } - // Initialize the CloudKit schema after the store finishes loading. - try container.initializeCloudKitSchema() - // Remove and unload the store from the persistent container. - if let store = container.persistentStoreCoordinator.persistentStores.first { - try container.persistentStoreCoordinator.remove(store) - } - } - } - #endif +// #if DEBUG +// // Use an autorelease pool to make sure Swift deallocates the persistent +// // container before setting up the SwiftData stack. +// try autoreleasepool { +// let desc = NSPersistentStoreDescription(url: modelConfiguration.url) +// let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue") +// desc.cloudKitContainerOptions = opts +// // Load the store synchronously so it completes before initializing the +// // CloudKit schema. +// desc.shouldAddStoreAsynchronously = false +// if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) { +// let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom) +// container.persistentStoreDescriptions = [desc] +// container.loadPersistentStores {_, err in +// if let err { +// fatalError(err.localizedDescription) +// } +// } +// // Initialize the CloudKit schema after the store finishes loading. +// try container.initializeCloudKitSchema() +// // Remove and unload the store from the persistent container. +// if let store = container.persistentStoreCoordinator.persistentStores.first { +// try container.persistentStoreCoordinator.remove(store) +// } +// } +// } +// #endif return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { diff --git a/OnCuePresenter Watch App/OnCuePresenterApp.swift b/OnCuePresenter Watch App/OnCuePresenterApp.swift index 81f6dfa..7efd453 100644 --- a/OnCuePresenter Watch App/OnCuePresenterApp.swift +++ b/OnCuePresenter Watch App/OnCuePresenterApp.swift @@ -19,33 +19,33 @@ struct OnCuePresenter_Watch_AppApp: App { let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { - #if DEBUG - // Use an autorelease pool to make sure Swift deallocates the persistent - // container before setting up the SwiftData stack. - try autoreleasepool { - let desc = NSPersistentStoreDescription(url: modelConfiguration.url) - let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue") - desc.cloudKitContainerOptions = opts - // Load the store synchronously so it completes before initializing the - // CloudKit schema. - desc.shouldAddStoreAsynchronously = false - if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) { - let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom) - container.persistentStoreDescriptions = [desc] - container.loadPersistentStores {_, err in - if let err { - fatalError(err.localizedDescription) - } - } - // Initialize the CloudKit schema after the store finishes loading. - try container.initializeCloudKitSchema() - // Remove and unload the store from the persistent container. - if let store = container.persistentStoreCoordinator.persistentStores.first { - try container.persistentStoreCoordinator.remove(store) - } - } - } - #endif +// #if DEBUG +// // Use an autorelease pool to make sure Swift deallocates the persistent +// // container before setting up the SwiftData stack. +// try autoreleasepool { +// let desc = NSPersistentStoreDescription(url: modelConfiguration.url) +// let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue") +// desc.cloudKitContainerOptions = opts +// // Load the store synchronously so it completes before initializing the +// // CloudKit schema. +// desc.shouldAddStoreAsynchronously = false +// if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) { +// let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom) +// container.persistentStoreDescriptions = [desc] +// container.loadPersistentStores {_, err in +// if let err { +// fatalError(err.localizedDescription) +// } +// } +// // Initialize the CloudKit schema after the store finishes loading. +// try container.initializeCloudKitSchema() +// // Remove and unload the store from the persistent container. +// if let store = container.persistentStoreCoordinator.persistentStores.first { +// try container.persistentStoreCoordinator.remove(store) +// } +// } +// } +// #endif return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") diff --git a/OnCuePresenter Watch App/View/MainViewPresenter.swift b/OnCuePresenter Watch App/View/MainViewPresenter.swift index 2267612..2bc991d 100644 --- a/OnCuePresenter Watch App/View/MainViewPresenter.swift +++ b/OnCuePresenter Watch App/View/MainViewPresenter.swift @@ -12,38 +12,23 @@ struct MainViewPresenter: View { @Environment(\.modelContext) private var modelContext @Query private var items: [OCProject] - @AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()! @State private var newProjectName = "" @State private var addNewProject = false var body: some View { - NavigationSplitView { + NavigationView { List { ForEach(items) { project in NavigationLink { CueCardViewPresenter(project: project) } label: { - VStack(alignment: .leading) { - if (project.color == Color.clear.toHex()!) { - Text("\(project.name)") - .bold() - .font(.title2) - .foregroundStyle(Color(hex: themeColor) ?? .blue) - } else { - Text("\(project.name)") - .bold() - .font(.title2) - .foregroundStyle(Color(hex: project.color) ?? .white) - } - Text("\(project.cards?.count ?? 0) \(project.cards?.count ?? 0 == 1 ? "Card" : "Cards")") - } } + ProjectCard(project: project) + } .padding(.vertical, 3) } } .navigationTitle("Projects") - } detail: { - Text("Select an item") } } } @@ -57,3 +42,25 @@ struct MainViewPresenter: View { return MainViewPresenter() .modelContainer(container) } + +struct ProjectCard: View { + @AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()! + let project: OCProject + + var body: some View { + VStack(alignment: .leading) { + if (project.color == Color.clear.toHex()!) { + Text("\(project.name)") + .bold() + .font(.title2) + .foregroundStyle(Color(hex: themeColor) ?? .blue) + } else { + Text("\(project.name)") + .bold() + .font(.title2) + .foregroundStyle(Color(hex: project.color) ?? .white) + } + Text("\(project.cards?.count ?? 0) \(project.cards?.count ?? 0 == 1 ? "Card" : "Cards")") + } + } +}