Fix residence auto-update, widget theming, and document patterns
- Fix residence detail not updating after edit: - DataManager.updateResidence() now updates both _residences and _myResidences - ResidenceViewModel auto-updates selectedResidence when data changes - No pull-to-refresh needed after editing - Add widget theme support: - Widgets now use user's selected theme via App Group UserDefaults - ThemeManager has simplified version for widget extension context - Added WIDGET_EXTENSION compiler flag to CaseraExtension target - Redesign widget views with organic aesthetic: - Updated FreeWidgetView, SmallWidgetView, MediumWidgetView, LargeWidgetView - Created OrganicTaskRowView, OrganicStatsView, OrganicStatPillWidget - Document patterns in CLAUDE.md: - Added Mutation & Auto-Update Pattern section - Added iOS Shared Components documentation - Documented reusable buttons, forms, empty states, cards, modifiers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,11 @@ class ResidenceViewModel: ObservableObject {
|
||||
if myResidences != nil {
|
||||
self?.isLoading = false
|
||||
}
|
||||
// Auto-update selectedResidence if it exists in the updated list
|
||||
if let currentSelected = self?.selectedResidence,
|
||||
let updatedResidence = myResidences?.residences.first(where: { $0.id == currentSelected.id }) {
|
||||
self?.selectedResidence = updatedResidence
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -40,6 +45,11 @@ class ResidenceViewModel: ObservableObject {
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] residences in
|
||||
self?.residences = residences
|
||||
// Auto-update selectedResidence if it exists in the updated list
|
||||
if let currentSelected = self?.selectedResidence,
|
||||
let updatedResidence = residences.first(where: { $0.id == currentSelected.id }) {
|
||||
self?.selectedResidence = updatedResidence
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user