Scaffold in-app notification banner widget
epic-scenario-push-engagement-ui-task-004 — Create the in-app-notification-banner widget as an overlay positioned at the top of the current screen. Implement the visual structure: icon, scenario title, short message, and dismiss button. Apply design token colours ensuring WCAG 2.2 AA contrast ratios. Support both light and dark themes via the design token provider.
Acceptance Criteria
Technical Requirements
Implementation Notes
Define a ScenarioNotificationBannerData value object (title, message, iconKey) to decouple the widget from any service types. Use AnimatedPositioned or SlideTransition for the enter/exit animation (slide down from top, 200ms ease-in-out) — this can be wired in this task even if the trigger logic comes in the next task, using a visible boolean parameter. Use Theme.of(context).extension
Do not place overlay management logic inside this widget — the widget only renders; a separate controller handles insertion/removal of the OverlayEntry.
Testing Requirements
Write widget tests: render banner with sample data in light theme and assert all four elements (icon, title, message, dismiss button) are present in the widget tree. Render in dark theme and assert background colour token differs. Test overflow: provide a 200-character title and assert it truncates with ellipsis and does not cause a RenderFlex overflow. Test dismiss button tap: assert onDismiss callback is called.
Write golden tests for light and dark themes at font scales 1.0 and 1.5. Manually verify WCAG contrast ratios using the Flutter DevTools accessibility checker or a colour contrast tool before marking the task complete.
The in-app notification banner depends on a Supabase Realtime subscription to detect new notification records. If the subscription reconnects slowly after an app resume from background, or if Realtime delivery is delayed under high load, the banner may not appear within the 2-second acceptance criterion.
Mitigation & Contingency
Mitigation: Implement an explicit subscription reconnect handler on app foreground events using Flutter's AppLifecycleState.resumed hook, and add a polling fallback that queries for unread notifications once per app foreground event as a safety net against missed Realtime events.
Contingency: If Realtime proves unreliable in production, promote the polling fallback to the primary mechanism with a 30-second interval, accepting slight latency in exchange for reliability.
Cold-start deep linking (app not running when push notification is tapped) requires deferred navigation after the Flutter engine and Supabase session are fully initialised. If the deep link is consumed before authentication completes, the router may navigate to a protected route without a valid session, causing an error or redirect loop.
Mitigation & Contingency
Mitigation: Implement a deferred navigation queue in scenario-deep-link-router that holds the parsed deep-link target until the auth session restoration lifecycle event fires, following the existing deep-link-handler pattern used in the BankID and Vipps authentication flows.
Contingency: If deferred navigation is not achievable within the epic's scope, fall back to navigating the user to the notification centre (which is always accessible post-login) where the relevant notification record is visible and tappable.