working on getting watch app to actually work

This commit is contained in:
breadone 2024-07-10 11:44:58 +12:00
parent f2de4ae7cc
commit a174b096fd
No known key found for this signature in database
14 changed files with 130 additions and 54 deletions

View File

@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
460D7DF62C2AE788002B623C /* TimerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 460D7DF52C2AE788002B623C /* TimerManager.swift */; }; 460D7DF62C2AE788002B623C /* TimerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 460D7DF52C2AE788002B623C /* TimerManager.swift */; };
460D7DF72C2AE788002B623C /* TimerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 460D7DF52C2AE788002B623C /* TimerManager.swift */; }; 460D7DF72C2AE788002B623C /* TimerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 460D7DF52C2AE788002B623C /* TimerManager.swift */; };
4614D4032C3DFD3E000799F5 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46D3E1432C27DFCE0060722E /* Preferences.swift */; };
464787CB2C269CAF00A9C462 /* TeleprompterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 464787CA2C269CAF00A9C462 /* TeleprompterView.swift */; }; 464787CB2C269CAF00A9C462 /* TeleprompterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 464787CA2C269CAF00A9C462 /* TeleprompterView.swift */; };
464787CC2C26A2E100A9C462 /* ColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30F12C2672BD00486C25 /* ColorModel.swift */; }; 464787CC2C26A2E100A9C462 /* ColorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30F12C2672BD00486C25 /* ColorModel.swift */; };
464787CD2C26A2E500A9C462 /* PreviewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30F32C267D6400486C25 /* PreviewData.swift */; }; 464787CD2C26A2E500A9C462 /* PreviewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46AD30F32C267D6400486C25 /* PreviewData.swift */; };
@ -67,6 +68,8 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
460D7DF52C2AE788002B623C /* TimerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerManager.swift; sourceTree = "<group>"; }; 460D7DF52C2AE788002B623C /* TimerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerManager.swift; sourceTree = "<group>"; };
4614D4022C3DF680000799F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; 4614D4022C3DF680000799F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
4614D4042C3DFEE8000799F5 /* OnCuePresenter.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OnCuePresenter.entitlements; sourceTree = "<group>"; };
4614D4052C3DFF16000799F5 /* OnCuePresenter-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "OnCuePresenter-Info.plist"; sourceTree = "<group>"; };
464787CA2C269CAF00A9C462 /* TeleprompterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeleprompterView.swift; sourceTree = "<group>"; }; 464787CA2C269CAF00A9C462 /* TeleprompterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeleprompterView.swift; sourceTree = "<group>"; };
46AD30B72C26557500486C25 /* OnCue.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OnCue.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46AD30B72C26557500486C25 /* OnCue.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OnCue.app; sourceTree = BUILT_PRODUCTS_DIR; };
46AD30BA2C26557500486C25 /* OnCueApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnCueApp.swift; sourceTree = "<group>"; }; 46AD30BA2C26557500486C25 /* OnCueApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnCueApp.swift; sourceTree = "<group>"; };
@ -116,6 +119,8 @@
46AD30AE2C26557500486C25 = { 46AD30AE2C26557500486C25 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
4614D4052C3DFF16000799F5 /* OnCuePresenter-Info.plist */,
4614D4042C3DFEE8000799F5 /* OnCuePresenter.entitlements */,
46AD30F02C2672AC00486C25 /* Shared */, 46AD30F02C2672AC00486C25 /* Shared */,
46AD30B92C26557500486C25 /* OnCue */, 46AD30B92C26557500486C25 /* OnCue */,
46AD30CF2C26559B00486C25 /* OnCuePresenter Watch App */, 46AD30CF2C26559B00486C25 /* OnCuePresenter Watch App */,
@ -355,6 +360,7 @@
files = ( files = (
46AD30E32C2656CB00486C25 /* OCCard.swift in Sources */, 46AD30E32C2656CB00486C25 /* OCCard.swift in Sources */,
46AD30D32C26559B00486C25 /* MainViewPresenter.swift in Sources */, 46AD30D32C26559B00486C25 /* MainViewPresenter.swift in Sources */,
4614D4032C3DFD3E000799F5 /* Preferences.swift in Sources */,
46E5FFD92C26A50D001191C9 /* CueCardViewPresenter.swift in Sources */, 46E5FFD92C26A50D001191C9 /* CueCardViewPresenter.swift in Sources */,
464787CD2C26A2E500A9C462 /* PreviewData.swift in Sources */, 464787CD2C26A2E500A9C462 /* PreviewData.swift in Sources */,
46AD30D12C26559B00486C25 /* OnCuePresenterApp.swift in Sources */, 46AD30D12C26559B00486C25 /* OnCuePresenterApp.swift in Sources */,
@ -574,12 +580,14 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = OnCuePresenter.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"OnCuePresenter Watch App/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"OnCuePresenter Watch App/Preview Content\"";
DEVELOPMENT_TEAM = 9MP5435PRF; DEVELOPMENT_TEAM = 9MP5435PRF;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "OnCuePresenter-Info.plist";
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue; INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -587,14 +595,14 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.watchkitapp; PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.presenter;
PRODUCT_NAME = OnCue; PRODUCT_NAME = OnCue;
SDKROOT = watchos; SDKROOT = watchos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4; TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 10.5; WATCHOS_DEPLOYMENT_TARGET = 10.0;
}; };
name = Debug; name = Debug;
}; };
@ -603,12 +611,14 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = OnCuePresenter.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"OnCuePresenter Watch App/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"OnCuePresenter Watch App/Preview Content\"";
DEVELOPMENT_TEAM = 9MP5435PRF; DEVELOPMENT_TEAM = 9MP5435PRF;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "OnCuePresenter-Info.plist";
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue; INFOPLIST_KEY_WKCompanionAppBundleIdentifier = xyz.breadone.oncue;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -616,14 +626,14 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0; MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.watchkitapp; PRODUCT_BUNDLE_IDENTIFIER = xyz.breadone.oncue.presenter;
PRODUCT_NAME = OnCue; PRODUCT_NAME = OnCue;
SDKROOT = watchos; SDKROOT = watchos;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4; TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 10.5; WATCHOS_DEPLOYMENT_TARGET = 10.0;
}; };
name = Release; name = Release;
}; };

