Add a range dropdown to Insights (Last week / MTD / YTD) - #18
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Insights screen was hard-wired to the current calendar month. This adds a dropdown to switch the category breakdown between three ranges:
The header now shows the selected range's label and actual date span, and the empty-state copy adapts per range.
How
InsightsRangeenum (lib/features/insights/logic/insights_range.dart) owns the label and the date-window math. Boundaries use calendar arithmetic (DateTime(y, m, d ± n)), neverDuration, per the DST note incore/dates.dart.InsightsRepository.monthlyByCategory(month:)→byCategory(from:, toExclusive:); aggregation unchanged.insightsProvideris now keyed by(groupId, range)so each range caches independently and re-selection is instant.InsightsScreenbecomesConsumerStatefulWidgetholding the selected range.Tests
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 analyzeclean,flutter test(180) green,flutter build web --releasesucceeds.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