Toggle Between Contacts and Peer Mentors List Views
The View Switcher Widget provides a toggle control that allows users to switch between the Contacts list view and the Peer Mentors list view within the same screen. The selected view preference is persisted in local storage via Riverpod so that users return to their preferred view when they reopen the app. Both views use the same underlying Contact Repository and BLoC, but apply different data filters and card templates appropriate to each entity type. The toggle state is managed reactively, with immediate visual feedback and no full-screen reload.
User Story
Acceptance Criteria
- Given a user is on the Contacts screen, when they tap the view switcher toggle, then the list switches between Contacts and Peer Mentors views immediately
- Given a user switches to the Peer Mentors view and closes the app, when they reopen the app and navigate to Contacts, then the Peer Mentors view is still selected
- Given the Contacts view is active, when peer mentor-specific data fields are not applicable, then they are not displayed in the contact cards
- Given the Peer Mentors view is active, when peer mentor-specific fields like availability status are available, then they are shown on the peer mentor cards
- Given a screen reader user activates the view switcher, when the view changes, then the new view state is announced by the screen reader
Business Value
Coordinators regularly work with both contacts and peer mentors and need to switch between these views efficiently during their workday. Persisting the view preference reduces repetitive interactions, which is important for users with motor or cognitive challenges. The Barnekreftforeningen specifically requested the view switcher pattern, confirming its value across multiple organisations.
Components
- View Switcher Widget ui
- Contact List BLoC service
- Contacts List Screen ui
- Contact Card Widget ui