View File

@ -4,6 +4,7 @@
<dict> <dict>
<key>UIBackgroundModes</key> <key>UIBackgroundModes</key>
<array> <array>
<string>fetch</string>
<string>remote-notification</string> <string>remote-notification</string>
</array> </array>
</dict> </dict>

View File

@ -15,8 +15,9 @@ final class OCCard: Identifiable {
var index: Int = 0 var index: Int = 0
var parentProject: OCProject? = nil var parentProject: OCProject? = nil
init(content: String, index: Int) { init(content: String, index: Int, parent: OCProject) {
self.content = content self.content = content
self.index = index self.index = index
self.parentProject = parent
} }
} }

View File

@ -37,6 +37,17 @@ final class OCProject {
self.color = color self.color = color
} }
init(name: String, color: String, tCards: [String] = []) {
self.name = name
self.creationDate = Date()
self.lastEditedDate = Date()
self.color = color
for i in 0 ..< tCards.count {
self.cards?.append(OCCard(content: tCards[i], index: i, parent: self))
}
}
func updateEditedDate(newDate: Date = Date()) { func updateEditedDate(newDate: Date = Date()) {
self.lastEditedDate = newDate self.lastEditedDate = newDate
} }

View File

@ -20,33 +20,33 @@ struct OnCueApp: App {
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do { do {
// #if DEBUG #if DEBUG
// // Use an autorelease pool to make sure Swift deallocates the persistent // Use an autorelease pool to make sure Swift deallocates the persistent
// // container before setting up the SwiftData stack. // container before setting up the SwiftData stack.
// try autoreleasepool { try autoreleasepool {
// let desc = NSPersistentStoreDescription(url: modelConfiguration.url) let desc = NSPersistentStoreDescription(url: modelConfiguration.url)
// let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue") let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.xyz.breadone.oncue")
// desc.cloudKitContainerOptions = opts desc.cloudKitContainerOptions = opts
// // Load the store synchronously so it completes before initializing the // Load the store synchronously so it completes before initializing the
// // CloudKit schema. // CloudKit schema.
// desc.shouldAddStoreAsynchronously = false desc.shouldAddStoreAsynchronously = false
// if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) { if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [OCProject.self, OCCard.self]) {
// let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom) let container = NSPersistentCloudKitContainer(name: "OnCue", managedObjectModel: mom)
// container.persistentStoreDescriptions = [desc] container.persistentStoreDescriptions = [desc]
// container.loadPersistentStores {_, err in container.loadPersistentStores {_, err in
// if let err { if let err {
// fatalError(err.localizedDescription) fatalError(err.localizedDescription)
// } }
// } }
// // Initialize the CloudKit schema after the store finishes loading. // Initialize the CloudKit schema after the store finishes loading.
// try container.initializeCloudKitSchema() try container.initializeCloudKitSchema()
// // Remove and unload the store from the persistent container. // Remove and unload the store from the persistent container.
// if let store = container.persistentStoreCoordinator.persistentStores.first { if let store = container.persistentStoreCoordinator.persistentStores.first {
// try container.persistentStoreCoordinator.remove(store) try container.persistentStoreCoordinator.remove(store)
// } }
// } }
// } }
// #endif #endif
return try ModelContainer(for: schema, configurations: [modelConfiguration]) return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch { } catch {

View File

@ -84,9 +84,12 @@ struct CardsView: View {
return return
} }
let card = OCCard(content: txt, index: (project.sortedCards.last?.index ?? -1) + 1) // adds one to the index, unless there arent any cards in which case default to 0 // adds one to the index, unless there arent any cards in which case default to 0
let card = OCCard(content: txt,
index: (project.sortedCards.last?.index ?? -1) + 1,
parent: project)
project.cards?.append(card) project.cards?.append(card)
try! ctx.save() try? ctx.save()
newCardText = "" newCardText = ""
} }

View File

@ -60,7 +60,7 @@ struct MainView: View {
// } else { // } else {
// newProject = OCProject(name: name, color: color) // newProject = OCProject(name: name, color: color)
// } // }
newProject = OCProject(name: name, color: color) newProject = OCProject(name: name, color: color, cards: [])
modelContext.insert(newProject) modelContext.insert(newProject)
} }
} }

