mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 12:07:58 -06:00
feat: view type stored in view/cubit, itself, cleanup coe
This commit is contained in:
39
lib/features/login/cubit/authentication_state.dart
Normal file
39
lib/features/login/cubit/authentication_state.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
part of 'authentication_cubit.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class AuthenticationState {
|
||||
final bool wasLoginStored;
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
final bool? wasLocalAuthenticationSuccessful;
|
||||
final AuthenticationInformation? authentication;
|
||||
|
||||
static final AuthenticationState initial = AuthenticationState(
|
||||
wasLoginStored: false,
|
||||
);
|
||||
|
||||
bool get isAuthenticated => authentication != null;
|
||||
AuthenticationState({
|
||||
required this.wasLoginStored,
|
||||
this.wasLocalAuthenticationSuccessful,
|
||||
this.authentication,
|
||||
});
|
||||
|
||||
AuthenticationState copyWith({
|
||||
bool? wasLoginStored,
|
||||
bool? isAuthenticated,
|
||||
AuthenticationInformation? authentication,
|
||||
bool? wasLocalAuthenticationSuccessful,
|
||||
}) {
|
||||
return AuthenticationState(
|
||||
wasLoginStored: wasLoginStored ?? this.wasLoginStored,
|
||||
authentication: authentication ?? this.authentication,
|
||||
wasLocalAuthenticationSuccessful: wasLocalAuthenticationSuccessful ??
|
||||
this.wasLocalAuthenticationSuccessful,
|
||||
);
|
||||
}
|
||||
|
||||
factory AuthenticationState.fromJson(Map<String, dynamic> json) =>
|
||||
_$AuthenticationStateFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AuthenticationStateToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user