Statistics Period Filter Bar
Component Detail
Description
Horizontal filter bar allowing selection of time period (this month, last 3 months, this year, custom range) and optionally filtering by activity type. Emits filter change events consumed by parent dashboard screen. Shared with Activity Statistics Dashboard.
stats-period-filter-bar
Summaries
The Statistics Period Filter Bar empowers every type of user — coordinator, org admin, or peer mentor — to slice performance data across meaningful time windows without navigating away from the dashboard. Offering preset periods such as 'this month' or 'last 3 months' alongside a custom range reduces the cognitive load on users and increases the likelihood they will actually explore trends, leading to more informed program decisions. Because this component is shared across multiple reporting surfaces, it provides a consistent filtering experience that reinforces product quality and reduces training overhead for new users.
This low-complexity shared UI component has no external library dependencies, making it straightforward to build and test. The primary delivery consideration is ensuring that the StatsPeriodFilter value object and its DateRange type are agreed upon early, as both the coordinator dashboard and the activity statistics dashboard consume this component — a late schema change would require updates in multiple places. The 'restore last-used filter on re-open' responsibility implies local state persistence, which should be scoped clearly: is this per-session or across app restarts? Clarifying this with product before implementation prevents a rework cycle.
StatsPeriodFilterBar is a stateless-preferring widget that receives an initialFilter and emits a new StatsPeriodFilter via the onFilterChanged ValueChanged callback on every user interaction. Period selection should be implemented as a row of ChoiceChip or FilterChip widgets for the presets, with a separate date-range picker dialog for custom ranges. The activity type dropdown is optional (nullable activityTypeId). The combined filter is assembled in _onAnyChange() and emitted as a single StatsPeriodFilter object — avoid emitting partial state.
The resetToDefault() method resets internal widget state and emits the default filter. Last-used filter restoration can be handled via a lightweight SharedPreferences read in initState, keyed to the calling screen's context to avoid cross-screen bleed.
Responsibilities
- Render period selector chips or dropdown
- Render activity type filter dropdown
- Emit combined filter state on change
- Restore last-used filter on re-open
Interfaces
StatsPeriodFilterBar({required StatsPeriodFilter initialFilter, required ValueChanged<StatsPeriodFilter> onFilterChanged})
StatsPeriodFilter({required DateRange period, String? activityTypeId})
resetToDefault()
setActivityTypeFilter(String? activityTypeId)
setPeriod(DateRange period)
Relationships
Dependents (2)
Components that depend on this component