mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 01:07:55 +00:00
Refactor code for consistency and readability
- Removed unused imports and commented-out code - Updated class inheritance for AuthState subclasses - Reorganized code structure for better readability - Cleaned up debug print statements and replaced with dart:developer logs
This commit is contained in:
@@ -4,30 +4,44 @@ abstract class AuthState {}
|
||||
|
||||
class AuthInitial extends AuthState {}
|
||||
|
||||
//base states
|
||||
class AuthLoading extends AuthState {}
|
||||
|
||||
class AuthError extends AuthState {
|
||||
final String message;
|
||||
|
||||
AuthError(this.message) {
|
||||
debugPrint(message);
|
||||
}
|
||||
String? code;
|
||||
AuthError({required this.message, this.code});
|
||||
}
|
||||
|
||||
class AuthSuccess extends AuthState {}
|
||||
|
||||
class AuthLoggedOut extends AuthState {}
|
||||
//user log states
|
||||
class AuthLoginLoading extends AuthLoading {}
|
||||
|
||||
class AuthLoginSuccess extends AuthSuccess {}
|
||||
|
||||
class AuthLoginError extends AuthError {
|
||||
AuthLoginError({required super.message, super.code});
|
||||
}
|
||||
|
||||
class AuthLogoutLoading extends AuthLoading {}
|
||||
|
||||
class AuthLogoutSuccess extends AuthSuccess {}
|
||||
|
||||
class AuthLogoutError extends AuthError {
|
||||
AuthLogoutError({required super.message, super.code});
|
||||
}
|
||||
|
||||
// UI states
|
||||
class AuthPasswordVisibilityChanged extends AuthState {}
|
||||
|
||||
class AuthAgreeToTermsChanged extends AuthState {}
|
||||
|
||||
class AuthTokenLoading extends AuthState {}
|
||||
//token states
|
||||
class AuthTokenLoading extends AuthLoading {}
|
||||
|
||||
class AuthTokenSuccess extends AuthState {}
|
||||
class AuthTokenSuccess extends AuthSuccess {}
|
||||
|
||||
class AuthTokenError extends AuthState {
|
||||
final String message;
|
||||
|
||||
AuthTokenError(this.message);
|
||||
class AuthTokenError extends AuthError {
|
||||
AuthTokenError({required super.message, super.code});
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ class LoginView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO move to strings manager
|
||||
|
||||
return BlocConsumer<AuthCubit, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthError) {
|
||||
@@ -28,8 +26,8 @@ class LoginView extends StatelessWidget {
|
||||
content: Text(state.message),
|
||||
),
|
||||
);
|
||||
} else if (state is AuthSuccess) {
|
||||
Navigator.popAndPushNamed(context, Routes.homeRoute);
|
||||
} else if (state is AuthLoginSuccess) {
|
||||
Navigator.pushNamed(context, Routes.homeRoute);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
|
||||
Reference in New Issue
Block a user