2025-09-18 09:31:42 +07:00
|
|
|
part of 'auth_bloc.dart';
|
|
|
|
|
|
|
|
|
|
@freezed
|
2026-10-01 01:43:22 +07:00
|
|
|
abstract class AuthState with _$AuthState {
|
2025-09-18 09:31:42 +07:00
|
|
|
const AuthState._();
|
|
|
|
|
|
|
|
|
|
const factory AuthState({
|
|
|
|
|
required User user,
|
|
|
|
|
@Default(AuthStatus.initial()) AuthStatus status,
|
|
|
|
|
required Option<AuthFailure> failureOption,
|
|
|
|
|
@Default(false) bool isFetching,
|
|
|
|
|
}) = _AuthState;
|
|
|
|
|
|
|
|
|
|
factory AuthState.initial() =>
|
|
|
|
|
AuthState(user: User.empty(), failureOption: none());
|
|
|
|
|
|
|
|
|
|
bool get isAuthenticated => status == const AuthStatus.authenticated();
|
|
|
|
|
bool get isInitial => status == const AuthStatus.initial();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@freezed
|
|
|
|
|
sealed class AuthStatus with _$AuthStatus {
|
|
|
|
|
const factory AuthStatus.authenticated() = _Authenticated;
|
|
|
|
|
const factory AuthStatus.unauthenticated() = _Unauthenticated;
|
|
|
|
|
const factory AuthStatus.initial() = _Initial;
|
|
|
|
|
}
|