Set Password Repo

This commit is contained in:
efrilm
2025-09-18 06:57:08 +07:00
parent c40f96fc88
commit 1a0c0cf49b
16 changed files with 2453 additions and 0 deletions
@@ -0,0 +1,81 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart';
part 'set_password_form_event.dart';
part 'set_password_form_state.dart';
part 'set_password_form_bloc.freezed.dart';
@injectable
class SetPasswordFormBloc
extends Bloc<SetPasswordFormEvent, SetPasswordFormState> {
final IAuthRepository _repository;
SetPasswordFormBloc(this._repository)
: super(SetPasswordFormState.initial()) {
on<SetPasswordFormEvent>(_onSetPasswordFormEvent);
}
Future<void> _onSetPasswordFormEvent(
SetPasswordFormEvent event,
Emitter<SetPasswordFormState> emit,
) {
return event.map(
registrationTokenChanged: (e) async {
emit(
state.copyWith(
registrationToken: e.registrationToken,
failureOrSetPasswordOption: none(),
),
);
},
passwordChanged: (e) async {
emit(
state.copyWith(
password: e.password,
failureOrSetPasswordOption: none(),
),
);
},
confirmPasswordChanged: (e) async {
emit(
state.copyWith(
confirmPassword: e.confirmPassword,
failureOrSetPasswordOption: none(),
),
);
},
submitted: (e) async {
Either<AuthFailure, Login>? failureOrSetPassword;
emit(
state.copyWith(
isSubmitting: true,
failureOrSetPasswordOption: none(),
),
);
final registrationTokenValid = state.registrationToken.isNotEmpty;
final passwordValid = state.password.isNotEmpty;
final confirmPasswordValid = state.confirmPassword.isNotEmpty;
if (registrationTokenValid && passwordValid && confirmPasswordValid) {
failureOrSetPassword = await _repository.setPassword(
registrationToken: state.registrationToken,
password: state.password,
confirmPassword: state.confirmPassword,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrSetPasswordOption: optionOf(failureOrSetPassword),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}
@@ -0,0 +1,980 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'set_password_form_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$SetPasswordFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SetPasswordFormEventCopyWith<$Res> {
factory $SetPasswordFormEventCopyWith(
SetPasswordFormEvent value,
$Res Function(SetPasswordFormEvent) then,
) = _$SetPasswordFormEventCopyWithImpl<$Res, SetPasswordFormEvent>;
}
/// @nodoc
class _$SetPasswordFormEventCopyWithImpl<
$Res,
$Val extends SetPasswordFormEvent
>
implements $SetPasswordFormEventCopyWith<$Res> {
_$SetPasswordFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$RegistrationTokenChangedImplCopyWith<$Res> {
factory _$$RegistrationTokenChangedImplCopyWith(
_$RegistrationTokenChangedImpl value,
$Res Function(_$RegistrationTokenChangedImpl) then,
) = __$$RegistrationTokenChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String registrationToken});
}
/// @nodoc
class __$$RegistrationTokenChangedImplCopyWithImpl<$Res>
extends
_$SetPasswordFormEventCopyWithImpl<$Res, _$RegistrationTokenChangedImpl>
implements _$$RegistrationTokenChangedImplCopyWith<$Res> {
__$$RegistrationTokenChangedImplCopyWithImpl(
_$RegistrationTokenChangedImpl _value,
$Res Function(_$RegistrationTokenChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? registrationToken = null}) {
return _then(
_$RegistrationTokenChangedImpl(
null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$RegistrationTokenChangedImpl implements _RegistrationTokenChanged {
const _$RegistrationTokenChangedImpl(this.registrationToken);
@override
final String registrationToken;
@override
String toString() {
return 'SetPasswordFormEvent.registrationTokenChanged(registrationToken: $registrationToken)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$RegistrationTokenChangedImpl &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken));
}
@override
int get hashCode => Object.hash(runtimeType, registrationToken);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
get copyWith =>
__$$RegistrationTokenChangedImplCopyWithImpl<
_$RegistrationTokenChangedImpl
>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return registrationTokenChanged(registrationToken);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return registrationTokenChanged?.call(registrationToken);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (registrationTokenChanged != null) {
return registrationTokenChanged(registrationToken);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return registrationTokenChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return registrationTokenChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (registrationTokenChanged != null) {
return registrationTokenChanged(this);
}
return orElse();
}
}
abstract class _RegistrationTokenChanged implements SetPasswordFormEvent {
const factory _RegistrationTokenChanged(final String registrationToken) =
_$RegistrationTokenChangedImpl;
String get registrationToken;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$PasswordChangedImplCopyWith<$Res> {
factory _$$PasswordChangedImplCopyWith(
_$PasswordChangedImpl value,
$Res Function(_$PasswordChangedImpl) then,
) = __$$PasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String password});
}
/// @nodoc
class __$$PasswordChangedImplCopyWithImpl<$Res>
extends _$SetPasswordFormEventCopyWithImpl<$Res, _$PasswordChangedImpl>
implements _$$PasswordChangedImplCopyWith<$Res> {
__$$PasswordChangedImplCopyWithImpl(
_$PasswordChangedImpl _value,
$Res Function(_$PasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? password = null}) {
return _then(
_$PasswordChangedImpl(
null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$PasswordChangedImpl implements _PasswordChanged {
const _$PasswordChangedImpl(this.password);
@override
final String password;
@override
String toString() {
return 'SetPasswordFormEvent.passwordChanged(password: $password)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PasswordChangedImpl &&
(identical(other.password, password) ||
other.password == password));
}
@override
int get hashCode => Object.hash(runtimeType, password);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
__$$PasswordChangedImplCopyWithImpl<_$PasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return passwordChanged(password);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return passwordChanged?.call(password);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (passwordChanged != null) {
return passwordChanged(password);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return passwordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return passwordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (passwordChanged != null) {
return passwordChanged(this);
}
return orElse();
}
}
abstract class _PasswordChanged implements SetPasswordFormEvent {
const factory _PasswordChanged(final String password) = _$PasswordChangedImpl;
String get password;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$ConfirmPasswordChangedImplCopyWith<$Res> {
factory _$$ConfirmPasswordChangedImplCopyWith(
_$ConfirmPasswordChangedImpl value,
$Res Function(_$ConfirmPasswordChangedImpl) then,
) = __$$ConfirmPasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String confirmPassword});
}
/// @nodoc
class __$$ConfirmPasswordChangedImplCopyWithImpl<$Res>
extends
_$SetPasswordFormEventCopyWithImpl<$Res, _$ConfirmPasswordChangedImpl>
implements _$$ConfirmPasswordChangedImplCopyWith<$Res> {
__$$ConfirmPasswordChangedImplCopyWithImpl(
_$ConfirmPasswordChangedImpl _value,
$Res Function(_$ConfirmPasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? confirmPassword = null}) {
return _then(
_$ConfirmPasswordChangedImpl(
null == confirmPassword
? _value.confirmPassword
: confirmPassword // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$ConfirmPasswordChangedImpl implements _ConfirmPasswordChanged {
const _$ConfirmPasswordChangedImpl(this.confirmPassword);
@override
final String confirmPassword;
@override
String toString() {
return 'SetPasswordFormEvent.confirmPasswordChanged(confirmPassword: $confirmPassword)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ConfirmPasswordChangedImpl &&
(identical(other.confirmPassword, confirmPassword) ||
other.confirmPassword == confirmPassword));
}
@override
int get hashCode => Object.hash(runtimeType, confirmPassword);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ConfirmPasswordChangedImplCopyWith<_$ConfirmPasswordChangedImpl>
get copyWith =>
__$$ConfirmPasswordChangedImplCopyWithImpl<_$ConfirmPasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return confirmPasswordChanged(confirmPassword);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return confirmPasswordChanged?.call(confirmPassword);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (confirmPasswordChanged != null) {
return confirmPasswordChanged(confirmPassword);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return confirmPasswordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return confirmPasswordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (confirmPasswordChanged != null) {
return confirmPasswordChanged(this);
}
return orElse();
}
}
abstract class _ConfirmPasswordChanged implements SetPasswordFormEvent {
const factory _ConfirmPasswordChanged(final String confirmPassword) =
_$ConfirmPasswordChangedImpl;
String get confirmPassword;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ConfirmPasswordChangedImplCopyWith<_$ConfirmPasswordChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$SetPasswordFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'SetPasswordFormEvent.submitted()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements SetPasswordFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$SetPasswordFormState {
String get registrationToken => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
String get confirmPassword => throw _privateConstructorUsedError;
Option<Either<AuthFailure, Login>> get failureOrSetPasswordOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SetPasswordFormStateCopyWith<SetPasswordFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SetPasswordFormStateCopyWith<$Res> {
factory $SetPasswordFormStateCopyWith(
SetPasswordFormState value,
$Res Function(SetPasswordFormState) then,
) = _$SetPasswordFormStateCopyWithImpl<$Res, SetPasswordFormState>;
@useResult
$Res call({
String registrationToken,
String password,
String confirmPassword,
Option<Either<AuthFailure, Login>> failureOrSetPasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$SetPasswordFormStateCopyWithImpl<
$Res,
$Val extends SetPasswordFormState
>
implements $SetPasswordFormStateCopyWith<$Res> {
_$SetPasswordFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? registrationToken = null,
Object? password = null,
Object? confirmPassword = null,
Object? failureOrSetPasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
confirmPassword: null == confirmPassword
? _value.confirmPassword
: confirmPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrSetPasswordOption: null == failureOrSetPasswordOption
? _value.failureOrSetPasswordOption
: failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Login>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$SetPasswordFormStateImplCopyWith<$Res>
implements $SetPasswordFormStateCopyWith<$Res> {
factory _$$SetPasswordFormStateImplCopyWith(
_$SetPasswordFormStateImpl value,
$Res Function(_$SetPasswordFormStateImpl) then,
) = __$$SetPasswordFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String registrationToken,
String password,
String confirmPassword,
Option<Either<AuthFailure, Login>> failureOrSetPasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$SetPasswordFormStateImplCopyWithImpl<$Res>
extends _$SetPasswordFormStateCopyWithImpl<$Res, _$SetPasswordFormStateImpl>
implements _$$SetPasswordFormStateImplCopyWith<$Res> {
__$$SetPasswordFormStateImplCopyWithImpl(
_$SetPasswordFormStateImpl _value,
$Res Function(_$SetPasswordFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? registrationToken = null,
Object? password = null,
Object? confirmPassword = null,
Object? failureOrSetPasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$SetPasswordFormStateImpl(
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
confirmPassword: null == confirmPassword
? _value.confirmPassword
: confirmPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrSetPasswordOption: null == failureOrSetPasswordOption
? _value.failureOrSetPasswordOption
: failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Login>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$SetPasswordFormStateImpl implements _SetPasswordFormState {
const _$SetPasswordFormStateImpl({
required this.registrationToken,
required this.password,
required this.confirmPassword,
required this.failureOrSetPasswordOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String registrationToken;
@override
final String password;
@override
final String confirmPassword;
@override
final Option<Either<AuthFailure, Login>> failureOrSetPasswordOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'SetPasswordFormState(registrationToken: $registrationToken, password: $password, confirmPassword: $confirmPassword, failureOrSetPasswordOption: $failureOrSetPasswordOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SetPasswordFormStateImpl &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken) &&
(identical(other.password, password) ||
other.password == password) &&
(identical(other.confirmPassword, confirmPassword) ||
other.confirmPassword == confirmPassword) &&
(identical(
other.failureOrSetPasswordOption,
failureOrSetPasswordOption,
) ||
other.failureOrSetPasswordOption ==
failureOrSetPasswordOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
registrationToken,
password,
confirmPassword,
failureOrSetPasswordOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SetPasswordFormStateImplCopyWith<_$SetPasswordFormStateImpl>
get copyWith =>
__$$SetPasswordFormStateImplCopyWithImpl<_$SetPasswordFormStateImpl>(
this,
_$identity,
);
}
abstract class _SetPasswordFormState implements SetPasswordFormState {
const factory _SetPasswordFormState({
required final String registrationToken,
required final String password,
required final String confirmPassword,
required final Option<Either<AuthFailure, Login>>
failureOrSetPasswordOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$SetPasswordFormStateImpl;
@override
String get registrationToken;
@override
String get password;
@override
String get confirmPassword;
@override
Option<Either<AuthFailure, Login>> get failureOrSetPasswordOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SetPasswordFormStateImplCopyWith<_$SetPasswordFormStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,14 @@
part of 'set_password_form_bloc.dart';
@freezed
class SetPasswordFormEvent with _$SetPasswordFormEvent {
const factory SetPasswordFormEvent.registrationTokenChanged(
String registrationToken,
) = _RegistrationTokenChanged;
const factory SetPasswordFormEvent.passwordChanged(String password) =
_PasswordChanged;
const factory SetPasswordFormEvent.confirmPasswordChanged(
String confirmPassword,
) = _ConfirmPasswordChanged;
const factory SetPasswordFormEvent.submitted() = _Submitted;
}
@@ -0,0 +1,20 @@
part of 'set_password_form_bloc.dart';
@freezed
class SetPasswordFormState with _$SetPasswordFormState {
const factory SetPasswordFormState({
required String registrationToken,
required String password,
required String confirmPassword,
required Option<Either<AuthFailure, Login>> failureOrSetPasswordOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _SetPasswordFormState;
factory SetPasswordFormState.initial() => SetPasswordFormState(
registrationToken: '',
password: '',
confirmPassword: '',
failureOrSetPasswordOption: none(),
);
}