critical priority low complexity frontend pending frontend specialist Tier 1

Acceptance Criteria

Widget accepts a required TimeWindow value (current selection) and a required ValueChanged<TimeWindow> onChanged callback
All 5 TimeWindow values are rendered as tappable segments in a single horizontal row
Each segment tap target is at minimum 44×44 dp (verified via flutter_test widget bounds check)
Active segment background uses the design token accent color; inactive segments use the design token surface color
Active segment foreground text uses a color with ≥4.5:1 contrast ratio against its background (WCAG 2.2 AA)
Inactive segment foreground text uses a color with ≥4.5:1 contrast ratio against its background
Each segment has a Semantics widget with label '[window label]' and selected: true/false matching the active state
Tapping an already-selected segment does NOT call onChanged
Widget rebuilds correctly when the parent passes a new value prop (stateless design)
Widget uses only design token constants — no hardcoded color hex values
Custom TimeWindow segment is hidden unless the feature flag for custom range is enabled (controlled via constructor bool showCustom = false)
Widget renders correctly at 1.0×, 1.5×, and 2.0× text scale factors without overflow

Technical Requirements

frameworks
Flutter
flutter_test
data models
TimeWindow
TimeWindowSelection
performance requirements
Widget build method must complete in under 16ms (one frame budget)
No unnecessary rebuilds — widget is stateless and relies entirely on parent-driven value prop
security requirements
No user data rendered in this widget — time window labels only
ui components
Semantics (Flutter built-in)
GestureDetector or InkWell for tap handling
Design token color constants (AppColors / AppTokens)

Execution Context

Execution Tier
Tier 1

Tier 1 - 540 tasks

Can start after Tier 0 completes

Implementation Notes

Implement as a StatelessWidget. Use a Row of Expanded children, each wrapped in a GestureDetector (or Material+InkWell for ripple) with a minimum size enforcer via ConstrainedBox(constraints: BoxConstraints(minWidth: 44, minHeight: 44)). Do NOT use Flutter's built-in SegmentedButton — it does not expose enough customization for design token integration. Label strings should come from a localization extension on TimeWindow (e.g., timeWindow.label(context)) so they are future-proof for Norwegian locale.

Wrap each segment's content in a Semantics widget with label and selected properties. Place the widget in lib/features/stats/presentation/widgets/time_window_selector.dart.

Testing Requirements

Widget tests in test/stats/time_window_selector_test.dart. Required scenarios: (1) all 5 segments render with correct label text; (2) tapping an inactive segment calls onChanged with correct TimeWindow value; (3) tapping the active segment does NOT call onChanged; (4) Semantics tree has selected:true on active segment and selected:false on all others; (5) each segment's render box height and width are ≥44 logical pixels; (6) widget renders without overflow at textScaleFactor 2.0; (7) passing a new value from outside causes the correct segment to become active. No golden tests required. Accessibility test using flutter_test's SemanticsHandle to verify Semantics labels.

Component
Time Window Selector
ui low
Epic Risks (4)
high impact high prob technical

fl_chart renders chart elements on a Canvas, making individual bars and data points invisible to the Flutter Semantics tree by default. Without explicit Semantics wrappers, VoiceOver and TalkBack users receive no chart information, violating the WCAG 2.2 AA requirement mandated by all three partner organizations.

Mitigation & Contingency

Mitigation: Wrap the fl_chart widget in a Semantics node with a dynamically generated textual description of the chart data (e.g., 'Bar chart: January 12, February 8, March 15 sessions'). Implement a collapsible data table alternative beneath the chart that screen readers can navigate row by row. Validate with VoiceOver on iOS and TalkBack on Android before the epic is marked complete.

Contingency: If fl_chart's Canvas rendering cannot be made accessible within the epic timeline, ship the chart hidden from the Semantics tree with ExcludeSemantics and promote the data table alternative to first-class UI so screen reader users have full access to the information. Log a tech-debt item to revisit native chart accessibility in a future sprint.

medium impact medium prob scope

Coordinators managing up to 5 chapters (NHF requirement) require the PeerMentorStatsList to display chapter affiliation labels for each row. With large chapter lists and many peer mentors, the list could become overwhelming and cause layout overflow or scrolling performance issues on lower-end Android devices.

Mitigation & Contingency

Mitigation: Implement chapter filtering as a segmented control above the list so coordinators can scope the list to one chapter at a time. Use ListView.builder (lazy rendering) rather than a Column of all rows. Profile scroll performance on a low-end Android device (Pixel 4a equivalent) with 50 peer mentors in scope during development.

Contingency: If multi-chapter display causes unacceptable performance, ship with single-chapter scope as the default view and a chapter switcher dropdown, deferring the combined cross-chapter list to a follow-up sprint.

low impact low prob technical

Summary cards and the chart widget rebuilding simultaneously on provider state change could cause a visible jank frame on slower devices, degrading perceived quality especially since this screen is intended to feel motivating and polished for gamification purposes.

Mitigation & Contingency

Mitigation: Use AnimatedSwitcher with a short fade transition (150ms) on the stats cards and chart so that data replacement feels intentional rather than jarring. Profile with Flutter DevTools on a mid-range device and ensure no frame exceeds 16ms during a time-window switch.

Contingency: If animation introduces complexity that delays delivery, ship without animation and use a loading skeleton (shimmer effect) during re-fetch instead, which is simpler and equally effective at masking the data swap.

high impact low prob security

If the role-based screen dispatch is misconfigured, a peer mentor could navigate to the coordinator stats screen and see aggregated chapter data for all peer mentors, which is a data privacy violation and a compliance risk for all three organizations.

Mitigation & Contingency

Mitigation: Implement role guard at the router level using an existing role-route-guard component so the coordinator screen route is unreachable for peer mentor roles. Add a widget test that mounts the coordinator screen with a peer mentor session token and asserts that the guard redirects to the no-access screen.

Contingency: If a bypass is found in QA, add a secondary in-screen role assertion in the coordinator screen's initState that throws an AuthorizationException and navigates to the error screen, ensuring defence in depth regardless of router configuration.