View File

@ -1,6 +1,7 @@
{ {
"images" : [ "images" : [
{ {
"filename" : "oncue_icon.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "watchos", "platform" : "watchos",
"size" : "1024x1024" "size" : "1024x1024"

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

View File

@ -7,6 +7,7 @@
import SwiftUI import SwiftUI
import SwiftData import SwiftData
import CoreData
@main @main
struct OnCuePresenter_Watch_AppApp: App { struct OnCuePresenter_Watch_AppApp: App {
@ -14,11 +15,37 @@ struct OnCuePresenter_Watch_AppApp: App {
let schema = Schema([ let schema = Schema([
OCProject.self, OCProject.self,
OCCard.self, OCCard.self,
// Item.self,
]) ])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do { 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
return try ModelContainer(for: schema, configurations: [modelConfiguration]) return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch { } catch {
fatalError("Could not create ModelContainer: \(error)") fatalError("Could not create ModelContainer: \(error)")

View File

@ -12,6 +12,7 @@ struct MainViewPresenter: View {
@Environment(\.modelContext) private var modelContext @Environment(\.modelContext) private var modelContext
@Query private var items: [OCProject] @Query private var items: [OCProject]
@AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()!
@State private var newProjectName = "" @State private var newProjectName = ""
@State private var addNewProject = false @State private var addNewProject = false
@ -23,13 +24,19 @@ struct MainViewPresenter: View {
CueCardViewPresenter(project: project) CueCardViewPresenter(project: project)
} label: { } label: {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Text("\(project.name)") if (project.color == Color.clear.toHex()!) {
.bold() Text("\(project.name)")
.font(.title2) .bold()
.foregroundStyle(Color(hex: project.color) ?? .white) .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")") Text("\(project.cards?.count ?? 0) \(project.cards?.count ?? 0 == 1 ? "Card" : "Cards")")
} } }
}
.padding(.vertical, 3) .padding(.vertical, 3)
} }

10
OnCuePresenter-Info.plist Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.xyz.breadone.oncue</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
</array>
</dict>
</plist>

View File

@ -12,16 +12,5 @@ public struct PreviewData {
private static let lorem = "colon three" private static let lorem = "colon three"
static let project = OCProject(name: "Test Project", color: "007AFF", cards: [ static let project = OCProject(name: "Test Project", color: "007AFF", tCards: Array<String>(repeating: lorem, count: 10) )
OCCard(content: lorem, index: 0),
OCCard(content: lorem, index: 1),
OCCard(content: lorem, index: 2),
OCCard(content: loreml, index: 3),
OCCard(content: lorem, index: 4),
OCCard(content: lorem, index: 5),
OCCard(content: lorem, index: 6),
OCCard(content: lorem, index: 7),
OCCard(content: lorem, index: 8),
OCCard(content: lorem, index: 9),
])
} }