diff --git a/lib/application/user/change_password_form/change_password_form_bloc.dart b/lib/application/user/change_password_form/change_password_form_bloc.dart new file mode 100644 index 0000000..6a5378c --- /dev/null +++ b/lib/application/user/change_password_form/change_password_form_bloc.dart @@ -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 { + final IUserRepository _repository; + ChangePasswordFormBloc(this._repository) + : super(ChangePasswordFormState.initial()) { + on(_onChangePasswordFormEvent); + } + + Future _onChangePasswordFormEvent( + ChangePasswordFormEvent event, + Emitter 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? 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)); + }, + ); + } +} diff --git a/lib/application/user/change_password_form/change_password_form_bloc.freezed.dart b/lib/application/user/change_password_form/change_password_form_bloc.freezed.dart new file mode 100644 index 0000000..55ee2a0 --- /dev/null +++ b/lib/application/user/change_password_form/change_password_form_bloc.freezed.dart @@ -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 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({ + required TResult Function(String newPassword) newPasswordChanged, + required TResult Function(String currentPassword) currentPasswordChanged, + required TResult Function() submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String newPassword)? newPasswordChanged, + TResult? Function(String currentPassword)? currentPasswordChanged, + TResult? Function()? submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(String newPassword)? newPasswordChanged, + TResult Function(String currentPassword)? currentPasswordChanged, + TResult Function()? submitted, + required TResult orElse(), + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(_NewPasswordChanged value) newPasswordChanged, + required TResult Function(_CurrentPasswordChanged value) + currentPasswordChanged, + required TResult Function(_Submitted value) submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(_NewPasswordChanged value)? newPasswordChanged, + TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged, + TResult? Function(_Submitted value)? submitted, + }) => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + 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({ + required TResult Function(String newPassword) newPasswordChanged, + required TResult Function(String currentPassword) currentPasswordChanged, + required TResult Function() submitted, + }) { + return newPasswordChanged(newPassword); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String newPassword)? newPasswordChanged, + TResult? Function(String currentPassword)? currentPasswordChanged, + TResult? Function()? submitted, + }) { + return newPasswordChanged?.call(newPassword); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + 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({ + 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? Function(_NewPasswordChanged value)? newPasswordChanged, + TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged, + TResult? Function(_Submitted value)? submitted, + }) { + return newPasswordChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + 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({ + required TResult Function(String newPassword) newPasswordChanged, + required TResult Function(String currentPassword) currentPasswordChanged, + required TResult Function() submitted, + }) { + return currentPasswordChanged(currentPassword); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String newPassword)? newPasswordChanged, + TResult? Function(String currentPassword)? currentPasswordChanged, + TResult? Function()? submitted, + }) { + return currentPasswordChanged?.call(currentPassword); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + 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({ + 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? Function(_NewPasswordChanged value)? newPasswordChanged, + TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged, + TResult? Function(_Submitted value)? submitted, + }) { + return currentPasswordChanged?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + 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({ + required TResult Function(String newPassword) newPasswordChanged, + required TResult Function(String currentPassword) currentPasswordChanged, + required TResult Function() submitted, + }) { + return submitted(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(String newPassword)? newPasswordChanged, + TResult? Function(String currentPassword)? currentPasswordChanged, + TResult? Function()? submitted, + }) { + return submitted?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + 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({ + 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? Function(_NewPasswordChanged value)? newPasswordChanged, + TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged, + TResult? Function(_Submitted value)? submitted, + }) { + return submitted?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + 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> 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 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> 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>, + 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> 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>, + 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> 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> + failureOrChangePasswordOption, + final bool isSubmitting, + final bool showErrorMessages, + }) = _$ChangePasswordFormStateImpl; + + @override + String get newPassword; + @override + String get currentPassword; + @override + Option> 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; +} diff --git a/lib/application/user/change_password_form/change_password_form_event.dart b/lib/application/user/change_password_form/change_password_form_event.dart new file mode 100644 index 0000000..41b9342 --- /dev/null +++ b/lib/application/user/change_password_form/change_password_form_event.dart @@ -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; +} diff --git a/lib/application/user/change_password_form/change_password_form_state.dart b/lib/application/user/change_password_form/change_password_form_state.dart new file mode 100644 index 0000000..d735ef9 --- /dev/null +++ b/lib/application/user/change_password_form/change_password_form_state.dart @@ -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> failureOrChangePasswordOption, + @Default(false) bool isSubmitting, + @Default(false) bool showErrorMessages, + }) = _ChangePasswordFormState; + + factory ChangePasswordFormState.initial() => ChangePasswordFormState( + currentPassword: '', + newPassword: '', + failureOrChangePasswordOption: none(), + ); +} diff --git a/lib/domain/user/repositories/i_user_repository.dart b/lib/domain/user/repositories/i_user_repository.dart index ee13ed4..3adfa4f 100644 --- a/lib/domain/user/repositories/i_user_repository.dart +++ b/lib/domain/user/repositories/i_user_repository.dart @@ -2,4 +2,8 @@ part of '../user.dart'; abstract class IUserRepository { Future> editUser({required String name}); + Future> changePassword({ + required String newPassword, + required String currentPassword, + }); } diff --git a/lib/infrastructure/user/datasource/remote_data_provider.dart b/lib/infrastructure/user/datasource/remote_data_provider.dart index 9d62006..f92a5b7 100644 --- a/lib/infrastructure/user/datasource/remote_data_provider.dart +++ b/lib/infrastructure/user/datasource/remote_data_provider.dart @@ -1,5 +1,6 @@ import 'dart:developer'; +import 'package:dartz/dartz.dart'; import 'package:data_channel/data_channel.dart'; import 'package:injectable/injectable.dart'; @@ -47,4 +48,36 @@ class UserRemoteDataProvider { return DC.error(UserFailure.serverError(e)); } } + + Future> changePassword({ + required String newPassword, + required String currentPassword, + required String userId, + }) async { + try { + final response = await _apiClient.put( + '${ApiPath.user}/$userId/password', + data: { + 'new_password': newPassword, + 'current_password': currentPassword, + }, + headers: getAuthorizationHeader(), + ); + + if (response.statusCode == 400) { + return DC.error(UserFailure.unexpectedError()); + } + + if (response.statusCode != 200) { + return DC.error( + UserFailure.dynamicErrorMessage(response.data['error']), + ); + } + + return DC.data(unit); + } on ApiFailure catch (e, s) { + log('changePassword', name: _logName, error: e, stackTrace: s); + return DC.error(UserFailure.serverError(e)); + } + } } diff --git a/lib/infrastructure/user/repositories/user_repository.dart b/lib/infrastructure/user/repositories/user_repository.dart index 2d2cd30..d5ab224 100644 --- a/lib/infrastructure/user/repositories/user_repository.dart +++ b/lib/infrastructure/user/repositories/user_repository.dart @@ -39,4 +39,28 @@ class UserRepository implements IUserRepository { return left(const UserFailure.unexpectedError()); } } + + @override + Future> changePassword({ + required String newPassword, + required String currentPassword, + }) async { + try { + User currentUser = await _authLocalDataProvider.currentUser(); + final result = await _dataProvider.changePassword( + newPassword: newPassword, + currentPassword: currentPassword, + userId: currentUser.id, + ); + + if (result.hasError) { + return left(result.error!); + } + + return right(unit); + } catch (e, s) { + log('changePasswordError', name: _logName, error: e, stackTrace: s); + return left(const UserFailure.unexpectedError()); + } + } } diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 5990c37..98d0aff 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -41,6 +41,8 @@ import 'package:apskel_owner_flutter/application/outlet/current_outlet_loader/cu as _i337; import 'package:apskel_owner_flutter/application/product/product_loader/product_loader_bloc.dart' as _i458; +import 'package:apskel_owner_flutter/application/user/change_password_form/change_password_form_bloc.dart' + as _i1030; import 'package:apskel_owner_flutter/application/user/user_edit_form/user_edit_form_bloc.dart' as _i147; import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115; @@ -258,6 +260,9 @@ extension GetItInjectableX on _i174.GetIt { gh.factory<_i147.UserEditFormBloc>( () => _i147.UserEditFormBloc(gh<_i635.IUserRepository>()), ); + gh.factory<_i1030.ChangePasswordFormBloc>( + () => _i1030.ChangePasswordFormBloc(gh<_i635.IUserRepository>()), + ); return this; } } diff --git a/lib/presentation/pages/profile/pages/profile_change_password/profile_change_password_page.dart b/lib/presentation/pages/profile/pages/profile_change_password/profile_change_password_page.dart new file mode 100644 index 0000000..b227813 --- /dev/null +++ b/lib/presentation/pages/profile/pages/profile_change_password/profile_change_password_page.dart @@ -0,0 +1,104 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../../application/user/change_password_form/change_password_form_bloc.dart'; +import '../../../../../common/theme/theme.dart'; +import '../../../../../injection.dart'; +import '../../../../components/appbar/appbar.dart'; +import '../../../../components/button/button.dart'; +import '../../../../components/spacer/spacer.dart'; +import '../../../../components/toast/flushbar.dart'; +import 'widgets/current_password.dart'; +import 'widgets/new_password.dart'; + +@RoutePage() +class ProfileChangePasswordPage extends StatefulWidget + implements AutoRouteWrapper { + const ProfileChangePasswordPage({super.key}); + + @override + State createState() => + _ProfileChangePasswordPageState(); + + @override + Widget wrappedRoute(BuildContext context) => + BlocProvider(create: (_) => getIt(), child: this); +} + +class _ProfileChangePasswordPageState extends State { + @override + Widget build(BuildContext context) { + return BlocListener( + listener: (context, state) { + state.failureOrChangePasswordOption.fold( + () => null, + (either) => either.fold( + (f) => AppFlushbar.showUserFailureToast(context, f), + (user) { + if (context.mounted) { + AppFlushbar.showSuccess(context, 'Password changed'); + Future.delayed(const Duration(seconds: 2), () { + context.router.back(); + }); + } + }, + ), + ); + }, + child: Scaffold( + backgroundColor: AppColor.background, + body: CustomScrollView( + slivers: [ + // SliverAppBar with gradient + SliverAppBar( + expandedHeight: 120, + floating: false, + pinned: true, + elevation: 0, + backgroundColor: AppColor.primary, + flexibleSpace: CustomAppBar(title: 'Change Password'), + ), + SliverToBoxAdapter( + child: + BlocBuilder( + builder: (context, state) { + return Container( + margin: EdgeInsets.all(AppValue.margin), + padding: EdgeInsets.all(AppValue.padding), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.radius), + ), + child: Form( + autovalidateMode: state.showErrorMessages + ? AutovalidateMode.always + : AutovalidateMode.disabled, + child: Column( + children: [ + ChangePasswordCurrentPassword(), + SpaceHeight(16), + ChangePasswordNewPassword(), + SpaceHeight(24), + AppElevatedButton( + text: 'Save', + isLoading: state.isSubmitting, + onPressed: () { + context.read().add( + ChangePasswordFormEvent.submitted(), + ); + }, + ), + ], + ), + ), + ); + }, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/profile/pages/profile_change_password/widgets/current_password.dart b/lib/presentation/pages/profile/pages/profile_change_password/widgets/current_password.dart new file mode 100644 index 0000000..c3886ae --- /dev/null +++ b/lib/presentation/pages/profile/pages/profile_change_password/widgets/current_password.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:line_icons/line_icons.dart'; + +import '../../../../../../application/user/change_password_form/change_password_form_bloc.dart'; +import '../../../../../components/field/field.dart'; + +class ChangePasswordCurrentPassword extends StatelessWidget { + const ChangePasswordCurrentPassword({super.key}); + + @override + Widget build(BuildContext context) { + return AppPasswordTextFormField( + title: 'Current Password', + prefixIcon: LineIcons.lock, + hintText: 'Please enter your current password', + onChanged: (value) => context.read().add( + ChangePasswordFormEvent.currentPasswordChanged(value), + ), + validator: (value) { + if (context + .read() + .state + .currentPassword + .isEmpty) { + return 'Please enter your current password'; + } + return null; + }, + ); + } +} diff --git a/lib/presentation/pages/profile/pages/profile_change_password/widgets/new_password.dart b/lib/presentation/pages/profile/pages/profile_change_password/widgets/new_password.dart new file mode 100644 index 0000000..4d404be --- /dev/null +++ b/lib/presentation/pages/profile/pages/profile_change_password/widgets/new_password.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:line_icons/line_icons.dart'; + +import '../../../../../../application/user/change_password_form/change_password_form_bloc.dart'; +import '../../../../../components/field/field.dart'; + +class ChangePasswordNewPassword extends StatelessWidget { + const ChangePasswordNewPassword({super.key}); + + @override + Widget build(BuildContext context) { + return AppPasswordTextFormField( + title: 'New Password', + prefixIcon: LineIcons.lock, + hintText: 'Please enter your new password', + onChanged: (value) => context.read().add( + ChangePasswordFormEvent.newPasswordChanged(value), + ), + validator: (value) { + if (context.read().state.newPassword.isEmpty) { + return 'Please enter your new password'; + } + + if (context.read().state.newPassword == + context.read().state.currentPassword) { + return 'New password cannot be same as current password'; + } + return null; + }, + ); + } +} diff --git a/lib/presentation/pages/profile/widgets/account_info.dart b/lib/presentation/pages/profile/widgets/account_info.dart index 187ce35..270e5db 100644 --- a/lib/presentation/pages/profile/widgets/account_info.dart +++ b/lib/presentation/pages/profile/widgets/account_info.dart @@ -66,6 +66,13 @@ class ProfileAccountInfo extends StatelessWidget { subtitle: 'Ubah profil kamu', onTap: () => context.router.push(ProfileEditRoute(user: user)), ), + ProfileDivider(), + ProfileTile( + icon: LineIcons.lock, + title: 'Change Password', + subtitle: 'Change your password', + onTap: () => context.router.push(ProfileChangePasswordRoute()), + ), ], ), ); diff --git a/lib/presentation/router/app_router.dart b/lib/presentation/router/app_router.dart index 5c5baea..3a51345 100644 --- a/lib/presentation/router/app_router.dart +++ b/lib/presentation/router/app_router.dart @@ -61,6 +61,7 @@ class AppRouter extends RootStackRouter { // Profile AutoRoute(page: ProfileEditRoute.page), + AutoRoute(page: ProfileChangePasswordRoute.page), // Error AutoRoute(page: ErrorRoute.page), diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index 1b42cd9..6743204 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -9,8 +9,8 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:apskel_owner_flutter/domain/order/order.dart' as _i26; -import 'package:apskel_owner_flutter/domain/user/user.dart' as _i27; +import 'package:apskel_owner_flutter/domain/order/order.dart' as _i27; +import 'package:apskel_owner_flutter/domain/user/user.dart' as _i28; import 'package:apskel_owner_flutter/presentation/pages/auth/login/login_page.dart' as _i10; import 'package:apskel_owner_flutter/presentation/pages/coming_soon/coming_soon_page.dart' @@ -43,32 +43,34 @@ import 'package:apskel_owner_flutter/presentation/pages/product/product_analytic as _i15; import 'package:apskel_owner_flutter/presentation/pages/product/product_list/product_page.dart' as _i16; -import 'package:apskel_owner_flutter/presentation/pages/profile/pages/profile_edit/profile_edit_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/profile/pages/profile_change_password/profile_change_password_page.dart' as _i17; -import 'package:apskel_owner_flutter/presentation/pages/profile/profile_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/profile/pages/profile_edit/profile_edit_page.dart' as _i18; -import 'package:apskel_owner_flutter/presentation/pages/purchase/purchase_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/profile/profile_page.dart' as _i19; -import 'package:apskel_owner_flutter/presentation/pages/report/report_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/purchase/purchase_page.dart' as _i20; -import 'package:apskel_owner_flutter/presentation/pages/sales/sales_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/report/report_page.dart' as _i21; -import 'package:apskel_owner_flutter/presentation/pages/schedule/schedule_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/sales/sales_page.dart' as _i22; -import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart' +import 'package:apskel_owner_flutter/presentation/pages/schedule/schedule_page.dart' as _i23; -import 'package:auto_route/auto_route.dart' as _i24; -import 'package:flutter/material.dart' as _i25; +import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart' + as _i24; +import 'package:auto_route/auto_route.dart' as _i25; +import 'package:flutter/material.dart' as _i26; /// generated route for /// [_i1.ComingSoonPage] -class ComingSoonRoute extends _i24.PageRouteInfo { - const ComingSoonRoute({List<_i24.PageRouteInfo>? children}) +class ComingSoonRoute extends _i25.PageRouteInfo { + const ComingSoonRoute({List<_i25.PageRouteInfo>? children}) : super(ComingSoonRoute.name, initialChildren: children); static const String name = 'ComingSoonRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { return const _i1.ComingSoonPage(); @@ -78,29 +80,29 @@ class ComingSoonRoute extends _i24.PageRouteInfo { /// generated route for /// [_i2.CustomerPage] -class CustomerRoute extends _i24.PageRouteInfo { - const CustomerRoute({List<_i24.PageRouteInfo>? children}) +class CustomerRoute extends _i25.PageRouteInfo { + const CustomerRoute({List<_i25.PageRouteInfo>? children}) : super(CustomerRoute.name, initialChildren: children); static const String name = 'CustomerRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i2.CustomerPage()); + return _i25.WrappedRoute(child: const _i2.CustomerPage()); }, ); } /// generated route for /// [_i3.DailyTasksFormPage] -class DailyTasksFormRoute extends _i24.PageRouteInfo { - const DailyTasksFormRoute({List<_i24.PageRouteInfo>? children}) +class DailyTasksFormRoute extends _i25.PageRouteInfo { + const DailyTasksFormRoute({List<_i25.PageRouteInfo>? children}) : super(DailyTasksFormRoute.name, initialChildren: children); static const String name = 'DailyTasksFormRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { return const _i3.DailyTasksFormPage(); @@ -110,13 +112,13 @@ class DailyTasksFormRoute extends _i24.PageRouteInfo { /// generated route for /// [_i4.DownloadReportPage] -class DownloadReportRoute extends _i24.PageRouteInfo { - const DownloadReportRoute({List<_i24.PageRouteInfo>? children}) +class DownloadReportRoute extends _i25.PageRouteInfo { + const DownloadReportRoute({List<_i25.PageRouteInfo>? children}) : super(DownloadReportRoute.name, initialChildren: children); static const String name = 'DownloadReportRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { return const _i4.DownloadReportPage(); @@ -126,16 +128,16 @@ class DownloadReportRoute extends _i24.PageRouteInfo { /// generated route for /// [_i5.ErrorPage] -class ErrorRoute extends _i24.PageRouteInfo { +class ErrorRoute extends _i25.PageRouteInfo { ErrorRoute({ - _i25.Key? key, + _i26.Key? key, String? title, String? message, - _i25.VoidCallback? onRetry, - _i25.VoidCallback? onBack, + _i26.VoidCallback? onRetry, + _i26.VoidCallback? onBack, String? errorCode, - _i25.IconData? errorIcon, - List<_i24.PageRouteInfo>? children, + _i26.IconData? errorIcon, + List<_i25.PageRouteInfo>? children, }) : super( ErrorRoute.name, args: ErrorRouteArgs( @@ -152,7 +154,7 @@ class ErrorRoute extends _i24.PageRouteInfo { static const String name = 'ErrorRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { final args = data.argsAs( @@ -182,19 +184,19 @@ class ErrorRouteArgs { this.errorIcon, }); - final _i25.Key? key; + final _i26.Key? key; final String? title; final String? message; - final _i25.VoidCallback? onRetry; + final _i26.VoidCallback? onRetry; - final _i25.VoidCallback? onBack; + final _i26.VoidCallback? onBack; final String? errorCode; - final _i25.IconData? errorIcon; + final _i26.IconData? errorIcon; @override String toString() { @@ -204,61 +206,61 @@ class ErrorRouteArgs { /// generated route for /// [_i6.FinancePage] -class FinanceRoute extends _i24.PageRouteInfo { - const FinanceRoute({List<_i24.PageRouteInfo>? children}) +class FinanceRoute extends _i25.PageRouteInfo { + const FinanceRoute({List<_i25.PageRouteInfo>? children}) : super(FinanceRoute.name, initialChildren: children); static const String name = 'FinanceRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i6.FinancePage()); + return _i25.WrappedRoute(child: const _i6.FinancePage()); }, ); } /// generated route for /// [_i7.HomePage] -class HomeRoute extends _i24.PageRouteInfo { - const HomeRoute({List<_i24.PageRouteInfo>? children}) +class HomeRoute extends _i25.PageRouteInfo { + const HomeRoute({List<_i25.PageRouteInfo>? children}) : super(HomeRoute.name, initialChildren: children); static const String name = 'HomeRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i7.HomePage()); + return _i25.WrappedRoute(child: const _i7.HomePage()); }, ); } /// generated route for /// [_i8.InventoryPage] -class InventoryRoute extends _i24.PageRouteInfo { - const InventoryRoute({List<_i24.PageRouteInfo>? children}) +class InventoryRoute extends _i25.PageRouteInfo { + const InventoryRoute({List<_i25.PageRouteInfo>? children}) : super(InventoryRoute.name, initialChildren: children); static const String name = 'InventoryRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i8.InventoryPage()); + return _i25.WrappedRoute(child: const _i8.InventoryPage()); }, ); } /// generated route for /// [_i9.LanguagePage] -class LanguageRoute extends _i24.PageRouteInfo { - const LanguageRoute({List<_i24.PageRouteInfo>? children}) +class LanguageRoute extends _i25.PageRouteInfo { + const LanguageRoute({List<_i25.PageRouteInfo>? children}) : super(LanguageRoute.name, initialChildren: children); static const String name = 'LanguageRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { return const _i9.LanguagePage(); @@ -268,29 +270,29 @@ class LanguageRoute extends _i24.PageRouteInfo { /// generated route for /// [_i10.LoginPage] -class LoginRoute extends _i24.PageRouteInfo { - const LoginRoute({List<_i24.PageRouteInfo>? children}) +class LoginRoute extends _i25.PageRouteInfo { + const LoginRoute({List<_i25.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i10.LoginPage()); + return _i25.WrappedRoute(child: const _i10.LoginPage()); }, ); } /// generated route for /// [_i11.MainPage] -class MainRoute extends _i24.PageRouteInfo { - const MainRoute({List<_i24.PageRouteInfo>? children}) +class MainRoute extends _i25.PageRouteInfo { + const MainRoute({List<_i25.PageRouteInfo>? children}) : super(MainRoute.name, initialChildren: children); static const String name = 'MainRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { return const _i11.MainPage(); @@ -300,11 +302,11 @@ class MainRoute extends _i24.PageRouteInfo { /// generated route for /// [_i12.OrderDetailPage] -class OrderDetailRoute extends _i24.PageRouteInfo { +class OrderDetailRoute extends _i25.PageRouteInfo { OrderDetailRoute({ - _i25.Key? key, - required _i26.Order order, - List<_i24.PageRouteInfo>? children, + _i26.Key? key, + required _i27.Order order, + List<_i25.PageRouteInfo>? children, }) : super( OrderDetailRoute.name, args: OrderDetailRouteArgs(key: key, order: order), @@ -313,7 +315,7 @@ class OrderDetailRoute extends _i24.PageRouteInfo { static const String name = 'OrderDetailRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { final args = data.argsAs(); @@ -325,9 +327,9 @@ class OrderDetailRoute extends _i24.PageRouteInfo { class OrderDetailRouteArgs { const OrderDetailRouteArgs({this.key, required this.order}); - final _i25.Key? key; + final _i26.Key? key; - final _i26.Order order; + final _i27.Order order; @override String toString() { @@ -337,75 +339,91 @@ class OrderDetailRouteArgs { /// generated route for /// [_i13.OrderPage] -class OrderRoute extends _i24.PageRouteInfo { - const OrderRoute({List<_i24.PageRouteInfo>? children}) +class OrderRoute extends _i25.PageRouteInfo { + const OrderRoute({List<_i25.PageRouteInfo>? children}) : super(OrderRoute.name, initialChildren: children); static const String name = 'OrderRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i13.OrderPage()); + return _i25.WrappedRoute(child: const _i13.OrderPage()); }, ); } /// generated route for /// [_i14.OutletInformationPage] -class OutletInformationRoute extends _i24.PageRouteInfo { - const OutletInformationRoute({List<_i24.PageRouteInfo>? children}) +class OutletInformationRoute extends _i25.PageRouteInfo { + const OutletInformationRoute({List<_i25.PageRouteInfo>? children}) : super(OutletInformationRoute.name, initialChildren: children); static const String name = 'OutletInformationRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i14.OutletInformationPage()); + return _i25.WrappedRoute(child: const _i14.OutletInformationPage()); }, ); } /// generated route for /// [_i15.ProductAnalyticPage] -class ProductAnalyticRoute extends _i24.PageRouteInfo { - const ProductAnalyticRoute({List<_i24.PageRouteInfo>? children}) +class ProductAnalyticRoute extends _i25.PageRouteInfo { + const ProductAnalyticRoute({List<_i25.PageRouteInfo>? children}) : super(ProductAnalyticRoute.name, initialChildren: children); static const String name = 'ProductAnalyticRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i15.ProductAnalyticPage()); + return _i25.WrappedRoute(child: const _i15.ProductAnalyticPage()); }, ); } /// generated route for /// [_i16.ProductPage] -class ProductRoute extends _i24.PageRouteInfo { - const ProductRoute({List<_i24.PageRouteInfo>? children}) +class ProductRoute extends _i25.PageRouteInfo { + const ProductRoute({List<_i25.PageRouteInfo>? children}) : super(ProductRoute.name, initialChildren: children); static const String name = 'ProductRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i16.ProductPage()); + return _i25.WrappedRoute(child: const _i16.ProductPage()); }, ); } /// generated route for -/// [_i17.ProfileEditPage] -class ProfileEditRoute extends _i24.PageRouteInfo { +/// [_i17.ProfileChangePasswordPage] +class ProfileChangePasswordRoute extends _i25.PageRouteInfo { + const ProfileChangePasswordRoute({List<_i25.PageRouteInfo>? children}) + : super(ProfileChangePasswordRoute.name, initialChildren: children); + + static const String name = 'ProfileChangePasswordRoute'; + + static _i25.PageInfo page = _i25.PageInfo( + name, + builder: (data) { + return _i25.WrappedRoute(child: const _i17.ProfileChangePasswordPage()); + }, + ); +} + +/// generated route for +/// [_i18.ProfileEditPage] +class ProfileEditRoute extends _i25.PageRouteInfo { ProfileEditRoute({ - _i25.Key? key, - required _i27.User user, - List<_i24.PageRouteInfo>? children, + _i26.Key? key, + required _i28.User user, + List<_i25.PageRouteInfo>? children, }) : super( ProfileEditRoute.name, args: ProfileEditRouteArgs(key: key, user: user), @@ -414,11 +432,13 @@ class ProfileEditRoute extends _i24.PageRouteInfo { static const String name = 'ProfileEditRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i17.ProfileEditPage(key: args.key, user: args.user); + return _i25.WrappedRoute( + child: _i18.ProfileEditPage(key: args.key, user: args.user), + ); }, ); } @@ -426,9 +446,9 @@ class ProfileEditRoute extends _i24.PageRouteInfo { class ProfileEditRouteArgs { const ProfileEditRouteArgs({this.key, required this.user}); - final _i25.Key? key; + final _i26.Key? key; - final _i27.User user; + final _i28.User user; @override String toString() { @@ -437,97 +457,97 @@ class ProfileEditRouteArgs { } /// generated route for -/// [_i18.ProfilePage] -class ProfileRoute extends _i24.PageRouteInfo { - const ProfileRoute({List<_i24.PageRouteInfo>? children}) +/// [_i19.ProfilePage] +class ProfileRoute extends _i25.PageRouteInfo { + const ProfileRoute({List<_i25.PageRouteInfo>? children}) : super(ProfileRoute.name, initialChildren: children); static const String name = 'ProfileRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i18.ProfilePage()); + return _i25.WrappedRoute(child: const _i19.ProfilePage()); }, ); } /// generated route for -/// [_i19.PurchasePage] -class PurchaseRoute extends _i24.PageRouteInfo { - const PurchaseRoute({List<_i24.PageRouteInfo>? children}) +/// [_i20.PurchasePage] +class PurchaseRoute extends _i25.PageRouteInfo { + const PurchaseRoute({List<_i25.PageRouteInfo>? children}) : super(PurchaseRoute.name, initialChildren: children); static const String name = 'PurchaseRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return const _i19.PurchasePage(); + return const _i20.PurchasePage(); }, ); } /// generated route for -/// [_i20.ReportPage] -class ReportRoute extends _i24.PageRouteInfo { - const ReportRoute({List<_i24.PageRouteInfo>? children}) +/// [_i21.ReportPage] +class ReportRoute extends _i25.PageRouteInfo { + const ReportRoute({List<_i25.PageRouteInfo>? children}) : super(ReportRoute.name, initialChildren: children); static const String name = 'ReportRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i20.ReportPage()); + return _i25.WrappedRoute(child: const _i21.ReportPage()); }, ); } /// generated route for -/// [_i21.SalesPage] -class SalesRoute extends _i24.PageRouteInfo { - const SalesRoute({List<_i24.PageRouteInfo>? children}) +/// [_i22.SalesPage] +class SalesRoute extends _i25.PageRouteInfo { + const SalesRoute({List<_i25.PageRouteInfo>? children}) : super(SalesRoute.name, initialChildren: children); static const String name = 'SalesRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return _i24.WrappedRoute(child: const _i21.SalesPage()); + return _i25.WrappedRoute(child: const _i22.SalesPage()); }, ); } /// generated route for -/// [_i22.SchedulePage] -class ScheduleRoute extends _i24.PageRouteInfo { - const ScheduleRoute({List<_i24.PageRouteInfo>? children}) +/// [_i23.SchedulePage] +class ScheduleRoute extends _i25.PageRouteInfo { + const ScheduleRoute({List<_i25.PageRouteInfo>? children}) : super(ScheduleRoute.name, initialChildren: children); static const String name = 'ScheduleRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return const _i22.SchedulePage(); + return const _i23.SchedulePage(); }, ); } /// generated route for -/// [_i23.SplashPage] -class SplashRoute extends _i24.PageRouteInfo { - const SplashRoute({List<_i24.PageRouteInfo>? children}) +/// [_i24.SplashPage] +class SplashRoute extends _i25.PageRouteInfo { + const SplashRoute({List<_i25.PageRouteInfo>? children}) : super(SplashRoute.name, initialChildren: children); static const String name = 'SplashRoute'; - static _i24.PageInfo page = _i24.PageInfo( + static _i25.PageInfo page = _i25.PageInfo( name, builder: (data) { - return const _i23.SplashPage(); + return const _i24.SplashPage(); }, ); }