Skip to content

Add a range dropdown to Insights (Last week / MTD / YTD) - #18

Merged
LouisBenjamin merged 1 commit into
mainfrom
feature/insights-range-dropdown
Sep 2, 2026
Merged

Add a range dropdown to Insights (Last week / MTD / YTD)#18
LouisBenjamin merged 1 commit into
mainfrom
feature/insights-range-dropdown

Conversation

@LouisBenjamin

Copy link
Copy Markdown
Owner

What

The Insights screen was hard-wired to the current calendar month. This adds a dropdown to switch the category breakdown between three ranges:

  • Last week — rolling past 7 days
  • Month to date — 1st of this month → today (default)
  • Year to date — Jan 1 → today

The header now shows the selected range's label and actual date span, and the empty-state copy adapts per range.

How

  • New InsightsRange enum (lib/features/insights/logic/insights_range.dart) owns the label and the date-window math. Boundaries use calendar arithmetic (DateTime(y, m, d ± n)), never Duration, per the DST note in core/dates.dart.
  • InsightsRepository.monthlyByCategory(month:)byCategory(from:, toExclusive:); aggregation unchanged.
  • insightsProvider is now keyed by (groupId, range) so each range caches independently and re-selection is instant.
  • InsightsScreen becomes ConsumerStatefulWidget holding the selected range.

Tests

  • New test/features/insights/insights_range_test.dart — unit-tests the window math incl. month/year-boundary roll-back.
  • test/features/screens_smoke_test.dart — updated the provider-override keys, added a test that switches range via the dropdown.
  • flutter analyze clean, flutter test (180) green, flutter build web --release succeeds.

Manual check (needs auth)

Open a group → Insights: confirm it opens on "Month to date", the dropdown switches ranges, the label/span/totals update, and an empty range shows "No spending for … yet".

🤖 Generated with Claude Code

The Insights screen was hard-wired to the current calendar month. Add a
dropdown to switch the category breakdown between the past 7 days,
month-to-date, and year-to-date, defaulting to month-to-date.

- New InsightsRange enum owns the label + DST-safe date-window math
- InsightsRepository.monthlyByCategory -> byCategory(from, toExclusive)
- insightsProvider is now keyed by (groupId, range) so each range caches
  independently
- InsightsScreen becomes stateful, shows the selected range's date span,
  and updates its empty-state copy per range

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzXWJsUFffSSJAKGaRqUT4
@LouisBenjamin
LouisBenjamin merged commit a7d49ae into main Sep 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant