Add WCAG 2.2 AA accessibility to Notification Card
epic-scenario-based-follow-up-prompts-scheduler-and-ui-task-014 — Audit and enhance the ScenarioPromptNotificationCard for WCAG 2.2 AA compliance: add Semantics wrappers with descriptive labels for screen readers, ensure CTA button meets 44x44dp touch target, verify contrast ratios for all text and badge colors against the dark background, and add live region announcements for dynamic state changes.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 7 - 84 tasks
Can start after Tier 6 completes
Implementation Notes
Use Flutter's Semantics widget with label, hint, and button role for the CTA. Wrap the entire card in MergeSemantics only if the card should be read as a single unit; otherwise keep individual Semantics nodes for finer screen-reader control. For live regions, call SemanticsService.announce(label, TextDirection.ltr) inside a post-frame callback when the prompt state changes. To fix contrast: pull color values from the existing design token system (do not hardcode) and verify token values against the dark background — if a token fails, update the token value rather than overriding locally.
For touch targets smaller than 44dp, wrap with a SizedBox(width: 44, height: 44) and use Semantics with onTap, or add padding inside the button widget. Use the Flutter Accessibility Scanner during manual testing on a physical device. Avoid setting excludeSemantics on non-decorative content.
Testing Requirements
Write or update widget tests in flutter_test: (1) call tester.ensureSemantics() before pumping the widget; (2) verify SemanticsNode tree contains expected labels for title, CTA, and dismiss using find.bySemanticsLabel; (3) assert hit-test area of CTA button is >= 44x44dp by inspecting RenderBox size; (4) simulate dynamic state change and assert SemanticsService.announce was called. Run flutter analyze --no-pub to catch any Semantics API misuse. No golden tests required for this task.
If the scheduler runs concurrently (e.g., two overlapping cron invocations due to edge function retry), duplicate prompts could be dispatched before the first run's history records are committed, breaking the deduplication guarantee.
Mitigation & Contingency
Mitigation: Use a Postgres advisory lock or unique constraint on (user_id, scenario_id, activity_ref) in the prompt history table to make concurrent writes idempotent; design the scheduler to check history inside a transaction.
Contingency: If concurrency issues persist in production, add a distributed lock via Supabase Edge Function concurrency limit (max_instances=1) for the evaluation function as a hard guard.
Coordinators may find scenario configuration unclear if trigger conditions are expressed as raw JSON or technical terminology, leading to misconfiguration and irrelevant prompts being sent to peer mentors.
Mitigation & Contingency
Mitigation: Design the ScenarioConfigurationScreen to display human-readable descriptions of each template's trigger condition (e.g., 'Send 3 days after first contact if wellbeing concern was flagged') rather than raw rule properties; validate with an HLF coordinator in a design review before implementation.
Contingency: If coordinators still misconfigure rules after launch, add a preview mode that shows a simulated prompt based on a test activity before the rule is enabled.