Build location consent dialog UI widget
epic-geographic-peer-mentor-map-consent-privacy-task-006 — Implement the location-consent-dialog Flutter widget that presents a plain-language explanation of what approximate location data is collected, how it is used for mentor-matching on the map, and links to the organisation-specific privacy policy URL sourced from location-privacy-config. Dialog must include explicit Opt In and Opt Out action buttons, must not be dismissible without an explicit choice, and must meet WCAG 2.2 AA contrast and touch-target requirements.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 3 - 413 tasks
Can start after Tier 2 completes
Implementation Notes
Use Flutter's showDialog with barrierDismissible: false and wrap the dialog content in a PopScope(canPop: false) to prevent all dismissal paths. Do not use AlertDialog directly — build a custom Dialog widget to have full control over padding, button placement, and accessibility semantics. Place the Opt Out button as a TextButton (secondary) and Opt In as an ElevatedButton (primary) using the project's AppButton widget. Fetch the privacy policy URL via a Riverpod provider that reads from location-privacy-config; use .when() to show the link only when the URL is available.
Add Semantics wrappers with explicit labels on the privacy policy link and both buttons. Test on a 320px-wide device profile in flutter_test to ensure no overflow. Keep the widget stateless — lift all state to the parent using the callback pattern to make it easily testable.
Testing Requirements
Widget tests using flutter_test: render the dialog and assert both buttons are present, assert WillPopScope blocks back navigation (simulate pop and verify false returned), assert onOptIn callback fires when Opt In is tapped, assert onOptOut callback fires when Opt Out is tapped, assert privacy policy link is hidden when URL is null. Accessibility tests: use flutter_test's SemanticsHandle to verify all interactive elements have semanticsLabel set. Golden tests for light and dark mode at 1x and 2x text scale. Manual test on a physical device with VoiceOver (iOS) enabled to confirm reading order and button announcements.
Contrast ratio documented in widget test file using computed values.
If the privacy policy text or consent terms change after mentors have already opted in, existing consent records may become legally insufficient, requiring re-consent from all opted-in mentors which could temporarily reduce map coverage.
Mitigation & Contingency
Mitigation: Store a consent_version field on every consent record. Implement a consent version check in location-consent-service that compares the stored version against the current policy version from location-privacy-config and flags stale consents for re-consent prompting.
Contingency: If a policy update invalidates existing consents, suppress affected mentors from the map, queue them for re-consent notification via the existing in-app notification system, and restore map visibility only after new consent is recorded.
A poorly designed consent dialog may lead to low opt-in rates, reducing map utility for coordinators to the point where the feature delivers insufficient value to justify maintenance cost.
Mitigation & Contingency
Mitigation: Follow plain-language writing guidelines from the cognitive accessibility feature. User-test the dialog with 2-3 peer mentors from Blindeforbundet before implementation is finalised. Ensure the dialog explains the benefit to the mentor, not just the data collection facts.
Contingency: If opt-in rate after launch is below 40%, conduct a targeted usability study and iterate on dialog copy and layout. The coordinator can also send a bulk opt-in invitation notification (per the user story) to non-consenting mentors.