rutorrent-flutter icon indicating copy to clipboard operation
rutorrent-flutter copied to clipboard

feat: Show torrent count for each filter state in drawer (#109)

Open ananyaaa66 opened this issue 8 months ago • 1 comments

Closes #109

Summary

Shows the count of torrents for each filter state (All, Downloading, Completed, Active, Inactive, Error) as a badge next to each filter tile in the drawer, matching the ruTorrent web interface behavior.

Changes

  • torrent_service.dart: Added getFilterCount(Filter) method that reuses the existing _filterList() logic to return the count
    • drawer_viewmodel.dart: Exposed getFilterCount() via the DrawerViewModel
    • filter_tile_list_widgets.dart: Added a trailing count badge with themed styling to each FilterTile The count updates reactively as torrents change state (download, complete, error, etc.).

Summary by CodeRabbit

  • New Features
    • Filter tiles now display the count of matching torrents as a trailing badge. The badge styling adapts based on selection state to maintain visual clarity across different filter categories.

ananyaaa66 avatar Mar 31 '26 17:03 ananyaaa66

📝 Walkthrough

Walkthrough

This change adds filter count display functionality to the app's drawer. A new getFilterCount() method is introduced across the service and view model layers to compute matching torrents per filter, and the UI is updated to render these counts as styled trailing widgets in filter tiles.

Changes

Cohort / File(s) Summary
Service Layer
lib/services/state_services/torrent_service.dart
Added public getFilterCount(Filter filter) method that delegates to internal _filterList() and returns the count of matching torrents, defaulting to 0 when null.
ViewModel Layer
lib/ui/widgets/smart_widgets/drawer/drawer_viewmodel.dart
Added public getFilterCount(Filter filter) method as a null-safe wrapper that delegates to the torrent service.
UI Rendering
lib/ui/widgets/dumb_widgets/filter_tile_list_widgets.dart
Modified FilterTile.build() to compute and display filter counts as styled trailing widgets in ListTiles, with opacity and color adjustments based on selection state.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A counter's delight, so neat and divine,
Each filter now shows its torrent count line,
No more shall we guess what downloads await,
The drawer reveals them—how simply ornate!
From service to view, the logic flows free, ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding torrent count display for each filter state in the drawer, which directly matches the primary objective.
Linked Issues check ✅ Passed The PR implements all coding requirements from #109: getFilterCount() method in TorrentService, delegation through DrawerViewModel, and count display with styling in FilterTile.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implement filter count display: the new getFilterCount() method, its delegation through DrawerViewModel, and the trailing count badge UI in FilterTile.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Mar 31 '26 17:03 coderabbitai[bot]