Add Apple Watch companion app with complications and WCSession sync
- Add watchOS app target with mood voting UI (5 mood buttons) - Add WidgetKit complications (circular, corner, inline, rectangular) - Add WatchConnectivityManager for bidirectional sync between iOS and watch - iOS app acts as central coordinator - all mood logging flows through MoodLogger - Watch votes send to iPhone via WCSession, iPhone logs and notifies watch back - Widget votes use openAppWhenRun=true to run MoodLogger in main app process - Add #if !os(watchOS) guards to Mood.swift and Random.swift for compatibility - Update SKStoreReviewController to AppStore.requestReview (iOS 18 deprecation fix) - Watch reads user's moodImages preference from GroupUserDefaults for emoji style 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftData
|
||||
import WidgetKit
|
||||
import os.log
|
||||
|
||||
/// Lightweight read-only data provider for widgets
|
||||
@@ -182,6 +183,17 @@ final class WidgetDataProvider {
|
||||
)
|
||||
|
||||
modelContext.insert(entry)
|
||||
try? modelContext.save()
|
||||
|
||||
do {
|
||||
try modelContext.save()
|
||||
|
||||
// Refresh all widgets immediately
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
|
||||
// Note: WatchConnectivity is not available in widget extensions
|
||||
// The watch will pick up the data on its next timeline refresh
|
||||
} catch {
|
||||
// Silently fail for widget context
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user