Single-Action Screen Layout widget
epic-cognitive-accessibility-foundation-task-010 — Implement the SingleActionScreenLayout Flutter widget that enforces the one-primary-action-per-screen cognitive accessibility constraint. The layout provides a scrollable content area, a fixed bottom action zone with exactly one primary CTA and an optional secondary action, a back button (not swipe), and a page title. The layout integrates with CognitiveLoadRuleEngine to assert ≤3 choices in content area and refuses to render if more than one primary action is passed.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 2 - 518 tasks
Can start after Tier 1 completes
Implementation Notes
The widget should be a thin layout shell — it does not know what AppButton looks like internally. Accept primaryAction and secondaryAction as Widget slots (composition over configuration). Use PopScope (Flutter 3.14+) or WillPopScope (pre-3.14) with canPop: false and onPopInvoked to intercept back gesture and route to onBack callback instead of swipe. Validate choiceCount via CognitiveLoadRuleEngine.instance.validateScreen() in the initState or build method (debug mode only).
The bottom action zone should use a Column inside a Container with design token padding, a Divider at the top, and vertical arrangement: primaryAction on top, secondaryAction below with reduced prominence styling. Avoid Expanded in the action zone — use explicit sizing to prevent layout shifts. This widget will be the default layout for all activity registration wizard steps, so keep its API stable.
Testing Requirements
Widget tests with flutter_test. Golden tests: primary action only, primary + secondary action, body with 3 choices (max). Test back button tap triggers onBack callback. Test swipe-back is disabled (simulate back gesture via tester and verify no pop occurs).
Test choiceCount = 4 throws AssertionError in debug mode. Test title > 60 chars throws AssertionError. Test bottom action zone remains visible when keyboard is shown (use tester.showKeyboard() + pump). Semantics test: verify AppBar title has Semantics focus.
Test primaryAction = null throws. Golden test at font scale 1.5x to verify no overflow in action zone. No e2e tests needed.
The error message registry and help content registry both depend on bundled JSON assets loaded at startup. If asset loading fails silently (e.g. malformed JSON, missing pubspec asset declaration), the entire plain-language layer falls back to empty strings or raw error codes, breaking the accessibility guarantee app-wide.
Mitigation & Contingency
Mitigation: Implement eager validation of both assets during app initialisation with an assertion failure in debug mode and a structured error log in release mode. Add integration tests that verify asset loading in the Flutter test harness on every CI run.
Contingency: Ship a hardcoded minimum-viable fallback message set directly in Dart code so the app always has at least a safe generic message, preventing a blank or code-only error surface.
The AccessibilityDesignTokenEnforcer relies on dart_code_metrics custom lint rules. If the lint toolchain is not already configured in the project's CI pipeline, integrating a new linting plugin may cause unexpected build failures or require significant CI configuration work beyond the estimated scope.
Mitigation & Contingency
Mitigation: Audit the existing dart_code_metrics configuration in the project before starting implementation. Scope the lint rules to a separate Dart package that can be integrated incrementally, starting with the most critical rule (hard-coded colors) and adding others in subsequent iterations.
Contingency: Fall back to Flutter test-level assertions (using the cognitive-accessibility-audit utility) to catch violations in CI if the lint plugin integration is delayed, preserving enforcement coverage without blocking the epic.
WizardDraftRepository must choose between shared_preferences and Hive for local persistence. Choosing the wrong store for the data volume (e.g. shared_preferences for complex nested wizard state) can lead to serialisation bugs or performance degradation, particularly on lower-end Android devices used by some NHF members.
Mitigation & Contingency
Mitigation: Define a clean repository interface first and implement shared_preferences as the initial backend. Profile serialisation round-trip time with a realistic wizard state payload (≈10 fields) before committing to either store.
Contingency: Swap the persistence backend behind the repository interface without touching wizard UI code, which is possible precisely because the repository abstraction isolates the storage detail.
The AccessibilityDesignTokenEnforcer scope could expand significantly if a large portion of existing widgets use hard-coded values. Discovering widespread violations during this epic would force either a major refactor or a decision to exclude legacy components, potentially reducing the enforcer's coverage and value.
Mitigation & Contingency
Mitigation: Run a preliminary audit of existing widgets using a simple grep for hard-coded hex colors and raw pixel values before implementation begins. Use the results to set a realistic remediation boundary for this epic and log all out-of-scope violations as tracked tech-debt items.
Contingency: Scope the enforcer to new and modified components only (via file-path filters in dart_code_metrics config), shipping a partial but immediately valuable coverage rather than blocking the epic on full-codebase remediation.