feedback models added

This commit is contained in:
amirrezaghabeli
2025-08-17 12:29:12 +03:30
parent dfe3e21068
commit 5bb7326c76
21 changed files with 1969 additions and 94 deletions
+25
View File
@@ -4,6 +4,7 @@ import 'package:tm_app/data/services/model/profile_data/profile_data.dart';
import '../core/utils/result.dart';
import '../data/repositories/profile_repository.dart';
import '../data/services/model/logout_response/logout_response.dart';
import '../data/services/model/profile_response/profile_response.dart';
class ProfileViewModel with ChangeNotifier {
@@ -21,8 +22,10 @@ class ProfileViewModel with ChangeNotifier {
bool _isLoading = false;
String? _errorMessage;
ProfileData? _profileData;
bool _loggedOut = false;
bool get isLoading => _isLoading;
bool get loggedOut => _loggedOut;
String? get errorMessage => _errorMessage;
ProfileData? get profileData => _profileData;
@@ -46,4 +49,26 @@ class ProfileViewModel with ChangeNotifier {
_errorMessage = null;
notifyListeners();
}
Future<void> localLogout() async {
await _authRepository.localLogout();
_loggedOut = true;
}
Future<void> logout() async {
_errorMessage = null;
notifyListeners();
final result = await _authRepository.logout();
switch (result) {
case Ok<LogoutResponse>():
await localLogout();
break;
case Error<LogoutResponse>():
_errorMessage = result.error.toString();
break;
}
_errorMessage = null;
notifyListeners();
}
}