2026-04-20 23:52:00 +02:00
|
|
|
part of 'auth_cubit.dart';
|
2026-04-06 10:55:56 +02:00
|
|
|
|
2026-04-20 23:52:00 +02:00
|
|
|
enum AuthStatus { initial, loading, failure }
|
2026-04-06 10:55:56 +02:00
|
|
|
|
|
|
|
|
class AuthState extends Equatable {
|
|
|
|
|
final AuthStatus status;
|
|
|
|
|
final bool isLoginMode;
|
2026-04-20 23:52:00 +02:00
|
|
|
final String? errorMessage;
|
|
|
|
|
final String? infoMessage;
|
2026-04-06 10:55:56 +02:00
|
|
|
|
2026-04-20 23:52:00 +02:00
|
|
|
const AuthState({
|
|
|
|
|
this.status = AuthStatus.initial,
|
|
|
|
|
this.isLoginMode = true,
|
|
|
|
|
this.errorMessage,
|
|
|
|
|
this.infoMessage,
|
|
|
|
|
});
|
2026-04-06 10:55:56 +02:00
|
|
|
|
2026-04-20 23:52:00 +02:00
|
|
|
AuthState copyWith({
|
|
|
|
|
AuthStatus? status,
|
|
|
|
|
bool? isLoginMode,
|
|
|
|
|
String? errorMessage,
|
|
|
|
|
String? infoMessage,
|
|
|
|
|
}) {
|
2026-04-06 10:55:56 +02:00
|
|
|
return AuthState(
|
|
|
|
|
status: status ?? this.status,
|
|
|
|
|
isLoginMode: isLoginMode ?? this.isLoginMode,
|
2026-04-20 23:52:00 +02:00
|
|
|
// Se non passo esplicitamente un errore, lo resetto per evitare che rimanga bloccato a schermo
|
|
|
|
|
errorMessage: errorMessage,
|
|
|
|
|
infoMessage: infoMessage,
|
2026-04-06 10:55:56 +02:00
|
|
|
);
|
|
|
|
|
}
|
2026-04-20 23:52:00 +02:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<Object?> get props => [status, isLoginMode, errorMessage, infoMessage];
|
2026-04-06 10:55:56 +02:00
|
|
|
}
|