Athena — roomy-mobile/archive/changes/2025-12-28-fix-home-expense-widget-reactivity/tasks/001-add-viewmodel-state.md


status: done

Task: Add ViewModel State and Methods

End Goal

HomeViewModel exposes payment listenables and date range state/methods matching PaymentsViewModel patterns.

Currently

  • HomeViewModel has _selectedPeriod Informer but no _customDateRange
  • HomeViewModel has computed getters but they don't include custom date range
  • No listenable exposed for payment changes
  • No period selection or custom range methods

Should

  • HomeViewModel exposes paymentsListenable for reactivity
  • HomeViewModel has _customDateRange Informer and getter
  • Computed getters include custom date range parameter
  • Period selection and custom range methods exist

Constraints

  • [ ] Follow existing PaymentsViewModel patterns exactly
  • [ ] Use project's section markers (STATE, FETCHERS, MUTATORS)
  • [ ] No graphs or analytics - summary cards only

Acceptance Criteria

  • [ ] paymentsListenable getter exists and returns merged listenable from PaymentsService
  • [ ] _customDateRange Informer exists in STATE section
  • [ ] customDateRangeListenable getter exists in FETCHERS section
  • [ ] filteredUserPayments, userPaidTotal, userOwesTotal use _customDateRange.value
  • [ ] onPresetSelected(PaymentPeriodFilter) method exists in MUTATORS section
  • [ ] onCustomRangeSelected(DateTimeRange?) method exists in MUTATORS section

Implementation Checklist

  • [x] 1.1 Add paymentsListenable getter in FETCHERS section
  • [x] 1.2 Add _customDateRange Informer in STATE section
  • [x] 1.3 Add customDateRangeListenable getter in FETCHERS section
  • [x] 1.4 Update filteredUserPayments to use _customDateRange.value
  • [x] 1.5 Update userPaidTotal to use _customDateRange.value
  • [x] 1.6 Update userOwesTotal to use _customDateRange.value
  • [x] 1.7 Add onPresetSelected method in MUTATORS section
  • [x] 1.8 Add onCustomRangeSelected method in MUTATORS section

Notes

Reference payments_view_model.dart lines 77-89 for state pattern and lines 233-241 for methods.

Reacties

Nog geen reacties