Add interactive iOS widget with subscription-based views

- Add direct API completion from widget via quick-complete endpoint
- Share auth token and API URL with widget via App Group UserDefaults
- Add dirty flag mechanism to refresh tasks when app returns from background
- Widget checkbox colors indicate priority (red=urgent, orange=high, yellow=medium, green=low)
- Show simple "X tasks waiting" view for free tier users when limitations enabled
- Show interactive task completion widget for premium users or when limitations disabled
- Sync subscription status with widget extension for view selection

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-08 12:02:16 -06:00
parent c5b08befea
commit efdb760438
10 changed files with 1008 additions and 124 deletions

View File

@@ -2,6 +2,7 @@ import SwiftUI
import ComposeApp
struct AllTasksView: View {
@Environment(\.scenePhase) private var scenePhase
@StateObject private var taskViewModel = TaskViewModel()
@StateObject private var residenceViewModel = ResidenceViewModel()
@StateObject private var subscriptionCache = SubscriptionCacheWrapper.shared
@@ -98,7 +99,14 @@ struct AllTasksView: View {
}
.onAppear {
PostHogAnalytics.shared.screen(AnalyticsEvents.taskScreenShown)
loadAllTasks()
// Check if widget completed a task - force refresh if dirty
if WidgetDataManager.shared.areTasksDirty() {
WidgetDataManager.shared.clearDirtyFlag()
loadAllTasks(forceRefresh: true)
} else {
loadAllTasks()
}
residenceViewModel.loadMyResidences()
}
// Handle push notification deep links
@@ -126,6 +134,15 @@ struct AllTasksView: View {
}
}
}
// Check dirty flag when app returns from background (widget may have completed a task)
.onChange(of: scenePhase) { newPhase in
if newPhase == .active {
if WidgetDataManager.shared.areTasksDirty() {
WidgetDataManager.shared.clearDirtyFlag()
loadAllTasks(forceRefresh: true)
}
}
}
}
@ViewBuilder