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

View File

@ -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));
},
);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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(),
);
}

View File

@ -2,4 +2,8 @@ part of '../user.dart';
abstract class IUserRepository { abstract class IUserRepository {
Future<Either<UserFailure, User>> editUser({required String name}); Future<Either<UserFailure, User>> editUser({required String name});
Future<Either<UserFailure, Unit>> changePassword({
required String newPassword,
required String currentPassword,
});
} }

View File

@ -1,5 +1,6 @@
import 'dart:developer'; import 'dart:developer';
import 'package:dartz/dartz.dart';
import 'package:data_channel/data_channel.dart'; import 'package:data_channel/data_channel.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
@ -47,4 +48,36 @@ class UserRemoteDataProvider {
return DC.error(UserFailure.serverError(e)); return DC.error(UserFailure.serverError(e));
} }
} }
Future<DC<UserFailure, Unit>> 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));
}
}
} }

View File

@ -39,4 +39,28 @@ class UserRepository implements IUserRepository {
return left(const UserFailure.unexpectedError()); return left(const UserFailure.unexpectedError());
} }
} }
@override
Future<Either<UserFailure, Unit>> 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());
}
}
} }

View File

@ -41,6 +41,8 @@ import 'package:apskel_owner_flutter/application/outlet/current_outlet_loader/cu
as _i337; as _i337;
import 'package:apskel_owner_flutter/application/product/product_loader/product_loader_bloc.dart' import 'package:apskel_owner_flutter/application/product/product_loader/product_loader_bloc.dart'
as _i458; 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' import 'package:apskel_owner_flutter/application/user/user_edit_form/user_edit_form_bloc.dart'
as _i147; as _i147;
import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115; 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>( gh.factory<_i147.UserEditFormBloc>(
() => _i147.UserEditFormBloc(gh<_i635.IUserRepository>()), () => _i147.UserEditFormBloc(gh<_i635.IUserRepository>()),
); );
gh.factory<_i1030.ChangePasswordFormBloc>(
() => _i1030.ChangePasswordFormBloc(gh<_i635.IUserRepository>()),
);
return this; return this;
} }
} }

View File

@ -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<ProfileChangePasswordPage> createState() =>
_ProfileChangePasswordPageState();
@override
Widget wrappedRoute(BuildContext context) =>
BlocProvider(create: (_) => getIt<ChangePasswordFormBloc>(), child: this);
}
class _ProfileChangePasswordPageState extends State<ProfileChangePasswordPage> {
@override
Widget build(BuildContext context) {
return BlocListener<ChangePasswordFormBloc, ChangePasswordFormState>(
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<ChangePasswordFormBloc, ChangePasswordFormState>(
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<ChangePasswordFormBloc>().add(
ChangePasswordFormEvent.submitted(),
);
},
),
],
),
),
);
},
),
),
],
),
),
);
}
}

View File

@ -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<ChangePasswordFormBloc>().add(
ChangePasswordFormEvent.currentPasswordChanged(value),
),
validator: (value) {
if (context
.read<ChangePasswordFormBloc>()
.state
.currentPassword
.isEmpty) {
return 'Please enter your current password';
}
return null;
},
);
}
}

View File

@ -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<ChangePasswordFormBloc>().add(
ChangePasswordFormEvent.newPasswordChanged(value),
),
validator: (value) {
if (context.read<ChangePasswordFormBloc>().state.newPassword.isEmpty) {
return 'Please enter your new password';
}
if (context.read<ChangePasswordFormBloc>().state.newPassword ==
context.read<ChangePasswordFormBloc>().state.currentPassword) {
return 'New password cannot be same as current password';
}
return null;
},
);
}
}

View File

@ -66,6 +66,13 @@ class ProfileAccountInfo extends StatelessWidget {
subtitle: 'Ubah profil kamu', subtitle: 'Ubah profil kamu',
onTap: () => context.router.push(ProfileEditRoute(user: user)), onTap: () => context.router.push(ProfileEditRoute(user: user)),
), ),
ProfileDivider(),
ProfileTile(
icon: LineIcons.lock,
title: 'Change Password',
subtitle: 'Change your password',
onTap: () => context.router.push(ProfileChangePasswordRoute()),
),
], ],
), ),
); );

