Implement ContactViewSwitcher segmented toggle with org-label overrides
epic-contact-list-management-ui-components-task-007 — Build the ContactViewSwitcher as a segmented control widget (SegmentedButton or equivalent) with two or more toggle options. Default label values are 'Contacts' and 'Peer Mentors'. Accept an optional label-override map from the org-labels provider so Barnekreftforeningen and other organizations can substitute terminology (e.g., 'Members' / 'Mentors'). Expose a selectedView ValueNotifier and an onChanged callback. The widget visibility is controlled by a parent-provided boolean flag.
Acceptance Criteria
Technical Requirements
Implementation Notes
Use Flutter's built-in SegmentedButton
defaultLabel. This keeps the build method clean. For visibility, prefer using a conditional expression (if visible widget else const SizedBox.shrink()) over Visibility widget to fully remove the widget from the tree when hidden — this is important for layout so it does not occupy space. The parent (ContactListScreen) is responsible for reading the org-labels provider and passing the override map down as a parameter.
Testing Requirements
Write flutter_test widget tests: (1) render with no label overrides and assert default 'Contacts' and 'Peer Mentors' text appears; (2) render with an override map {'contacts': 'Members', 'peerMentors': 'Mentors'} and assert overridden labels appear; (3) tap each segment and assert onChanged fires with the correct ContactViewType value; (4) render with visible: false and assert the widget is not present in the widget tree (findsNothing); (5) render with visible: true and assert the widget is present; (6) provide an unexpected key in the override map and assert no exception is thrown and default labels fall back correctly; (7) assert Semantics nodes for each segment carry correct label and isSelected state.
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.