Enhance SettingsViewModel with State Persistence and Sign Out

This commit enriches the `SettingsViewModel` by integrating state persistence functionality and a sign-out method, thus ensuring a more robust and user-friendly settings feature.

Key Enhancements:
1. **State Persistence**:
   - Leveraging the `shared_preferences` package, the app now stores and retrieves user preferences related to app settings, ensuring consistency across app restarts.
   - Preferences like Dark Mode, Developer Mode, Base URL, and Continuous Mode Steps are persistently stored and loaded when the ViewModel is initialized.

2. **Sign Out Method**:
   - A `signOut` method has been introduced in the ViewModel, utilizing the `AuthService` to facilitate user sign-out processes.
   - This addition allows for seamless integration of sign-out functionality within the settings interface, granting users the ability to easily terminate sessions.

3. **SettingsView Enhancement**:
   - The `SettingsView` has been adapted to incorporate a UI element invoking the `signOut` method, enhancing user interaction within the settings environment.

This enhancement not only bolsters the resilience and usability of the app’s settings but also lays down a structured approach for potential future additions to user preferences and settings-related functionalities.
This commit is contained in:
hunteraraujo
2023-09-23 21:51:07 -07:00
parent 4c0349a6a8
commit a09d2a581f
2 changed files with 52 additions and 5 deletions

View File

@@ -62,6 +62,13 @@ class SettingsView extends StatelessWidget {
],
),
),
ListTile(
title: Text('Sign Out'),
onTap: () {
viewModel.signOut();
// Optionally, navigate to a different view or show a message
},
),
],
);
},