feat: change password

This commit is contained in:
efrilm
2025-08-19 15:35:18 +07:00
parent 7919825955
commit 1b1e8c5bb4
14 changed files with 1247 additions and 119 deletions
@@ -0,0 +1,70 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/user/user.dart';
part 'change_password_form_event.dart';
part 'change_password_form_state.dart';
part 'change_password_form_bloc.freezed.dart';
@injectable
class ChangePasswordFormBloc
extends Bloc<ChangePasswordFormEvent, ChangePasswordFormState> {
final IUserRepository _repository;
ChangePasswordFormBloc(this._repository)
: super(ChangePasswordFormState.initial()) {
on<ChangePasswordFormEvent>(_onChangePasswordFormEvent);
}
Future<void> _onChangePasswordFormEvent(
ChangePasswordFormEvent event,
Emitter<ChangePasswordFormState> emit,
) {
return event.map(
newPasswordChanged: (e) async {
emit(
state.copyWith(
newPassword: e.newPassword,
failureOrChangePasswordOption: none(),
),
);
},
currentPasswordChanged: (e) async {
emit(
state.copyWith(
currentPassword: e.currentPassword,
failureOrChangePasswordOption: none(),
),
);
},
submitted: (e) async {
Either<UserFailure, Unit>? failureOrSuccess;
emit(
state.copyWith(
isSubmitting: true,
failureOrChangePasswordOption: none(),
),
);
final oldPasswordValid = state.newPassword.isNotEmpty;
final currentPasswordValid = state.currentPassword.isNotEmpty;
if (oldPasswordValid && currentPasswordValid) {
failureOrSuccess = await _repository.changePassword(
newPassword: state.newPassword,
currentPassword: state.currentPassword,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrChangePasswordOption: optionOf(failureOrSuccess),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}
@@ -0,0 +1,766 @@
// 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 'change_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 _$ChangePasswordFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChangePasswordFormEventCopyWith<$Res> {
factory $ChangePasswordFormEventCopyWith(
ChangePasswordFormEvent value,
$Res Function(ChangePasswordFormEvent) then,
) = _$ChangePasswordFormEventCopyWithImpl<$Res, ChangePasswordFormEvent>;
}
/// @nodoc
class _$ChangePasswordFormEventCopyWithImpl<
$Res,
$Val extends ChangePasswordFormEvent
>
implements $ChangePasswordFormEventCopyWith<$Res> {
_$ChangePasswordFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$NewPasswordChangedImplCopyWith<$Res> {
factory _$$NewPasswordChangedImplCopyWith(
_$NewPasswordChangedImpl value,
$Res Function(_$NewPasswordChangedImpl) then,
) = __$$NewPasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String newPassword});
}
/// @nodoc
class __$$NewPasswordChangedImplCopyWithImpl<$Res>
extends
_$ChangePasswordFormEventCopyWithImpl<$Res, _$NewPasswordChangedImpl>
implements _$$NewPasswordChangedImplCopyWith<$Res> {
__$$NewPasswordChangedImplCopyWithImpl(
_$NewPasswordChangedImpl _value,
$Res Function(_$NewPasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? newPassword = null}) {
return _then(
_$NewPasswordChangedImpl(
null == newPassword
? _value.newPassword
: newPassword // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$NewPasswordChangedImpl implements _NewPasswordChanged {
const _$NewPasswordChangedImpl(this.newPassword);
@override
final String newPassword;
@override
String toString() {
return 'ChangePasswordFormEvent.newPasswordChanged(newPassword: $newPassword)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NewPasswordChangedImpl &&
(identical(other.newPassword, newPassword) ||
other.newPassword == newPassword));
}
@override
int get hashCode => Object.hash(runtimeType, newPassword);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$NewPasswordChangedImplCopyWith<_$NewPasswordChangedImpl> get copyWith =>
__$$NewPasswordChangedImplCopyWithImpl<_$NewPasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) {
return newPasswordChanged(newPassword);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) {
return newPasswordChanged?.call(newPassword);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (newPasswordChanged != null) {
return newPasswordChanged(newPassword);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return newPasswordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return newPasswordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (newPasswordChanged != null) {
return newPasswordChanged(this);
}
return orElse();
}
}
abstract class _NewPasswordChanged implements ChangePasswordFormEvent {
const factory _NewPasswordChanged(final String newPassword) =
_$NewPasswordChangedImpl;
String get newPassword;
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$NewPasswordChangedImplCopyWith<_$NewPasswordChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$CurrentPasswordChangedImplCopyWith<$Res> {
factory _$$CurrentPasswordChangedImplCopyWith(
_$CurrentPasswordChangedImpl value,
$Res Function(_$CurrentPasswordChangedImpl) then,
) = __$$CurrentPasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String currentPassword});
}
/// @nodoc
class __$$CurrentPasswordChangedImplCopyWithImpl<$Res>
extends
_$ChangePasswordFormEventCopyWithImpl<
$Res,
_$CurrentPasswordChangedImpl
>
implements _$$CurrentPasswordChangedImplCopyWith<$Res> {
__$$CurrentPasswordChangedImplCopyWithImpl(
_$CurrentPasswordChangedImpl _value,
$Res Function(_$CurrentPasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? currentPassword = null}) {
return _then(
_$CurrentPasswordChangedImpl(
null == currentPassword
? _value.currentPassword
: currentPassword // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$CurrentPasswordChangedImpl implements _CurrentPasswordChanged {
const _$CurrentPasswordChangedImpl(this.currentPassword);
@override
final String currentPassword;
@override
String toString() {
return 'ChangePasswordFormEvent.currentPasswordChanged(currentPassword: $currentPassword)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CurrentPasswordChangedImpl &&
(identical(other.currentPassword, currentPassword) ||
other.currentPassword == currentPassword));
}
@override
int get hashCode => Object.hash(runtimeType, currentPassword);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CurrentPasswordChangedImplCopyWith<_$CurrentPasswordChangedImpl>
get copyWith =>
__$$CurrentPasswordChangedImplCopyWithImpl<_$CurrentPasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) {
return currentPasswordChanged(currentPassword);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) {
return currentPasswordChanged?.call(currentPassword);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (currentPasswordChanged != null) {
return currentPasswordChanged(currentPassword);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return currentPasswordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return currentPasswordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (currentPasswordChanged != null) {
return currentPasswordChanged(this);
}
return orElse();
}
}
abstract class _CurrentPasswordChanged implements ChangePasswordFormEvent {
const factory _CurrentPasswordChanged(final String currentPassword) =
_$CurrentPasswordChangedImpl;
String get currentPassword;
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CurrentPasswordChangedImplCopyWith<_$CurrentPasswordChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$ChangePasswordFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'ChangePasswordFormEvent.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 newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements ChangePasswordFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$ChangePasswordFormState {
String get newPassword => throw _privateConstructorUsedError;
String get currentPassword => throw _privateConstructorUsedError;
Option<Either<UserFailure, Unit>> get failureOrChangePasswordOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ChangePasswordFormStateCopyWith<ChangePasswordFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChangePasswordFormStateCopyWith<$Res> {
factory $ChangePasswordFormStateCopyWith(
ChangePasswordFormState value,
$Res Function(ChangePasswordFormState) then,
) = _$ChangePasswordFormStateCopyWithImpl<$Res, ChangePasswordFormState>;
@useResult
$Res call({
String newPassword,
String currentPassword,
Option<Either<UserFailure, Unit>> failureOrChangePasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$ChangePasswordFormStateCopyWithImpl<
$Res,
$Val extends ChangePasswordFormState
>
implements $ChangePasswordFormStateCopyWith<$Res> {
_$ChangePasswordFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? newPassword = null,
Object? currentPassword = null,
Object? failureOrChangePasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
newPassword: null == newPassword
? _value.newPassword
: newPassword // ignore: cast_nullable_to_non_nullable
as String,
currentPassword: null == currentPassword
? _value.currentPassword
: currentPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrChangePasswordOption: null == failureOrChangePasswordOption
? _value.failureOrChangePasswordOption
: failureOrChangePasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, Unit>>,
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 _$$ChangePasswordFormStateImplCopyWith<$Res>
implements $ChangePasswordFormStateCopyWith<$Res> {
factory _$$ChangePasswordFormStateImplCopyWith(
_$ChangePasswordFormStateImpl value,
$Res Function(_$ChangePasswordFormStateImpl) then,
) = __$$ChangePasswordFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String newPassword,
String currentPassword,
Option<Either<UserFailure, Unit>> failureOrChangePasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$ChangePasswordFormStateImplCopyWithImpl<$Res>
extends
_$ChangePasswordFormStateCopyWithImpl<
$Res,
_$ChangePasswordFormStateImpl
>
implements _$$ChangePasswordFormStateImplCopyWith<$Res> {
__$$ChangePasswordFormStateImplCopyWithImpl(
_$ChangePasswordFormStateImpl _value,
$Res Function(_$ChangePasswordFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? newPassword = null,
Object? currentPassword = null,
Object? failureOrChangePasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$ChangePasswordFormStateImpl(
newPassword: null == newPassword
? _value.newPassword
: newPassword // ignore: cast_nullable_to_non_nullable
as String,
currentPassword: null == currentPassword
? _value.currentPassword
: currentPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrChangePasswordOption: null == failureOrChangePasswordOption
? _value.failureOrChangePasswordOption
: failureOrChangePasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, Unit>>,
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 _$ChangePasswordFormStateImpl implements _ChangePasswordFormState {
const _$ChangePasswordFormStateImpl({
required this.newPassword,
required this.currentPassword,
required this.failureOrChangePasswordOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String newPassword;
@override
final String currentPassword;
@override
final Option<Either<UserFailure, Unit>> failureOrChangePasswordOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'ChangePasswordFormState(newPassword: $newPassword, currentPassword: $currentPassword, failureOrChangePasswordOption: $failureOrChangePasswordOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ChangePasswordFormStateImpl &&
(identical(other.newPassword, newPassword) ||
other.newPassword == newPassword) &&
(identical(other.currentPassword, currentPassword) ||
other.currentPassword == currentPassword) &&
(identical(
other.failureOrChangePasswordOption,
failureOrChangePasswordOption,
) ||
other.failureOrChangePasswordOption ==
failureOrChangePasswordOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
newPassword,
currentPassword,
failureOrChangePasswordOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ChangePasswordFormStateImplCopyWith<_$ChangePasswordFormStateImpl>
get copyWith =>
__$$ChangePasswordFormStateImplCopyWithImpl<
_$ChangePasswordFormStateImpl
>(this, _$identity);
}
abstract class _ChangePasswordFormState implements ChangePasswordFormState {
const factory _ChangePasswordFormState({
required final String newPassword,
required final String currentPassword,
required final Option<Either<UserFailure, Unit>>
failureOrChangePasswordOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$ChangePasswordFormStateImpl;
@override
String get newPassword;
@override
String get currentPassword;
@override
Option<Either<UserFailure, Unit>> get failureOrChangePasswordOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ChangePasswordFormStateImplCopyWith<_$ChangePasswordFormStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,11 @@
part of 'change_password_form_bloc.dart';
@freezed
class ChangePasswordFormEvent with _$ChangePasswordFormEvent {
const factory ChangePasswordFormEvent.newPasswordChanged(String newPassword) =
_NewPasswordChanged;
const factory ChangePasswordFormEvent.currentPasswordChanged(
String currentPassword,
) = _CurrentPasswordChanged;
const factory ChangePasswordFormEvent.submitted() = _Submitted;
}
@@ -0,0 +1,18 @@
part of 'change_password_form_bloc.dart';
@freezed
class ChangePasswordFormState with _$ChangePasswordFormState {
const factory ChangePasswordFormState({
required String newPassword,
required String currentPassword,
required Option<Either<UserFailure, Unit>> failureOrChangePasswordOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _ChangePasswordFormState;
factory ChangePasswordFormState.initial() => ChangePasswordFormState(
currentPassword: '',
newPassword: '',
failureOrChangePasswordOption: none(),
);
}