Render PeerMentorCardWidget in ContactListScreen via view switcher
epic-contact-list-management-ui-components-task-010 — Extend ContactListScreen to render PeerMentorCardWidget items when the ContactViewSwitcher is toggled to the peer mentor view. Ensure list switching is animated smoothly. When view is 'peer mentors', filter and display PeerMentorCardWidget instances from mock data. Maintain search bar functionality across both views so the debounced query filters the currently active list. Verify scroll position resets on view switch.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Introduce a ContactViewType enum (contacts | peerMentors) and add it as a field in the ContactList BLoC/Riverpod state. The filtered list logic should live in the state/notifier, not in the widget build method. Use a single ScrollController exposed via the state or passed down, and call scrollController.jumpTo(0) when the view type changes. Wrap the list with AnimatedSwitcher keyed on the view type to get a smooth crossfade.
Guard PeerMentorCardWidget rendering with a null/empty check on the peer mentor list before delegating to the empty state widget from task-009. Keep mock data consistent with the fixtures established in task-001 to avoid divergence.
Testing Requirements
Widget-test ContactListScreen with mock data for both views: (1) default state shows ContactCardWidget list, (2) toggle to peer mentor view shows PeerMentorCardWidget list, (3) toggle back restores contacts, (4) search query in peer mentor view filters PeerMentorCardWidget items by name, (5) scroll position resets after view switch. Use flutter_test WidgetTester.tap to simulate view switcher toggle. Verify widget types rendered in the list via findsNWidgets and isA
Design token color values used in role badges, certification status indicators, and availability chips may not meet the WCAG 2.2 AA contrast ratio of 4.5:1 when rendered against card backgrounds, requiring rework after accessibility review and potentially blocking acceptance sign-off.
Mitigation & Contingency
Mitigation: Run the contrast-ratio-validator on every new token combination during widget development. Enforce the CI accessibility lint runner on all PRs touching visualization components, and validate against the contrast-safe-color-palette before finalizing card designs.
Contingency: If contrast failures are found late, adjust token values in the design token theme centrally — since all widgets consume design tokens rather than hardcoded colors, all affected widgets will be corrected by a single token update without per-widget changes.
The ContactViewSwitcher is required for Barnekreftforeningen but must not appear for other organizations. If the organization labels provider does not yet expose a reliable feature flag for this widget, it may render universally or be conditionally hidden in an inconsistent way, breaking the role-specific layout contract.
Mitigation & Contingency
Mitigation: Implement view switcher visibility as a constructor parameter on ContactListScreen injected from a provider, defaulting to hidden. Document the integration point for the org labels provider so the flag can be wired without changing the widget's API.
Contingency: If org labels integration is delayed beyond this epic, use a feature flag constant keyed to the Barnekreftforeningen organization ID as a temporary gate, with a tracked issue to replace it with the runtime labels provider before general release.