Implement organisation branding override pipeline
epic-visual-design-accessibility-theme-integration-task-006 — Implement the branding override pipeline that accepts an OrgBrandingConfig for NHF, Blindeforbundet, HLF, or Barnekreftforeningen and applies brand-specific primary colors and logo assets. Each override must be submitted as a BrandingOverrideRequest to the TokenAccessibilityEnforcer before application. Overrides that fail contrast or sizing validation must be rejected with a typed BrandingValidationError rather than silently applied.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 5 - 253 tasks
Can start after Tier 4 completes
Handles integration between different epics or system components. Requires coordination across multiple development streams.
Implementation Notes
Model BrandingOverrideRequest as an immutable value class and TokenAccessibilityEnforcer as a pure function class (no state). Use a sealed class Result
Testing Requirements
Unit tests: (1) valid NHF config passes validation and produces correct primary color in scheme, (2) low-contrast Blindeforbundet config returns BrandingValidationError with contrastFailure type, (3) invalid logo asset key returns invalidAssetKey error, (4) fallback palette is applied when validation fails, (5) switching from NHF to HLF config produces a fully different ThemeBuildResult. Integration test: mount a minimal app, inject each of the four org configs sequentially, and assert MaterialApp primary color matches expected brand color after each switch. No golden tests required at this layer — color correctness is asserted programmatically. 90% coverage on the override pipeline class.
One or more of the four partner organisations may supply brand primary colors that cannot be paired with any standard foreground at 4.5:1 contrast (for example, a mid-range hue that is too light for dark text and too dark for white text). Rejecting these colors programmatically could cause a political dispute with the organisation and delay the feature.
Mitigation & Contingency
Mitigation: Before implementation begins, run all four organisations' existing brand primary colors through the contrast-ratio-validator against both white (#FFFFFF) and a near-black (#1A1A1A). Share the results with each organisation's contact person ahead of the theme builder sprint so any problematic colors can be adjusted collaboratively with advance notice.
Contingency: If an organisation insists on a non-compliant brand color, produce a compliant near-match (lightened or darkened along the hue's luminance axis) and present both options with contrast ratio evidence. Document the adjusted token in the manifest with an explicit note that the original brand color was non-compliant, and obtain written sign-off from the organisation.
Flutter's ThemeData contains over 30 component theme properties. If the theme-builder only addresses the most common ones (Button, InputDecoration, Card) and leaves others at Flutter defaults, downstream feature teams may unknowingly use default-themed widgets that do not meet sizing or contrast requirements.
Mitigation & Contingency
Mitigation: Produce a full inventory of all ThemeData component theme properties and map each to either a token-driven override or an explicit pass-through decision documented in the theme builder code. Prioritise the inventory by frequency of use in the existing codebase (identified via Grep). Include a check in the CI lint runner that flags widgets using Flutter default component themes not covered by the theme builder.
Contingency: If the full inventory scope exceeds the sprint budget, ship with the highest-frequency components covered and add a tracked backlog item for each uncovered component theme, pairing with a temporary lint suppression comment that includes the backlog reference.