View File

@ -61,6 +61,7 @@ class AppRouter extends RootStackRouter {
// Profile // Profile
AutoRoute(page: ProfileEditRoute.page), AutoRoute(page: ProfileEditRoute.page),
AutoRoute(page: ProfileChangePasswordRoute.page),
// Error // Error
AutoRoute(page: ErrorRoute.page), AutoRoute(page: ErrorRoute.page),

View File

@ -9,8 +9,8 @@
// coverage:ignore-file // coverage:ignore-file
// ignore_for_file: no_leading_underscores_for_library_prefixes // 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/order/order.dart' as _i27;
import 'package:apskel_owner_flutter/domain/user/user.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' import 'package:apskel_owner_flutter/presentation/pages/auth/login/login_page.dart'
as _i10; as _i10;
import 'package:apskel_owner_flutter/presentation/pages/coming_soon/coming_soon_page.dart' 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; as _i15;
import 'package:apskel_owner_flutter/presentation/pages/product/product_list/product_page.dart' import 'package:apskel_owner_flutter/presentation/pages/product/product_list/product_page.dart'
as _i16; 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; 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; 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; 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; 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; 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; 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; as _i23;
import 'package:auto_route/auto_route.dart' as _i24; import 'package:apskel_owner_flutter/presentation/pages/splash/splash_page.dart'
import 'package:flutter/material.dart' as _i25; as _i24;
import 'package:auto_route/auto_route.dart' as _i25;
import 'package:flutter/material.dart' as _i26;
/// generated route for /// generated route for
/// [_i1.ComingSoonPage] /// [_i1.ComingSoonPage]
class ComingSoonRoute extends _i24.PageRouteInfo<void> { class ComingSoonRoute extends _i25.PageRouteInfo<void> {
const ComingSoonRoute({List<_i24.PageRouteInfo>? children}) const ComingSoonRoute({List<_i25.PageRouteInfo>? children})
: super(ComingSoonRoute.name, initialChildren: children); : super(ComingSoonRoute.name, initialChildren: children);
static const String name = 'ComingSoonRoute'; static const String name = 'ComingSoonRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i1.ComingSoonPage(); return const _i1.ComingSoonPage();
@ -78,29 +80,29 @@ class ComingSoonRoute extends _i24.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i2.CustomerPage] /// [_i2.CustomerPage]
class CustomerRoute extends _i24.PageRouteInfo<void> { class CustomerRoute extends _i25.PageRouteInfo<void> {
const CustomerRoute({List<_i24.PageRouteInfo>? children}) const CustomerRoute({List<_i25.PageRouteInfo>? children})
: super(CustomerRoute.name, initialChildren: children); : super(CustomerRoute.name, initialChildren: children);
static const String name = 'CustomerRoute'; static const String name = 'CustomerRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i2.CustomerPage()); return _i25.WrappedRoute(child: const _i2.CustomerPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i3.DailyTasksFormPage] /// [_i3.DailyTasksFormPage]
class DailyTasksFormRoute extends _i24.PageRouteInfo<void> { class DailyTasksFormRoute extends _i25.PageRouteInfo<void> {
const DailyTasksFormRoute({List<_i24.PageRouteInfo>? children}) const DailyTasksFormRoute({List<_i25.PageRouteInfo>? children})
: super(DailyTasksFormRoute.name, initialChildren: children); : super(DailyTasksFormRoute.name, initialChildren: children);
static const String name = 'DailyTasksFormRoute'; static const String name = 'DailyTasksFormRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i3.DailyTasksFormPage(); return const _i3.DailyTasksFormPage();
@ -110,13 +112,13 @@ class DailyTasksFormRoute extends _i24.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i4.DownloadReportPage] /// [_i4.DownloadReportPage]
class DownloadReportRoute extends _i24.PageRouteInfo<void> { class DownloadReportRoute extends _i25.PageRouteInfo<void> {
const DownloadReportRoute({List<_i24.PageRouteInfo>? children}) const DownloadReportRoute({List<_i25.PageRouteInfo>? children})
: super(DownloadReportRoute.name, initialChildren: children); : super(DownloadReportRoute.name, initialChildren: children);
static const String name = 'DownloadReportRoute'; static const String name = 'DownloadReportRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i4.DownloadReportPage(); return const _i4.DownloadReportPage();
@ -126,16 +128,16 @@ class DownloadReportRoute extends _i24.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i5.ErrorPage] /// [_i5.ErrorPage]
class ErrorRoute extends _i24.PageRouteInfo<ErrorRouteArgs> { class ErrorRoute extends _i25.PageRouteInfo<ErrorRouteArgs> {
ErrorRoute({ ErrorRoute({
_i25.Key? key, _i26.Key? key,
String? title, String? title,
String? message, String? message,
_i25.VoidCallback? onRetry, _i26.VoidCallback? onRetry,
_i25.VoidCallback? onBack, _i26.VoidCallback? onBack,
String? errorCode, String? errorCode,
_i25.IconData? errorIcon, _i26.IconData? errorIcon,
List<_i24.PageRouteInfo>? children, List<_i25.PageRouteInfo>? children,
}) : super( }) : super(
ErrorRoute.name, ErrorRoute.name,
args: ErrorRouteArgs( args: ErrorRouteArgs(
@ -152,7 +154,7 @@ class ErrorRoute extends _i24.PageRouteInfo<ErrorRouteArgs> {
static const String name = 'ErrorRoute'; static const String name = 'ErrorRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
final args = data.argsAs<ErrorRouteArgs>( final args = data.argsAs<ErrorRouteArgs>(
@ -182,19 +184,19 @@ class ErrorRouteArgs {
this.errorIcon, this.errorIcon,
}); });
final _i25.Key? key; final _i26.Key? key;
final String? title; final String? title;
final String? message; final String? message;
final _i25.VoidCallback? onRetry; final _i26.VoidCallback? onRetry;
final _i25.VoidCallback? onBack; final _i26.VoidCallback? onBack;
final String? errorCode; final String? errorCode;
final _i25.IconData? errorIcon; final _i26.IconData? errorIcon;
@override @override
String toString() { String toString() {
@ -204,61 +206,61 @@ class ErrorRouteArgs {
/// generated route for /// generated route for
/// [_i6.FinancePage] /// [_i6.FinancePage]
class FinanceRoute extends _i24.PageRouteInfo<void> { class FinanceRoute extends _i25.PageRouteInfo<void> {
const FinanceRoute({List<_i24.PageRouteInfo>? children}) const FinanceRoute({List<_i25.PageRouteInfo>? children})
: super(FinanceRoute.name, initialChildren: children); : super(FinanceRoute.name, initialChildren: children);
static const String name = 'FinanceRoute'; static const String name = 'FinanceRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i6.FinancePage()); return _i25.WrappedRoute(child: const _i6.FinancePage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i7.HomePage] /// [_i7.HomePage]
class HomeRoute extends _i24.PageRouteInfo<void> { class HomeRoute extends _i25.PageRouteInfo<void> {
const HomeRoute({List<_i24.PageRouteInfo>? children}) const HomeRoute({List<_i25.PageRouteInfo>? children})
: super(HomeRoute.name, initialChildren: children); : super(HomeRoute.name, initialChildren: children);
static const String name = 'HomeRoute'; static const String name = 'HomeRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i7.HomePage()); return _i25.WrappedRoute(child: const _i7.HomePage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i8.InventoryPage] /// [_i8.InventoryPage]
class InventoryRoute extends _i24.PageRouteInfo<void> { class InventoryRoute extends _i25.PageRouteInfo<void> {
const InventoryRoute({List<_i24.PageRouteInfo>? children}) const InventoryRoute({List<_i25.PageRouteInfo>? children})
: super(InventoryRoute.name, initialChildren: children); : super(InventoryRoute.name, initialChildren: children);
static const String name = 'InventoryRoute'; static const String name = 'InventoryRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i8.InventoryPage()); return _i25.WrappedRoute(child: const _i8.InventoryPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i9.LanguagePage] /// [_i9.LanguagePage]
class LanguageRoute extends _i24.PageRouteInfo<void> { class LanguageRoute extends _i25.PageRouteInfo<void> {
const LanguageRoute({List<_i24.PageRouteInfo>? children}) const LanguageRoute({List<_i25.PageRouteInfo>? children})
: super(LanguageRoute.name, initialChildren: children); : super(LanguageRoute.name, initialChildren: children);
static const String name = 'LanguageRoute'; static const String name = 'LanguageRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i9.LanguagePage(); return const _i9.LanguagePage();
@ -268,29 +270,29 @@ class LanguageRoute extends _i24.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i10.LoginPage] /// [_i10.LoginPage]
class LoginRoute extends _i24.PageRouteInfo<void> { class LoginRoute extends _i25.PageRouteInfo<void> {
const LoginRoute({List<_i24.PageRouteInfo>? children}) const LoginRoute({List<_i25.PageRouteInfo>? children})
: super(LoginRoute.name, initialChildren: children); : super(LoginRoute.name, initialChildren: children);
static const String name = 'LoginRoute'; static const String name = 'LoginRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i10.LoginPage()); return _i25.WrappedRoute(child: const _i10.LoginPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i11.MainPage] /// [_i11.MainPage]
class MainRoute extends _i24.PageRouteInfo<void> { class MainRoute extends _i25.PageRouteInfo<void> {
const MainRoute({List<_i24.PageRouteInfo>? children}) const MainRoute({List<_i25.PageRouteInfo>? children})
: super(MainRoute.name, initialChildren: children); : super(MainRoute.name, initialChildren: children);
static const String name = 'MainRoute'; static const String name = 'MainRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i11.MainPage(); return const _i11.MainPage();
@ -300,11 +302,11 @@ class MainRoute extends _i24.PageRouteInfo<void> {
/// generated route for /// generated route for
/// [_i12.OrderDetailPage] /// [_i12.OrderDetailPage]
class OrderDetailRoute extends _i24.PageRouteInfo<OrderDetailRouteArgs> { class OrderDetailRoute extends _i25.PageRouteInfo<OrderDetailRouteArgs> {
OrderDetailRoute({ OrderDetailRoute({
_i25.Key? key, _i26.Key? key,
required _i26.Order order, required _i27.Order order,
List<_i24.PageRouteInfo>? children, List<_i25.PageRouteInfo>? children,
}) : super( }) : super(
OrderDetailRoute.name, OrderDetailRoute.name,
args: OrderDetailRouteArgs(key: key, order: order), args: OrderDetailRouteArgs(key: key, order: order),
@ -313,7 +315,7 @@ class OrderDetailRoute extends _i24.PageRouteInfo<OrderDetailRouteArgs> {
static const String name = 'OrderDetailRoute'; static const String name = 'OrderDetailRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
final args = data.argsAs<OrderDetailRouteArgs>(); final args = data.argsAs<OrderDetailRouteArgs>();
@ -325,9 +327,9 @@ class OrderDetailRoute extends _i24.PageRouteInfo<OrderDetailRouteArgs> {
class OrderDetailRouteArgs { class OrderDetailRouteArgs {
const OrderDetailRouteArgs({this.key, required this.order}); const OrderDetailRouteArgs({this.key, required this.order});
final _i25.Key? key; final _i26.Key? key;
final _i26.Order order; final _i27.Order order;
@override @override
String toString() { String toString() {
@ -337,75 +339,91 @@ class OrderDetailRouteArgs {
/// generated route for /// generated route for
/// [_i13.OrderPage] /// [_i13.OrderPage]
class OrderRoute extends _i24.PageRouteInfo<void> { class OrderRoute extends _i25.PageRouteInfo<void> {
const OrderRoute({List<_i24.PageRouteInfo>? children}) const OrderRoute({List<_i25.PageRouteInfo>? children})
: super(OrderRoute.name, initialChildren: children); : super(OrderRoute.name, initialChildren: children);
static const String name = 'OrderRoute'; static const String name = 'OrderRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i13.OrderPage()); return _i25.WrappedRoute(child: const _i13.OrderPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i14.OutletInformationPage] /// [_i14.OutletInformationPage]
class OutletInformationRoute extends _i24.PageRouteInfo<void> { class OutletInformationRoute extends _i25.PageRouteInfo<void> {
const OutletInformationRoute({List<_i24.PageRouteInfo>? children}) const OutletInformationRoute({List<_i25.PageRouteInfo>? children})
: super(OutletInformationRoute.name, initialChildren: children); : super(OutletInformationRoute.name, initialChildren: children);
static const String name = 'OutletInformationRoute'; static const String name = 'OutletInformationRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i14.OutletInformationPage()); return _i25.WrappedRoute(child: const _i14.OutletInformationPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i15.ProductAnalyticPage] /// [_i15.ProductAnalyticPage]
class ProductAnalyticRoute extends _i24.PageRouteInfo<void> { class ProductAnalyticRoute extends _i25.PageRouteInfo<void> {
const ProductAnalyticRoute({List<_i24.PageRouteInfo>? children}) const ProductAnalyticRoute({List<_i25.PageRouteInfo>? children})
: super(ProductAnalyticRoute.name, initialChildren: children); : super(ProductAnalyticRoute.name, initialChildren: children);
static const String name = 'ProductAnalyticRoute'; static const String name = 'ProductAnalyticRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i15.ProductAnalyticPage()); return _i25.WrappedRoute(child: const _i15.ProductAnalyticPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i16.ProductPage] /// [_i16.ProductPage]
class ProductRoute extends _i24.PageRouteInfo<void> { class ProductRoute extends _i25.PageRouteInfo<void> {
const ProductRoute({List<_i24.PageRouteInfo>? children}) const ProductRoute({List<_i25.PageRouteInfo>? children})
: super(ProductRoute.name, initialChildren: children); : super(ProductRoute.name, initialChildren: children);
static const String name = 'ProductRoute'; static const String name = 'ProductRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i16.ProductPage()); return _i25.WrappedRoute(child: const _i16.ProductPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i17.ProfileEditPage] /// [_i17.ProfileChangePasswordPage]
class ProfileEditRoute extends _i24.PageRouteInfo<ProfileEditRouteArgs> { class ProfileChangePasswordRoute extends _i25.PageRouteInfo<void> {
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<ProfileEditRouteArgs> {
ProfileEditRoute({ ProfileEditRoute({
_i25.Key? key, _i26.Key? key,
required _i27.User user, required _i28.User user,
List<_i24.PageRouteInfo>? children, List<_i25.PageRouteInfo>? children,
}) : super( }) : super(
ProfileEditRoute.name, ProfileEditRoute.name,
args: ProfileEditRouteArgs(key: key, user: user), args: ProfileEditRouteArgs(key: key, user: user),
@ -414,11 +432,13 @@ class ProfileEditRoute extends _i24.PageRouteInfo<ProfileEditRouteArgs> {
static const String name = 'ProfileEditRoute'; static const String name = 'ProfileEditRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
final args = data.argsAs<ProfileEditRouteArgs>(); final args = data.argsAs<ProfileEditRouteArgs>();
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<ProfileEditRouteArgs> {
class ProfileEditRouteArgs { class ProfileEditRouteArgs {
const ProfileEditRouteArgs({this.key, required this.user}); const ProfileEditRouteArgs({this.key, required this.user});
final _i25.Key? key; final _i26.Key? key;
final _i27.User user; final _i28.User user;
@override @override
String toString() { String toString() {
@ -437,97 +457,97 @@ class ProfileEditRouteArgs {
} }
/// generated route for /// generated route for
/// [_i18.ProfilePage] /// [_i19.ProfilePage]
class ProfileRoute extends _i24.PageRouteInfo<void> { class ProfileRoute extends _i25.PageRouteInfo<void> {
const ProfileRoute({List<_i24.PageRouteInfo>? children}) const ProfileRoute({List<_i25.PageRouteInfo>? children})
: super(ProfileRoute.name, initialChildren: children); : super(ProfileRoute.name, initialChildren: children);
static const String name = 'ProfileRoute'; static const String name = 'ProfileRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i18.ProfilePage()); return _i25.WrappedRoute(child: const _i19.ProfilePage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i19.PurchasePage] /// [_i20.PurchasePage]
class PurchaseRoute extends _i24.PageRouteInfo<void> { class PurchaseRoute extends _i25.PageRouteInfo<void> {
const PurchaseRoute({List<_i24.PageRouteInfo>? children}) const PurchaseRoute({List<_i25.PageRouteInfo>? children})
: super(PurchaseRoute.name, initialChildren: children); : super(PurchaseRoute.name, initialChildren: children);
static const String name = 'PurchaseRoute'; static const String name = 'PurchaseRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i19.PurchasePage(); return const _i20.PurchasePage();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i20.ReportPage] /// [_i21.ReportPage]
class ReportRoute extends _i24.PageRouteInfo<void> { class ReportRoute extends _i25.PageRouteInfo<void> {
const ReportRoute({List<_i24.PageRouteInfo>? children}) const ReportRoute({List<_i25.PageRouteInfo>? children})
: super(ReportRoute.name, initialChildren: children); : super(ReportRoute.name, initialChildren: children);
static const String name = 'ReportRoute'; static const String name = 'ReportRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i20.ReportPage()); return _i25.WrappedRoute(child: const _i21.ReportPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i21.SalesPage] /// [_i22.SalesPage]
class SalesRoute extends _i24.PageRouteInfo<void> { class SalesRoute extends _i25.PageRouteInfo<void> {
const SalesRoute({List<_i24.PageRouteInfo>? children}) const SalesRoute({List<_i25.PageRouteInfo>? children})
: super(SalesRoute.name, initialChildren: children); : super(SalesRoute.name, initialChildren: children);
static const String name = 'SalesRoute'; static const String name = 'SalesRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return _i24.WrappedRoute(child: const _i21.SalesPage()); return _i25.WrappedRoute(child: const _i22.SalesPage());
}, },
); );
} }
/// generated route for /// generated route for
/// [_i22.SchedulePage] /// [_i23.SchedulePage]
class ScheduleRoute extends _i24.PageRouteInfo<void> { class ScheduleRoute extends _i25.PageRouteInfo<void> {
const ScheduleRoute({List<_i24.PageRouteInfo>? children}) const ScheduleRoute({List<_i25.PageRouteInfo>? children})
: super(ScheduleRoute.name, initialChildren: children); : super(ScheduleRoute.name, initialChildren: children);
static const String name = 'ScheduleRoute'; static const String name = 'ScheduleRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i22.SchedulePage(); return const _i23.SchedulePage();
}, },
); );
} }
/// generated route for /// generated route for
/// [_i23.SplashPage] /// [_i24.SplashPage]
class SplashRoute extends _i24.PageRouteInfo<void> { class SplashRoute extends _i25.PageRouteInfo<void> {
const SplashRoute({List<_i24.PageRouteInfo>? children}) const SplashRoute({List<_i25.PageRouteInfo>? children})
: super(SplashRoute.name, initialChildren: children); : super(SplashRoute.name, initialChildren: children);
static const String name = 'SplashRoute'; static const String name = 'SplashRoute';
static _i24.PageInfo page = _i24.PageInfo( static _i25.PageInfo page = _i25.PageInfo(
name, name,
builder: (data) { builder: (data) {
return const _i23.SplashPage(); return const _i24.SplashPage();
}, },
); );
} }