Service Layer medium complexity Shared Component mobile
0
Dependencies
1
Dependents
0
Entities
0
Integrations

Description

A Riverpod-backed service that tracks and restores per-tab navigation state using StatefulShellRoute branch navigators. Ensures users with motor fatigue never lose their place when switching between the five main sections, reducing re-navigation burden.

Feature: Navigation & Gesture Accessibility

tab-state-manager

Summaries

The Tab State Manager directly protects user retention among our core audience of people living with motor fatigue and movement impairments. When a user with limited dexterity spends significant effort navigating to a specific screen, any interruption — a phone call, a notification, switching apps — that resets their position creates real friction and frustration that drives abandonment. This component eliminates that failure mode by remembering exactly where each user was across all five application sections. The business result is lower churn, higher session completion rates, and a product that demonstrably respects the energy constraints of its users — a meaningful differentiator in the accessibility-focused app market.

Tab State Manager is a medium-complexity Riverpod service with no external dependencies, making it a relatively self-contained deliverable. Development requires solid knowledge of Flutter's StatefulShellRoute and Riverpod state management patterns. It must be delivered before any feature that relies on multi-tab navigation, as it is consumed by the accessibility layer and UI shell. Testing should cover cold-start restoration, tab-switch persistence, and edge cases like state corruption or missing snapshots.

Integration testing with real devices is advisable given the mobile-specific execution context. Risk is low but regression testing on tab navigation after any routing change is mandatory.

Tab State Manager wraps Flutter's StatefulShellRoute branch navigators with a Riverpod provider layer, maintaining a per-branch state snapshot map. The `watchTabChanges()` stream drives reactive UI updates and notifies the accessibility layer on context switches. `saveTabState()` serializes the current route stack and scroll offset per branch index; `restoreTabState()` rehydrates the navigator on tab focus. The service is marked shared and should be provided at the root widget scope via ProviderScope.

Care must be taken to invalidate stale state on logout — wire `clearTabState()` to the auth state change stream. No external dependencies keep this unit testable in isolation with mock navigators.

Responsibilities

  • Maintain a state snapshot for each of the five tab branches
  • Restore scroll position and sub-route when a tab is revisited
  • Expose current active tab index to UI components
  • Notify accessibility layer when tab context changes

Interfaces

getCurrentTabIndex()
setCurrentTabIndex(index)
saveTabState(index, routeState)
restoreTabState(index)
clearTabState(index)
watchTabChanges()
getTabBranchNavigator(index)

Relationships

Dependents (1)

Components that depend on this component

API Contract

View full contract →
REST /api/v1/tab-states 8 endpoints
GET /api/v1/tab-states
GET /api/v1/tab-states/:id
POST /api/v1/tab-states
PUT /api/v1/tab-states/:id
DELETE /api/v1/tab-states/:id
GET /api/v1/tab-states/current
+2 more