Implement AccessibleBottomNavigation labels and selected state
epic-screen-reader-support-complex-widgets-task-006 — Build the AccessibleBottomNavigation overlay widget that wraps the existing bottom navigation bar. Assign explicit semantic labels to all five tab items (Home, Contacts, Add, Work, Notifications), expose the currently selected tab's state via Semantics.selected, and provide tooltip/hint strings describing each tab's function for screen reader users who may not see icons.
Acceptance Criteria
Technical Requirements
Implementation Notes
Wrap each existing BottomNavigationBarItem using a Semantics widget. Use MergeSemantics to combine icon and text into a single semantics node so VoiceOver reads them as one element rather than two. Set Semantics(button: true, selected: isSelected, label: label, hint: hint) on each tab. For the 'Add activity' tab, override the button semantics with Semantics(button: true, label: 'Add activity', hint: 'Opens a menu to create a new activity or event') — it is functionally a button/menu trigger, not a navigation tab.
For notification count: read the unread count from a Riverpod provider that queries the notifications stream; interpolate into the label as 'Notifications, $count unread' when count > 0. The OrgLabelResolver maps tab identifiers to org-specific strings using the existing organisation labels system documented in CLAUDE.md. Important: do not hardcode label strings — store in the localisation arb file so Norwegian translations are supported. The underlying StatefulShellRoute already handles tab state persistence — this widget only wraps the semantics layer.
Testing Requirements
Widget tests: mount AccessibleBottomNavigation with a mock nav state; assert Semantics.selected is true for the active tab and false for all others after each tab switch. Assert all 5 tab labels are present in the semantics tree. Assert hint strings are present. Simulate tab index change and verify selected state updates correctly.
Test with notification badge count of 0, 1, and 99+. Test with an org that overrides the 'Contacts' label to 'Members' and assert the semantic label updates. Accessibility audit: run flutter_test semanticsTester to verify no duplicate labels, no unlabelled interactive elements in the nav bar. Run on physical iOS device with VoiceOver enabled for final validation.
Coverage target: 90%.
Flutter does not natively enforce a focus trap within a bottom sheet or modal dialog in the semantic tree — VoiceOver and TalkBack can navigate outside the sheet to background content. Implementing a reliable focus trap requires overriding the semantic tree, which may conflict with the existing modal helper infrastructure in the app and require changes to shared components beyond this feature's scope.
Mitigation & Contingency
Mitigation: Prototype the focus trap on the first modal sheet implementation before building the remaining sheets. Evaluate Flutter's ExcludeSemantics and BlockSemantics widgets as the trap mechanism, and coordinate with the team owning the shared modal helpers to agree on a non-breaking integration point before writing production code.
Contingency: If a complete semantic focus trap cannot be implemented without breaking existing modal patterns, implement a partial solution using FocusScope with autofocus on the modal's first element and a prominent 'Return to main content' semantic action, documenting the deviation from WCAG 2.4.3 with a scheduled remediation item.
The activity wizard uses BLoC state management and the UI rebuilds the entire step widget subtree on transition. If the semantic tree is traversed by VoiceOver before the build cycle settles, focus may land on a stale or partially rendered step, causing the wrong step label or progress value to be announced. This is particularly problematic for blind users who cannot visually verify the announcement against the screen.
Mitigation & Contingency
Mitigation: Coordinate ActivityWizardStepSemantics with FocusManagementService (from the core services epic) to delay focus placement until the post-build callback confirms the new step's semantic tree is complete. Write integration tests using the AccessibilityTestHarness that assert the full announcement sequence across all five wizard steps.
Contingency: If post-build focus delay is insufficient due to async BLoC emission timing, add an explicit semantic notification barrier in the wizard cubit that emits a 'step ready' event only after the new widget tree has been marked as built, decoupling the announcement trigger from the raw state transition.
Automated WCAG contrast ratio checking on widget tree snapshots may produce false positives for gradient backgrounds, dark-mode overrides, or design token overrides that are resolved at runtime but appear as unresolvable colours at static analysis time. Excessive false positives would erode team trust in the CI gate, leading to suppression rules that also mask real violations.
Mitigation & Contingency
Mitigation: Scope the WCAGComplianceChecker to check only solid-colour backgrounds in the first iteration, explicitly excluding gradients from contrast checks with documented rationale. Design the check output to distinguish 'undetermined' (gradient/unknown) from 'fail' (solid colour below threshold) so the team can take targeted action on genuine failures only.
Contingency: If false positive rates exceed 20% of reported violations during initial CI runs, switch the CI gate from a hard build failure to a warning annotation on the pull request, combined with a mandatory manual review step, until the checker's rule set has been tuned to match actual design token values.