high priority low complexity frontend pending frontend specialist Tier 4

Acceptance Criteria

RecruitmentStatsWidget appears at the bottom of the scrollable content area of ReferralCodeScreen, below the share controls
A section divider or spacing separates the share controls from the stats widget visually
When the user navigates away and returns to ReferralCodeScreen, the stats provider is refreshed/invalidated to show latest data
Focus-triggered refresh is implemented using `RouteAware` or `WidgetsBindingObserver` — not a timer
A 'View details' TextButton link appears below RecruitmentStatsWidget
The 'View details' button navigates to a placeholder route (e.g., `/referral-stats-detail`) that shows a 'Coming soon' screen
The placeholder route is registered in the app router but clearly marked as a stub
The full ReferralCodeScreen scrolls correctly when content overflows the viewport
No layout overflow errors occur at minimum supported screen size (360dp wide)
Screen remains accessible: all interactive elements are reachable via keyboard/switch access traversal

Technical Requirements

frameworks
Flutter
Riverpod
apis
GoRouter or Navigator (routing)
ReferralAttributionService (via RecruitmentStatsWidget)
data models
assignment
performance requirements
Screen focus refresh invalidates the provider once — no redundant API calls on rapid back/forward navigation
security requirements
No additional security surface introduced — stats widget and routing do not expose new data beyond what RLS permits
ui components
RecruitmentStatsWidget (embedded)
Divider or SizedBox spacing
TextButton ('View details' stub link)
SingleChildScrollView or CustomScrollView wrapping entire screen content

Execution Context

Execution Tier
Tier 4

Tier 4 - 323 tasks

Can start after Tier 3 completes

Implementation Notes

Use `RouteAware` mixin on the screen's State (even if the widget is nominally StatelessWidget — wrap in a ConsumerStatefulWidget for lifecycle hooks) and call `ref.invalidate(recruitmentStatsProvider(mentorId))` in `didPopNext`. Register the screen with `RouteObserver>` in the widget tree. Wrap the entire screen body in a `SingleChildScrollView` with `physics: AlwaysScrollableScrollPhysics()` to handle content overflow. The 'View details' stub route should use GoRouter's `GoRoute` with a simple `ComingSoonScreen` widget.

Testing Requirements

Write widget tests using flutter_test. Test (1) RecruitmentStatsWidget is present in the ReferralCodeScreen widget tree, (2) 'View details' button navigates to the stub route, (3) provider invalidation is triggered on screen focus resume — mock RouteObserver and verify `ref.invalidate` or `ref.refresh` is called. Integration test: navigate away and back to ReferralCodeScreen and verify the stats provider re-fetches. Test scroll behavior at 360dp screen width to confirm no overflow.

Component
Referral Code Screen
ui medium
Epic Risks (3)
medium impact medium prob technical

QR codes rendered at the minimum 200×200 size may fail to scan under typical indoor lighting conditions on older or lower-resolution phone cameras, causing recruitment moments to fail when a peer mentor shows the screen to a prospective member.

Mitigation & Contingency

Mitigation: Set the default QR render size to 260×260 logical pixels (not the 200px minimum) and apply a high-contrast white module background. Test scan reliability on at minimum three physical devices (budget Android, mid-range Android, iPhone SE) before marking the screen as done.

Contingency: If scan reliability remains an issue, add a 'Enlarge QR' full-screen mode triggered by tapping the code, and ensure the text referral URL with copy-to-clipboard is always visible as a fallback sharing method.

high impact medium prob integration

The onboarding screen submits attribution and then hands off to an external membership registration URL (HLF's Dynamics portal or similar). If the external URL is unavailable, changes its format, or requires authentication the new member does not have, the conversion funnel is broken at its final step.

Mitigation & Contingency

Mitigation: Confirm the external registration URL and its expected query parameters with HLF's portal team before implementing the handoff. Record the pending_signup attribution event before launching the URL so data is not lost if the external site fails. Display a fallback message with contact information if the URL launch fails.

Contingency: If the external membership URL is not available at feature launch, implement a temporary form that collects name and email and stores a pending_member record in Supabase, allowing coordinators to manually complete registration while the integration is finalised.

low impact medium prob integration

Embedding the RecruitmentStatsWidget on the peer mentor home screen may conflict with existing layout components (activity summary, badge shelf), causing overflow or requiring a redesign of the home screen that is outside this epic's scope.

Mitigation & Contingency

Mitigation: Design the widget as a horizontally constrained card with a maximum height of 96dp so it can be inserted into any vertical list without overflow. Coordinate with the home screen's existing layout owners before starting the embedding task.

Contingency: If home screen embedding creates unacceptable layout conflicts, defer embedding to a separate home-screen redesign task and make the widget accessible only via the dedicated ReferralCodeScreen for the initial release.