Update .gitignore to exclude Firebase configuration files and refactor notification handling in the app. Removed redundant logging and notification data storage in SharedPreferences. Introduced NotificationCheckService and NotificationStateService for improved notification management. Updated view models and UI components to utilize the new services, enhancing notification state tracking and user experience.

This commit is contained in:
amirrezaghabeli
2025-10-06 11:59:54 +03:30
parent 17634744f7
commit 42f2e93a8e
28 changed files with 1499 additions and 595 deletions
+9 -9
View File
@@ -3,11 +3,14 @@ import 'package:tm_app/data/services/model/customer/customer.dart';
import 'package:tm_app/data/services/model/forgot_password_response/forgot_password_response_model.dart';
import 'package:tm_app/data/services/model/verify_otp_response/verify_otp_response_model.dart';
import '../core/utils/error_utils.dart';
import '../core/utils/logger.dart';
import '../core/utils/result.dart';
import '../data/repositories/auth_repository.dart';
import '../data/services/model/login_response/login_response_model.dart';
import '../data/services/model/logout_response/logout_response.dart';
import '../data/services/model/reset_password_response/reset_password_response.dart';
import '../views/forget_password_create/strings/forgot_password_create_strings.dart';
class AuthViewModel with ChangeNotifier {
final AuthRepository _authRepository;
@@ -139,9 +142,6 @@ class AuthViewModel with ChangeNotifier {
}
_isLoading = false;
notifyListeners();
// reset error after notify
_errorMessage = null;
notifyListeners();
}
@@ -151,6 +151,7 @@ class AuthViewModel with ChangeNotifier {
await _authRepository.localLogout();
} catch (e) {
// Handle local logout exceptions gracefully
AppLogger().error('❌ Failed to local logout: $e');
}
_loggedInUser = null;
notifyListeners();
@@ -177,7 +178,7 @@ class AuthViewModel with ChangeNotifier {
notifyListeners();
}
Future<void> forgotPassword(BuildContext context) async {
Future<void> forgotPassword() async {
_isLoadingForgot = true;
_errorMessageForget = null;
successMessage = null;
@@ -214,7 +215,7 @@ class AuthViewModel with ChangeNotifier {
notifyListeners();
}
Future<void> verifyOtp(BuildContext context) async {
Future<void> verifyOtp() async {
_isLoadingOtp = true;
_errorMessageOtp = null;
_verifyOtpSuccess = false;
@@ -273,16 +274,16 @@ class AuthViewModel with ChangeNotifier {
_resetPasswordSuccess = true;
break;
case Error<ResetPasswordResponse>():
_resetPasswordErrorMessage = result.error.toString();
_resetPasswordErrorMessage = ErrorUtils.getErrorMessage(result.error);
_resetPasswordSuccess = false;
break;
}
_isResetPasswordLoading = false;
notifyListeners();
_resetPasswordErrorMessage = null;
notifyListeners();
} else {
_resetPasswordErrorMessage = 'Reset token is required';
_resetPasswordErrorMessage =
ForgotPasswordCreateStrings.passwordResetFailed;
_isResetPasswordLoading = false;
notifyListeners();
}
@@ -325,7 +326,6 @@ class AuthViewModel with ChangeNotifier {
emailController.dispose();
newPasswordController.dispose();
otpController.dispose();
usernameFocus.dispose();
passwordFocus.dispose();
emailFocus.dispose();