feat: splash page done

This commit is contained in:
jahongireshonqulov
2025-10-31 12:29:30 +05:00
parent ab1ac6e6fa
commit 077ea23416
229 changed files with 3187 additions and 13517 deletions

View File

@@ -1,138 +0,0 @@
import 'package:food_delivery_client/core/services/request_handler_service.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/register_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/reset_password_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
abstract class AuthDatasource {
Future<LoginResponseModel> login({
required String phoneNumber,
required String password,
});
Future<SuccessModel> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
});
Future<SuccessModel> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
});
Future<SuccessModel> resetPassword({required ResetPasswordParams params});
Future<SuccessModel> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
});
Future<SuccessModel> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
});
Future<SuccessModel> register({required RegisterParams params});
}
@LazySingleton(as: AuthDatasource)
class AuthDatasourceImpl implements AuthDatasource {
final RequestHandlerService _requestHandlerService;
AuthDatasourceImpl(this._requestHandlerService);
@override
Future<LoginResponseModel> login({
required String phoneNumber,
required String password,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.login,
method: RequestMethodEnum.post,
data: {"password": password, "phoneNumber": phoneNumber},
fromJson: (response) async => LoginResponseModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> register({required RegisterParams params}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.register,
method: RequestMethodEnum.post,
data: {
"firstName": params.firstName,
"lastName": params.lastName,
"password": params.password,
"phoneNumber": params.phoneNumber,
},
fromJson: (response) async {
return SuccessModel.fromJson(response.data);
},
);
}
@override
Future<SuccessModel> resetPassword({
required ResetPasswordParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.resetPassword,
method: RequestMethodEnum.post,
data: {
"newPassword": params.newPassword,
"phoneNumber": params.phoneNumber,
},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.verifyCode,
method: RequestMethodEnum.post,
data: {"code": params.otpCode, "phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.forgotPassword,
method: RequestMethodEnum.post,
data: {"code": params.otpCode, "phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.verifyPhone,
method: RequestMethodEnum.post,
data: {"phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
@override
Future<SuccessModel> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequest(
path: ApiConst.sendCode,
method: RequestMethodEnum.post,
data: {"phoneNumber": params.phoneNumber},
fromJson: (response) async => SuccessModel.fromJson(response.data),
);
}
}

View File

@@ -1,26 +0,0 @@
import 'package:equatable/equatable.dart';
class LoginResponseModel extends Equatable {
final String token;
const LoginResponseModel({required this.token});
factory LoginResponseModel.fromJson(Map<String, dynamic> json) {
return LoginResponseModel(
token: json['token'] as String,
);
}
Map<String, dynamic> toJson() => {
'token': token,
};
LoginResponseModel copyWith({String? token}) {
return LoginResponseModel(
token: token ?? this.token,
);
}
@override
List<Object?> get props => [token];
}

View File

@@ -1,90 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/services/request_handler_service.dart';
import 'package:food_delivery_client/feature/auth/data/datasource/auth_datasource.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../domain/repository/auth_repository.dart';
import '../../domain/usecases/register_usecase.dart';
import '../../domain/usecases/reset_password_usecase.dart';
import '../../domain/usecases/verify_otp_code_login_usecase.dart';
import '../../domain/usecases/verify_phone_login_usecase.dart';
@LazySingleton(as: AuthRepository)
class AuthRepositoryImpl implements AuthRepository {
final RequestHandlerService _requestHandlerService;
final AuthDatasource _authDatasource;
AuthRepositoryImpl(this._requestHandlerService, this._authDatasource);
@override
Future<Either<Failure, LoginResponseModel>> login({
required String phoneNumber,
required String password,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () async {
return _authDatasource.login(
phoneNumber: phoneNumber,
password: password,
);
},
);
}
@override
Future<Either<Failure, SuccessModel>> register({
required RegisterParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () async => _authDatasource.register(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> resetPassword({
required ResetPasswordParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.resetPassword(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.verifyOtpCodeRegister(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () =>
_authDatasource.verifyOtpCodeResetPassword(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.verifyPhoneRegister(params: params),
);
}
@override
Future<Either<Failure, SuccessModel>> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
}) async {
return _requestHandlerService.handleRequestInRepository(
onRequest: () => _authDatasource.verifyPhoneResetPassword(params: params),
);
}
}

View File

@@ -1,43 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/services/request_handler_service.dart';
import 'package:food_delivery_client/feature/auth/data/datasource/auth_datasource.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../usecases/register_usecase.dart';
import '../usecases/reset_password_usecase.dart';
import '../usecases/verify_otp_code_login_usecase.dart';
import '../usecases/verify_phone_login_usecase.dart';
abstract class AuthRepository {
Future<Either<Failure, LoginResponseModel>> login({
required String phoneNumber,
required String password,
});
Future<Either<Failure, SuccessModel>> verifyPhoneResetPassword({
required VerifyPhoneNumberParams params,
});
Future<Either<Failure, SuccessModel>> verifyOtpCodeResetPassword({
required VerifyOtpCodeParams params,
});
Future<Either<Failure, SuccessModel>> resetPassword({
required ResetPasswordParams params,
});
Future<Either<Failure, SuccessModel>> verifyPhoneRegister({
required VerifyPhoneNumberParams params,
});
Future<Either<Failure, SuccessModel>> verifyOtpCodeRegister({
required VerifyOtpCodeParams params,
});
Future<Either<Failure, SuccessModel>> register({
required RegisterParams params,
});
}

View File

@@ -1,26 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/usecase/usecase.dart';
import 'package:food_delivery_client/feature/auth/data/models/response/login_response.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
@injectable
class LoginUseCase implements UseCase<LoginResponseModel, LoginParams> {
final AuthRepository _authRepository;
LoginUseCase(this._authRepository);
@override
Future<Either<Failure, LoginResponseModel>> call(LoginParams params) async {
return _authRepository.login(
phoneNumber: params.phoneNumber,
password: params.password,
);
}
}
class LoginParams {
final String phoneNumber;
final String password;
LoginParams({required this.phoneNumber, required this.password});
}

View File

@@ -1,32 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/exceptions/failure.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/common/common.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class RegisterUseCase implements UseCase<SuccessModel, RegisterParams> {
final AuthRepository _authRepository;
RegisterUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(RegisterParams params) async {
return _authRepository.register(params: params);
}
}
class RegisterParams {
final String firstName;
final String lastName;
final String phoneNumber;
final String password;
RegisterParams({
required this.firstName,
required this.lastName,
required this.phoneNumber,
required this.password,
});
}

View File

@@ -1,26 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/exceptions/failure.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/common/common.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class ResetPasswordUseCase
implements UseCase<SuccessModel, ResetPasswordParams> {
final AuthRepository _authRepository;
ResetPasswordUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(ResetPasswordParams params) async {
return _authRepository.resetPassword(params: params);
}
}
class ResetPasswordParams {
final String newPassword;
final String phoneNumber;
ResetPasswordParams({required this.newPassword, required this.phoneNumber});
}

View File

@@ -1,33 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyOtpCodeForgotPasswordUseCase
implements UseCase<SuccessModel, VerifyOtpCodeParams> {
final AuthRepository _authRepository;
VerifyOtpCodeForgotPasswordUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(VerifyOtpCodeParams params) async {
return _authRepository.verifyOtpCodeResetPassword(params: params);
}
}
class VerifyOtpCodeParams {
final dynamic otpCode;
final String phoneNumber;
VerifyOtpCodeParams({required this.otpCode, required this.phoneNumber});
}
class OtpCodePageParams {
final String phoneNumber;
final bool isRegister;
OtpCodePageParams({required this.phoneNumber, required this.isRegister});
}

View File

@@ -1,19 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyOtpCodeRegisterUseCase
implements UseCase<SuccessModel, VerifyOtpCodeParams> {
final AuthRepository _authRepository;
VerifyOtpCodeRegisterUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(VerifyOtpCodeParams params) async {
return _authRepository.verifyOtpCodeRegister(params: params);
}
}

View File

@@ -1,27 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/core/exceptions/failure.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/common/common.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyPhoneNumberLoginUseCase
implements UseCase<SuccessModel, VerifyPhoneNumberParams> {
final AuthRepository _authRepository;
VerifyPhoneNumberLoginUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(
VerifyPhoneNumberParams params,
) async {
return _authRepository.verifyPhoneResetPassword(params: params);
}
}
class VerifyPhoneNumberParams {
final String phoneNumber;
VerifyPhoneNumberParams({required this.phoneNumber});
}

View File

@@ -1,21 +0,0 @@
import 'package:dartz/dartz.dart';
import 'package:food_delivery_client/feature/auth/domain/repository/auth_repository.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
import '../../../../core/usecase/usecase.dart';
@injectable
class VerifyPhoneRegisterUseCase
implements UseCase<SuccessModel, VerifyPhoneNumberParams> {
final AuthRepository _authRepository;
VerifyPhoneRegisterUseCase(this._authRepository);
@override
Future<Either<Failure, SuccessModel>> call(
VerifyPhoneNumberParams params,
) async {
return _authRepository.verifyPhoneRegister(params: params);
}
}

View File

@@ -1,41 +0,0 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/login_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'login_event.dart';
part 'login_state.dart';
part 'login_bloc.freezed.dart';
@injectable
class LoginBloc extends Bloc<LoginEvent, LoginState> {
final LoginUseCase _loginUseCase;
final StorageService _storageService;
LoginBloc(this._loginUseCase, this._storageService)
: super(const LoginState()) {
on<_Login>(_onLogin);
}
Future<void> _onLogin(_Login event, Emitter<LoginState> emit) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _loginUseCase.call(event.params);
response.fold(
(l) {
log("${l.errorMessage}");
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast("Login success");
_storageService.setString(key: AppLocaleKeys.token, value: r.token);
final token = _storageService.getString(key: AppLocaleKeys.token);
log('Token:$token');
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -1,535 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'login_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$LoginEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'LoginEvent()';
}
}
/// @nodoc
class $LoginEventCopyWith<$Res> {
$LoginEventCopyWith(LoginEvent _, $Res Function(LoginEvent) __);
}
/// Adds pattern-matching-related methods to [LoginEvent].
extension LoginEventPatterns on LoginEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Checked value)? checked,TResult Function( _Login value)? login,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked(_that);case _Login() when login != null:
return login(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Checked value) checked,required TResult Function( _Login value) login,}){
final _that = this;
switch (_that) {
case _Checked():
return checked(_that);case _Login():
return login(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Checked value)? checked,TResult? Function( _Login value)? login,}){
final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked(_that);case _Login() when login != null:
return login(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? checked,TResult Function( LoginParams params)? login,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked();case _Login() when login != null:
return login(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() checked,required TResult Function( LoginParams params) login,}) {final _that = this;
switch (_that) {
case _Checked():
return checked();case _Login():
return login(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? checked,TResult? Function( LoginParams params)? login,}) {final _that = this;
switch (_that) {
case _Checked() when checked != null:
return checked();case _Login() when login != null:
return login(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Checked implements LoginEvent {
const _Checked();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Checked);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'LoginEvent.checked()';
}
}
/// @nodoc
class _Login implements LoginEvent {
const _Login(this.params);
final LoginParams params;
/// Create a copy of LoginEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoginCopyWith<_Login> get copyWith => __$LoginCopyWithImpl<_Login>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Login&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'LoginEvent.login(params: $params)';
}
}
/// @nodoc
abstract mixin class _$LoginCopyWith<$Res> implements $LoginEventCopyWith<$Res> {
factory _$LoginCopyWith(_Login value, $Res Function(_Login) _then) = __$LoginCopyWithImpl;
@useResult
$Res call({
LoginParams params
});
}
/// @nodoc
class __$LoginCopyWithImpl<$Res>
implements _$LoginCopyWith<$Res> {
__$LoginCopyWithImpl(this._self, this._then);
final _Login _self;
final $Res Function(_Login) _then;
/// Create a copy of LoginEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_Login(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as LoginParams,
));
}
}
/// @nodoc
mixin _$LoginState {
RequestStatus get status;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$LoginStateCopyWith<LoginState> get copyWith => _$LoginStateCopyWithImpl<LoginState>(this as LoginState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'LoginState(status: $status)';
}
}
/// @nodoc
abstract mixin class $LoginStateCopyWith<$Res> {
factory $LoginStateCopyWith(LoginState value, $Res Function(LoginState) _then) = _$LoginStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$LoginStateCopyWithImpl<$Res>
implements $LoginStateCopyWith<$Res> {
_$LoginStateCopyWithImpl(this._self, this._then);
final LoginState _self;
final $Res Function(LoginState) _then;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [LoginState].
extension LoginStatePatterns on LoginState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _LoginState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _LoginState value) $default,){
final _that = this;
switch (_that) {
case _LoginState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _LoginState value)? $default,){
final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _LoginState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _LoginState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _LoginState implements LoginState {
const _LoginState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoginStateCopyWith<_LoginState> get copyWith => __$LoginStateCopyWithImpl<_LoginState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'LoginState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$LoginStateCopyWith<$Res> implements $LoginStateCopyWith<$Res> {
factory _$LoginStateCopyWith(_LoginState value, $Res Function(_LoginState) _then) = __$LoginStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$LoginStateCopyWithImpl<$Res>
implements _$LoginStateCopyWith<$Res> {
__$LoginStateCopyWithImpl(this._self, this._then);
final _LoginState _self;
final $Res Function(_LoginState) _then;
/// Create a copy of LoginState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_LoginState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -1,8 +0,0 @@
part of 'login_bloc.dart';
@freezed
class LoginEvent with _$LoginEvent {
const factory LoginEvent.checked() = _Checked;
const factory LoginEvent.login(LoginParams params) = _Login;
}

View File

@@ -1,8 +0,0 @@
part of 'login_bloc.dart';
@freezed
abstract class LoginState with _$LoginState {
const factory LoginState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _LoginState;
}

View File

@@ -1,35 +0,0 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/register_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'register_event.dart';
part 'register_state.dart';
part 'register_bloc.freezed.dart';
@injectable
class RegisterBloc extends Bloc<RegisterEvent, RegisterState> {
final RegisterUseCase _registerUseCase;
RegisterBloc(this._registerUseCase) : super(const RegisterState()) {
on<_Loaded>(_onLoaded);
}
Future<void> _onLoaded(_Loaded event, Emitter<RegisterState> emit) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _registerUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -1,535 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'register_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$RegisterEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'RegisterEvent()';
}
}
/// @nodoc
class $RegisterEventCopyWith<$Res> {
$RegisterEventCopyWith(RegisterEvent _, $Res Function(RegisterEvent) __);
}
/// Adds pattern-matching-related methods to [RegisterEvent].
extension RegisterEventPatterns on RegisterEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _Loaded value)? loaded,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _Loaded value) loaded,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _Loaded():
return loaded(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _Loaded value)? loaded,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function( RegisterParams params)? loaded,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function( RegisterParams params) loaded,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _Loaded():
return loaded(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function( RegisterParams params)? loaded,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements RegisterEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'RegisterEvent.started()';
}
}
/// @nodoc
class _Loaded implements RegisterEvent {
const _Loaded(this.params);
final RegisterParams params;
/// Create a copy of RegisterEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoadedCopyWith<_Loaded> get copyWith => __$LoadedCopyWithImpl<_Loaded>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Loaded&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'RegisterEvent.loaded(params: $params)';
}
}
/// @nodoc
abstract mixin class _$LoadedCopyWith<$Res> implements $RegisterEventCopyWith<$Res> {
factory _$LoadedCopyWith(_Loaded value, $Res Function(_Loaded) _then) = __$LoadedCopyWithImpl;
@useResult
$Res call({
RegisterParams params
});
}
/// @nodoc
class __$LoadedCopyWithImpl<$Res>
implements _$LoadedCopyWith<$Res> {
__$LoadedCopyWithImpl(this._self, this._then);
final _Loaded _self;
final $Res Function(_Loaded) _then;
/// Create a copy of RegisterEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_Loaded(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as RegisterParams,
));
}
}
/// @nodoc
mixin _$RegisterState {
RequestStatus get status;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$RegisterStateCopyWith<RegisterState> get copyWith => _$RegisterStateCopyWithImpl<RegisterState>(this as RegisterState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'RegisterState(status: $status)';
}
}
/// @nodoc
abstract mixin class $RegisterStateCopyWith<$Res> {
factory $RegisterStateCopyWith(RegisterState value, $Res Function(RegisterState) _then) = _$RegisterStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$RegisterStateCopyWithImpl<$Res>
implements $RegisterStateCopyWith<$Res> {
_$RegisterStateCopyWithImpl(this._self, this._then);
final RegisterState _self;
final $Res Function(RegisterState) _then;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [RegisterState].
extension RegisterStatePatterns on RegisterState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _RegisterState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _RegisterState value) $default,){
final _that = this;
switch (_that) {
case _RegisterState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _RegisterState value)? $default,){
final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _RegisterState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _RegisterState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _RegisterState implements RegisterState {
const _RegisterState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$RegisterStateCopyWith<_RegisterState> get copyWith => __$RegisterStateCopyWithImpl<_RegisterState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegisterState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'RegisterState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$RegisterStateCopyWith<$Res> implements $RegisterStateCopyWith<$Res> {
factory _$RegisterStateCopyWith(_RegisterState value, $Res Function(_RegisterState) _then) = __$RegisterStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$RegisterStateCopyWithImpl<$Res>
implements _$RegisterStateCopyWith<$Res> {
__$RegisterStateCopyWithImpl(this._self, this._then);
final _RegisterState _self;
final $Res Function(_RegisterState) _then;
/// Create a copy of RegisterState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_RegisterState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -1,8 +0,0 @@
part of 'register_bloc.dart';
@freezed
class RegisterEvent with _$RegisterEvent {
const factory RegisterEvent.started() = _Started;
const factory RegisterEvent.loaded(RegisterParams params) = _Loaded;
}

View File

@@ -1,8 +0,0 @@
part of 'register_bloc.dart';
@freezed
abstract class RegisterState with _$RegisterState {
const factory RegisterState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _RegisterState;
}

View File

@@ -1,36 +0,0 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/reset_password_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'reset_password_event.dart';
part 'reset_password_state.dart';
part 'reset_password_bloc.freezed.dart';
@injectable
class ResetPasswordBloc extends Bloc<ResetPasswordEvent, ResetPasswordState> {
final ResetPasswordUseCase _passwordUseCase;
ResetPasswordBloc(this._passwordUseCase) : super(const ResetPasswordState()) {
on<_Loaded>(_onLoaded);
}
Future<void> _onLoaded(
_Loaded event,
Emitter<ResetPasswordState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _passwordUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -1,535 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'reset_password_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$ResetPasswordEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ResetPasswordEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'ResetPasswordEvent()';
}
}
/// @nodoc
class $ResetPasswordEventCopyWith<$Res> {
$ResetPasswordEventCopyWith(ResetPasswordEvent _, $Res Function(ResetPasswordEvent) __);
}
/// Adds pattern-matching-related methods to [ResetPasswordEvent].
extension ResetPasswordEventPatterns on ResetPasswordEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _Loaded value)? loaded,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _Loaded value) loaded,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _Loaded():
return loaded(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _Loaded value)? loaded,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _Loaded() when loaded != null:
return loaded(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function( ResetPasswordParams params)? loaded,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function( ResetPasswordParams params) loaded,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _Loaded():
return loaded(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function( ResetPasswordParams params)? loaded,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _Loaded() when loaded != null:
return loaded(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements ResetPasswordEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'ResetPasswordEvent.started()';
}
}
/// @nodoc
class _Loaded implements ResetPasswordEvent {
const _Loaded(this.params);
final ResetPasswordParams params;
/// Create a copy of ResetPasswordEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$LoadedCopyWith<_Loaded> get copyWith => __$LoadedCopyWithImpl<_Loaded>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Loaded&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'ResetPasswordEvent.loaded(params: $params)';
}
}
/// @nodoc
abstract mixin class _$LoadedCopyWith<$Res> implements $ResetPasswordEventCopyWith<$Res> {
factory _$LoadedCopyWith(_Loaded value, $Res Function(_Loaded) _then) = __$LoadedCopyWithImpl;
@useResult
$Res call({
ResetPasswordParams params
});
}
/// @nodoc
class __$LoadedCopyWithImpl<$Res>
implements _$LoadedCopyWith<$Res> {
__$LoadedCopyWithImpl(this._self, this._then);
final _Loaded _self;
final $Res Function(_Loaded) _then;
/// Create a copy of ResetPasswordEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_Loaded(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as ResetPasswordParams,
));
}
}
/// @nodoc
mixin _$ResetPasswordState {
RequestStatus get status;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$ResetPasswordStateCopyWith<ResetPasswordState> get copyWith => _$ResetPasswordStateCopyWithImpl<ResetPasswordState>(this as ResetPasswordState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ResetPasswordState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'ResetPasswordState(status: $status)';
}
}
/// @nodoc
abstract mixin class $ResetPasswordStateCopyWith<$Res> {
factory $ResetPasswordStateCopyWith(ResetPasswordState value, $Res Function(ResetPasswordState) _then) = _$ResetPasswordStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$ResetPasswordStateCopyWithImpl<$Res>
implements $ResetPasswordStateCopyWith<$Res> {
_$ResetPasswordStateCopyWithImpl(this._self, this._then);
final ResetPasswordState _self;
final $Res Function(ResetPasswordState) _then;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [ResetPasswordState].
extension ResetPasswordStatePatterns on ResetPasswordState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _ResetPasswordState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _ResetPasswordState value) $default,){
final _that = this;
switch (_that) {
case _ResetPasswordState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _ResetPasswordState value)? $default,){
final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _ResetPasswordState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _ResetPasswordState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _ResetPasswordState implements ResetPasswordState {
const _ResetPasswordState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ResetPasswordStateCopyWith<_ResetPasswordState> get copyWith => __$ResetPasswordStateCopyWithImpl<_ResetPasswordState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResetPasswordState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'ResetPasswordState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$ResetPasswordStateCopyWith<$Res> implements $ResetPasswordStateCopyWith<$Res> {
factory _$ResetPasswordStateCopyWith(_ResetPasswordState value, $Res Function(_ResetPasswordState) _then) = __$ResetPasswordStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$ResetPasswordStateCopyWithImpl<$Res>
implements _$ResetPasswordStateCopyWith<$Res> {
__$ResetPasswordStateCopyWithImpl(this._self, this._then);
final _ResetPasswordState _self;
final $Res Function(_ResetPasswordState) _then;
/// Create a copy of ResetPasswordState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_ResetPasswordState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -1,8 +0,0 @@
part of 'reset_password_bloc.dart';
@freezed
class ResetPasswordEvent with _$ResetPasswordEvent {
const factory ResetPasswordEvent.started() = _Started;
const factory ResetPasswordEvent.loaded(ResetPasswordParams params) = _Loaded;
}

View File

@@ -1,8 +0,0 @@
part of 'reset_password_bloc.dart';
@freezed
abstract class ResetPasswordState with _$ResetPasswordState {
const factory ResetPasswordState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _ResetPasswordState;
}

View File

@@ -1,140 +0,0 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_register_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_register_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'verify_otp_event.dart';
part 'verify_otp_state.dart';
part 'verify_otp_bloc.freezed.dart';
@injectable
class VerifyOtpBloc extends Bloc<VerifyOtpEvent, VerifyOtpState> {
final VerifyOtpCodeRegisterUseCase _registerUseCase;
final VerifyOtpCodeForgotPasswordUseCase _passwordUseCase;
final VerifyPhoneRegisterUseCase _phoneRegisterUseCase;
final VerifyPhoneNumberLoginUseCase _phoneNumberLoginUseCase;
VerifyOtpBloc(
this._registerUseCase,
this._passwordUseCase,
this._phoneRegisterUseCase,
this._phoneNumberLoginUseCase,
) : super(const VerifyOtpState()) {
Timer? timer1;
on<_CancelTimer>((event, emit) {
timer1?.cancel();
});
on<_Started>((event, emit) {
int seconds = state.time;
emit(state.copyWith(time: seconds));
timer1 = Timer.periodic(TimeDelayConst.duration1, (timer) {
if (seconds == 0) {
timer.cancel();
} else {
seconds--;
add(VerifyOtpEvent.ticked(seconds));
}
});
});
on<_Ticked>(_onTicked);
on<_VerifyOtpReset>(_onVerifyOtpReset);
on<_VerifyOtpRegister>(_onVerifyOtpRegister);
on<_ResendRegister>(_onResendVerifyPhoneRegister);
on<_ResendForgot>(_onResendVerifyPhoneForgot);
}
void _onTicked(_Ticked event, Emitter<VerifyOtpState> emit) {
emit(state.copyWith(time: event.seconds));
}
Future<void> _onVerifyOtpReset(
_VerifyOtpReset event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _passwordUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
add(VerifyOtpEvent.cancelTimer());
},
);
}
Future<void> _onVerifyOtpRegister(
_VerifyOtpRegister event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _registerUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
add(VerifyOtpEvent.cancelTimer());
},
);
}
Future<void> _onResendVerifyPhoneRegister(
_ResendRegister event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(resendStatus: RequestStatus.loading));
final response = await _phoneRegisterUseCase.call(
VerifyPhoneNumberParams(phoneNumber: event.phoneNUmber),
);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(resendStatus: RequestStatus.error));
},
(r) {
emit(state.copyWith(resendStatus: RequestStatus.loaded));
add(VerifyOtpEvent.ticked(120));
add(VerifyOtpEvent.started());
},
);
}
Future<void> _onResendVerifyPhoneForgot(
_ResendForgot event,
Emitter<VerifyOtpState> emit,
) async {
emit(state.copyWith(resendStatus: RequestStatus.loading));
final response = await _phoneNumberLoginUseCase.call(
VerifyPhoneNumberParams(phoneNumber: event.phoneNUmber),
);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(resendStatus: RequestStatus.error));
},
(r) {
emit(state.copyWith(resendStatus: RequestStatus.loaded));
add(VerifyOtpEvent.ticked(120));
add(VerifyOtpEvent.started());
},
);
}
}

View File

@@ -1,867 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'verify_otp_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$VerifyOtpEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyOtpEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyOtpEvent()';
}
}
/// @nodoc
class $VerifyOtpEventCopyWith<$Res> {
$VerifyOtpEventCopyWith(VerifyOtpEvent _, $Res Function(VerifyOtpEvent) __);
}
/// Adds pattern-matching-related methods to [VerifyOtpEvent].
extension VerifyOtpEventPatterns on VerifyOtpEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _CancelTimer value)? cancelTimer,TResult Function( _ResendRegister value)? resendRegister,TResult Function( _ResendForgot value)? resendForgot,TResult Function( _Ticked value)? ticked,TResult Function( _VerifyOtpReset value)? verifyOtpReset,TResult Function( _VerifyOtpRegister value)? verifyOtpRegister,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _CancelTimer() when cancelTimer != null:
return cancelTimer(_that);case _ResendRegister() when resendRegister != null:
return resendRegister(_that);case _ResendForgot() when resendForgot != null:
return resendForgot(_that);case _Ticked() when ticked != null:
return ticked(_that);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _CancelTimer value) cancelTimer,required TResult Function( _ResendRegister value) resendRegister,required TResult Function( _ResendForgot value) resendForgot,required TResult Function( _Ticked value) ticked,required TResult Function( _VerifyOtpReset value) verifyOtpReset,required TResult Function( _VerifyOtpRegister value) verifyOtpRegister,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _CancelTimer():
return cancelTimer(_that);case _ResendRegister():
return resendRegister(_that);case _ResendForgot():
return resendForgot(_that);case _Ticked():
return ticked(_that);case _VerifyOtpReset():
return verifyOtpReset(_that);case _VerifyOtpRegister():
return verifyOtpRegister(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _CancelTimer value)? cancelTimer,TResult? Function( _ResendRegister value)? resendRegister,TResult? Function( _ResendForgot value)? resendForgot,TResult? Function( _Ticked value)? ticked,TResult? Function( _VerifyOtpReset value)? verifyOtpReset,TResult? Function( _VerifyOtpRegister value)? verifyOtpRegister,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _CancelTimer() when cancelTimer != null:
return cancelTimer(_that);case _ResendRegister() when resendRegister != null:
return resendRegister(_that);case _ResendForgot() when resendForgot != null:
return resendForgot(_that);case _Ticked() when ticked != null:
return ticked(_that);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function()? cancelTimer,TResult Function( String phoneNUmber)? resendRegister,TResult Function( String phoneNUmber)? resendForgot,TResult Function( int seconds)? ticked,TResult Function( VerifyOtpCodeParams params)? verifyOtpReset,TResult Function( VerifyOtpCodeParams params)? verifyOtpRegister,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _CancelTimer() when cancelTimer != null:
return cancelTimer();case _ResendRegister() when resendRegister != null:
return resendRegister(_that.phoneNUmber);case _ResendForgot() when resendForgot != null:
return resendForgot(_that.phoneNUmber);case _Ticked() when ticked != null:
return ticked(_that.seconds);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that.params);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function() cancelTimer,required TResult Function( String phoneNUmber) resendRegister,required TResult Function( String phoneNUmber) resendForgot,required TResult Function( int seconds) ticked,required TResult Function( VerifyOtpCodeParams params) verifyOtpReset,required TResult Function( VerifyOtpCodeParams params) verifyOtpRegister,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _CancelTimer():
return cancelTimer();case _ResendRegister():
return resendRegister(_that.phoneNUmber);case _ResendForgot():
return resendForgot(_that.phoneNUmber);case _Ticked():
return ticked(_that.seconds);case _VerifyOtpReset():
return verifyOtpReset(_that.params);case _VerifyOtpRegister():
return verifyOtpRegister(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function()? cancelTimer,TResult? Function( String phoneNUmber)? resendRegister,TResult? Function( String phoneNUmber)? resendForgot,TResult? Function( int seconds)? ticked,TResult? Function( VerifyOtpCodeParams params)? verifyOtpReset,TResult? Function( VerifyOtpCodeParams params)? verifyOtpRegister,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _CancelTimer() when cancelTimer != null:
return cancelTimer();case _ResendRegister() when resendRegister != null:
return resendRegister(_that.phoneNUmber);case _ResendForgot() when resendForgot != null:
return resendForgot(_that.phoneNUmber);case _Ticked() when ticked != null:
return ticked(_that.seconds);case _VerifyOtpReset() when verifyOtpReset != null:
return verifyOtpReset(_that.params);case _VerifyOtpRegister() when verifyOtpRegister != null:
return verifyOtpRegister(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements VerifyOtpEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyOtpEvent.started()';
}
}
/// @nodoc
class _CancelTimer implements VerifyOtpEvent {
const _CancelTimer();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CancelTimer);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyOtpEvent.cancelTimer()';
}
}
/// @nodoc
class _ResendRegister implements VerifyOtpEvent {
const _ResendRegister(this.phoneNUmber);
final String phoneNUmber;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ResendRegisterCopyWith<_ResendRegister> get copyWith => __$ResendRegisterCopyWithImpl<_ResendRegister>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendRegister&&(identical(other.phoneNUmber, phoneNUmber) || other.phoneNUmber == phoneNUmber));
}
@override
int get hashCode => Object.hash(runtimeType,phoneNUmber);
@override
String toString() {
return 'VerifyOtpEvent.resendRegister(phoneNUmber: $phoneNUmber)';
}
}
/// @nodoc
abstract mixin class _$ResendRegisterCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$ResendRegisterCopyWith(_ResendRegister value, $Res Function(_ResendRegister) _then) = __$ResendRegisterCopyWithImpl;
@useResult
$Res call({
String phoneNUmber
});
}
/// @nodoc
class __$ResendRegisterCopyWithImpl<$Res>
implements _$ResendRegisterCopyWith<$Res> {
__$ResendRegisterCopyWithImpl(this._self, this._then);
final _ResendRegister _self;
final $Res Function(_ResendRegister) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? phoneNUmber = null,}) {
return _then(_ResendRegister(
null == phoneNUmber ? _self.phoneNUmber : phoneNUmber // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _ResendForgot implements VerifyOtpEvent {
const _ResendForgot(this.phoneNUmber);
final String phoneNUmber;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$ResendForgotCopyWith<_ResendForgot> get copyWith => __$ResendForgotCopyWithImpl<_ResendForgot>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendForgot&&(identical(other.phoneNUmber, phoneNUmber) || other.phoneNUmber == phoneNUmber));
}
@override
int get hashCode => Object.hash(runtimeType,phoneNUmber);
@override
String toString() {
return 'VerifyOtpEvent.resendForgot(phoneNUmber: $phoneNUmber)';
}
}
/// @nodoc
abstract mixin class _$ResendForgotCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$ResendForgotCopyWith(_ResendForgot value, $Res Function(_ResendForgot) _then) = __$ResendForgotCopyWithImpl;
@useResult
$Res call({
String phoneNUmber
});
}
/// @nodoc
class __$ResendForgotCopyWithImpl<$Res>
implements _$ResendForgotCopyWith<$Res> {
__$ResendForgotCopyWithImpl(this._self, this._then);
final _ResendForgot _self;
final $Res Function(_ResendForgot) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? phoneNUmber = null,}) {
return _then(_ResendForgot(
null == phoneNUmber ? _self.phoneNUmber : phoneNUmber // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// @nodoc
class _Ticked implements VerifyOtpEvent {
const _Ticked(this.seconds);
final int seconds;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$TickedCopyWith<_Ticked> get copyWith => __$TickedCopyWithImpl<_Ticked>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Ticked&&(identical(other.seconds, seconds) || other.seconds == seconds));
}
@override
int get hashCode => Object.hash(runtimeType,seconds);
@override
String toString() {
return 'VerifyOtpEvent.ticked(seconds: $seconds)';
}
}
/// @nodoc
abstract mixin class _$TickedCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$TickedCopyWith(_Ticked value, $Res Function(_Ticked) _then) = __$TickedCopyWithImpl;
@useResult
$Res call({
int seconds
});
}
/// @nodoc
class __$TickedCopyWithImpl<$Res>
implements _$TickedCopyWith<$Res> {
__$TickedCopyWithImpl(this._self, this._then);
final _Ticked _self;
final $Res Function(_Ticked) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? seconds = null,}) {
return _then(_Ticked(
null == seconds ? _self.seconds : seconds // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
class _VerifyOtpReset implements VerifyOtpEvent {
const _VerifyOtpReset(this.params);
final VerifyOtpCodeParams params;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyOtpResetCopyWith<_VerifyOtpReset> get copyWith => __$VerifyOtpResetCopyWithImpl<_VerifyOtpReset>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyOtpReset&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyOtpEvent.verifyOtpReset(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyOtpResetCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$VerifyOtpResetCopyWith(_VerifyOtpReset value, $Res Function(_VerifyOtpReset) _then) = __$VerifyOtpResetCopyWithImpl;
@useResult
$Res call({
VerifyOtpCodeParams params
});
}
/// @nodoc
class __$VerifyOtpResetCopyWithImpl<$Res>
implements _$VerifyOtpResetCopyWith<$Res> {
__$VerifyOtpResetCopyWithImpl(this._self, this._then);
final _VerifyOtpReset _self;
final $Res Function(_VerifyOtpReset) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyOtpReset(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyOtpCodeParams,
));
}
}
/// @nodoc
class _VerifyOtpRegister implements VerifyOtpEvent {
const _VerifyOtpRegister(this.params);
final VerifyOtpCodeParams params;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyOtpRegisterCopyWith<_VerifyOtpRegister> get copyWith => __$VerifyOtpRegisterCopyWithImpl<_VerifyOtpRegister>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyOtpRegister&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyOtpEvent.verifyOtpRegister(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyOtpRegisterCopyWith<$Res> implements $VerifyOtpEventCopyWith<$Res> {
factory _$VerifyOtpRegisterCopyWith(_VerifyOtpRegister value, $Res Function(_VerifyOtpRegister) _then) = __$VerifyOtpRegisterCopyWithImpl;
@useResult
$Res call({
VerifyOtpCodeParams params
});
}
/// @nodoc
class __$VerifyOtpRegisterCopyWithImpl<$Res>
implements _$VerifyOtpRegisterCopyWith<$Res> {
__$VerifyOtpRegisterCopyWithImpl(this._self, this._then);
final _VerifyOtpRegister _self;
final $Res Function(_VerifyOtpRegister) _then;
/// Create a copy of VerifyOtpEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyOtpRegister(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyOtpCodeParams,
));
}
}
/// @nodoc
mixin _$VerifyOtpState {
RequestStatus get status; RequestStatus get resendStatus; int get time;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$VerifyOtpStateCopyWith<VerifyOtpState> get copyWith => _$VerifyOtpStateCopyWithImpl<VerifyOtpState>(this as VerifyOtpState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyOtpState&&(identical(other.status, status) || other.status == status)&&(identical(other.resendStatus, resendStatus) || other.resendStatus == resendStatus)&&(identical(other.time, time) || other.time == time));
}
@override
int get hashCode => Object.hash(runtimeType,status,resendStatus,time);
@override
String toString() {
return 'VerifyOtpState(status: $status, resendStatus: $resendStatus, time: $time)';
}
}
/// @nodoc
abstract mixin class $VerifyOtpStateCopyWith<$Res> {
factory $VerifyOtpStateCopyWith(VerifyOtpState value, $Res Function(VerifyOtpState) _then) = _$VerifyOtpStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status, RequestStatus resendStatus, int time
});
}
/// @nodoc
class _$VerifyOtpStateCopyWithImpl<$Res>
implements $VerifyOtpStateCopyWith<$Res> {
_$VerifyOtpStateCopyWithImpl(this._self, this._then);
final VerifyOtpState _self;
final $Res Function(VerifyOtpState) _then;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? resendStatus = null,Object? time = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,resendStatus: null == resendStatus ? _self.resendStatus : resendStatus // ignore: cast_nullable_to_non_nullable
as RequestStatus,time: null == time ? _self.time : time // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// Adds pattern-matching-related methods to [VerifyOtpState].
extension VerifyOtpStatePatterns on VerifyOtpState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _VerifyOtpState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _VerifyOtpState value) $default,){
final _that = this;
switch (_that) {
case _VerifyOtpState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _VerifyOtpState value)? $default,){
final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status, RequestStatus resendStatus, int time)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that.status,_that.resendStatus,_that.time);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status, RequestStatus resendStatus, int time) $default,) {final _that = this;
switch (_that) {
case _VerifyOtpState():
return $default(_that.status,_that.resendStatus,_that.time);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status, RequestStatus resendStatus, int time)? $default,) {final _that = this;
switch (_that) {
case _VerifyOtpState() when $default != null:
return $default(_that.status,_that.resendStatus,_that.time);case _:
return null;
}
}
}
/// @nodoc
class _VerifyOtpState implements VerifyOtpState {
const _VerifyOtpState({this.status = RequestStatus.initial, this.resendStatus = RequestStatus.initial, this.time = 120});
@override@JsonKey() final RequestStatus status;
@override@JsonKey() final RequestStatus resendStatus;
@override@JsonKey() final int time;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyOtpStateCopyWith<_VerifyOtpState> get copyWith => __$VerifyOtpStateCopyWithImpl<_VerifyOtpState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyOtpState&&(identical(other.status, status) || other.status == status)&&(identical(other.resendStatus, resendStatus) || other.resendStatus == resendStatus)&&(identical(other.time, time) || other.time == time));
}
@override
int get hashCode => Object.hash(runtimeType,status,resendStatus,time);
@override
String toString() {
return 'VerifyOtpState(status: $status, resendStatus: $resendStatus, time: $time)';
}
}
/// @nodoc
abstract mixin class _$VerifyOtpStateCopyWith<$Res> implements $VerifyOtpStateCopyWith<$Res> {
factory _$VerifyOtpStateCopyWith(_VerifyOtpState value, $Res Function(_VerifyOtpState) _then) = __$VerifyOtpStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status, RequestStatus resendStatus, int time
});
}
/// @nodoc
class __$VerifyOtpStateCopyWithImpl<$Res>
implements _$VerifyOtpStateCopyWith<$Res> {
__$VerifyOtpStateCopyWithImpl(this._self, this._then);
final _VerifyOtpState _self;
final $Res Function(_VerifyOtpState) _then;
/// Create a copy of VerifyOtpState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? resendStatus = null,Object? time = null,}) {
return _then(_VerifyOtpState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,resendStatus: null == resendStatus ? _self.resendStatus : resendStatus // ignore: cast_nullable_to_non_nullable
as RequestStatus,time: null == time ? _self.time : time // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
// dart format on

View File

@@ -1,19 +0,0 @@
part of 'verify_otp_bloc.dart';
@freezed
class VerifyOtpEvent with _$VerifyOtpEvent {
const factory VerifyOtpEvent.started() = _Started;
const factory VerifyOtpEvent.cancelTimer() = _CancelTimer;
const factory VerifyOtpEvent.resendRegister(String phoneNUmber) =
_ResendRegister;
const factory VerifyOtpEvent.resendForgot(String phoneNUmber) = _ResendForgot;
const factory VerifyOtpEvent.ticked(int seconds) = _Ticked;
const factory VerifyOtpEvent.verifyOtpReset(VerifyOtpCodeParams params) =
_VerifyOtpReset;
const factory VerifyOtpEvent.verifyOtpRegister(VerifyOtpCodeParams params) =
_VerifyOtpRegister;
}

View File

@@ -1,10 +0,0 @@
part of 'verify_otp_bloc.dart';
@freezed
abstract class VerifyOtpState with _$VerifyOtpState {
const factory VerifyOtpState({
@Default(RequestStatus.initial) RequestStatus status,
@Default(RequestStatus.initial) RequestStatus resendStatus,
@Default(120) int time,
}) = _VerifyOtpState;
}

View File

@@ -1,60 +0,0 @@
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_register_usecase.dart';
import 'package:food_delivery_client/feature/common/presentation/widgets/w_toastification.dart';
import 'package:food_delivery_client/food_delivery_client.dart';
part 'verify_phone_event.dart';
part 'verify_phone_state.dart';
part 'verify_phone_bloc.freezed.dart';
@injectable
class VerifyPhoneBloc extends Bloc<VerifyPhoneEvent, VerifyPhoneState> {
final VerifyPhoneNumberLoginUseCase _loginUseCase;
final VerifyPhoneRegisterUseCase _registerUseCase;
VerifyPhoneBloc(this._loginUseCase, this._registerUseCase)
: super(const VerifyPhoneState()) {
on<_VerifyPhoneRegister>(_onVerifyPhoneNumberRegister);
on<_VerifyPhoneReset>(_onVerifyPhoneReset);
}
Future<void> _onVerifyPhoneNumberRegister(
_VerifyPhoneRegister event,
Emitter<VerifyPhoneState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _registerUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
Future<void> _onVerifyPhoneReset(
_VerifyPhoneReset event,
Emitter<VerifyPhoneState> emit,
) async {
emit(state.copyWith(status: RequestStatus.loading));
final response = await _loginUseCase.call(event.params);
response.fold(
(l) {
showErrorToast(l.errorMessage);
emit(state.copyWith(status: RequestStatus.error));
},
(r) {
showSuccessToast(r.message);
emit(state.copyWith(status: RequestStatus.loaded));
},
);
}
}

View File

@@ -1,607 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'verify_phone_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$VerifyPhoneEvent {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyPhoneEvent);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyPhoneEvent()';
}
}
/// @nodoc
class $VerifyPhoneEventCopyWith<$Res> {
$VerifyPhoneEventCopyWith(VerifyPhoneEvent _, $Res Function(VerifyPhoneEvent) __);
}
/// Adds pattern-matching-related methods to [VerifyPhoneEvent].
extension VerifyPhoneEventPatterns on VerifyPhoneEvent {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Started value)? started,TResult Function( _VerifyPhoneRegister value)? verifyPhoneRegister,TResult Function( _VerifyPhoneReset value)? verifyPhoneReset,required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Started value) started,required TResult Function( _VerifyPhoneRegister value) verifyPhoneRegister,required TResult Function( _VerifyPhoneReset value) verifyPhoneReset,}){
final _that = this;
switch (_that) {
case _Started():
return started(_that);case _VerifyPhoneRegister():
return verifyPhoneRegister(_that);case _VerifyPhoneReset():
return verifyPhoneReset(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Started value)? started,TResult? Function( _VerifyPhoneRegister value)? verifyPhoneRegister,TResult? Function( _VerifyPhoneReset value)? verifyPhoneReset,}){
final _that = this;
switch (_that) {
case _Started() when started != null:
return started(_that);case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? started,TResult Function( VerifyPhoneNumberParams params)? verifyPhoneRegister,TResult Function( VerifyPhoneNumberParams params)? verifyPhoneReset,required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that.params);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that.params);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() started,required TResult Function( VerifyPhoneNumberParams params) verifyPhoneRegister,required TResult Function( VerifyPhoneNumberParams params) verifyPhoneReset,}) {final _that = this;
switch (_that) {
case _Started():
return started();case _VerifyPhoneRegister():
return verifyPhoneRegister(_that.params);case _VerifyPhoneReset():
return verifyPhoneReset(_that.params);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? started,TResult? Function( VerifyPhoneNumberParams params)? verifyPhoneRegister,TResult? Function( VerifyPhoneNumberParams params)? verifyPhoneReset,}) {final _that = this;
switch (_that) {
case _Started() when started != null:
return started();case _VerifyPhoneRegister() when verifyPhoneRegister != null:
return verifyPhoneRegister(_that.params);case _VerifyPhoneReset() when verifyPhoneReset != null:
return verifyPhoneReset(_that.params);case _:
return null;
}
}
}
/// @nodoc
class _Started implements VerifyPhoneEvent {
const _Started();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Started);
}
@override
int get hashCode => runtimeType.hashCode;
@override
String toString() {
return 'VerifyPhoneEvent.started()';
}
}
/// @nodoc
class _VerifyPhoneRegister implements VerifyPhoneEvent {
const _VerifyPhoneRegister(this.params);
final VerifyPhoneNumberParams params;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyPhoneRegisterCopyWith<_VerifyPhoneRegister> get copyWith => __$VerifyPhoneRegisterCopyWithImpl<_VerifyPhoneRegister>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyPhoneRegister&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyPhoneEvent.verifyPhoneRegister(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyPhoneRegisterCopyWith<$Res> implements $VerifyPhoneEventCopyWith<$Res> {
factory _$VerifyPhoneRegisterCopyWith(_VerifyPhoneRegister value, $Res Function(_VerifyPhoneRegister) _then) = __$VerifyPhoneRegisterCopyWithImpl;
@useResult
$Res call({
VerifyPhoneNumberParams params
});
}
/// @nodoc
class __$VerifyPhoneRegisterCopyWithImpl<$Res>
implements _$VerifyPhoneRegisterCopyWith<$Res> {
__$VerifyPhoneRegisterCopyWithImpl(this._self, this._then);
final _VerifyPhoneRegister _self;
final $Res Function(_VerifyPhoneRegister) _then;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyPhoneRegister(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyPhoneNumberParams,
));
}
}
/// @nodoc
class _VerifyPhoneReset implements VerifyPhoneEvent {
const _VerifyPhoneReset(this.params);
final VerifyPhoneNumberParams params;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyPhoneResetCopyWith<_VerifyPhoneReset> get copyWith => __$VerifyPhoneResetCopyWithImpl<_VerifyPhoneReset>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyPhoneReset&&(identical(other.params, params) || other.params == params));
}
@override
int get hashCode => Object.hash(runtimeType,params);
@override
String toString() {
return 'VerifyPhoneEvent.verifyPhoneReset(params: $params)';
}
}
/// @nodoc
abstract mixin class _$VerifyPhoneResetCopyWith<$Res> implements $VerifyPhoneEventCopyWith<$Res> {
factory _$VerifyPhoneResetCopyWith(_VerifyPhoneReset value, $Res Function(_VerifyPhoneReset) _then) = __$VerifyPhoneResetCopyWithImpl;
@useResult
$Res call({
VerifyPhoneNumberParams params
});
}
/// @nodoc
class __$VerifyPhoneResetCopyWithImpl<$Res>
implements _$VerifyPhoneResetCopyWith<$Res> {
__$VerifyPhoneResetCopyWithImpl(this._self, this._then);
final _VerifyPhoneReset _self;
final $Res Function(_VerifyPhoneReset) _then;
/// Create a copy of VerifyPhoneEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') $Res call({Object? params = null,}) {
return _then(_VerifyPhoneReset(
null == params ? _self.params : params // ignore: cast_nullable_to_non_nullable
as VerifyPhoneNumberParams,
));
}
}
/// @nodoc
mixin _$VerifyPhoneState {
RequestStatus get status;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$VerifyPhoneStateCopyWith<VerifyPhoneState> get copyWith => _$VerifyPhoneStateCopyWithImpl<VerifyPhoneState>(this as VerifyPhoneState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyPhoneState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'VerifyPhoneState(status: $status)';
}
}
/// @nodoc
abstract mixin class $VerifyPhoneStateCopyWith<$Res> {
factory $VerifyPhoneStateCopyWith(VerifyPhoneState value, $Res Function(VerifyPhoneState) _then) = _$VerifyPhoneStateCopyWithImpl;
@useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class _$VerifyPhoneStateCopyWithImpl<$Res>
implements $VerifyPhoneStateCopyWith<$Res> {
_$VerifyPhoneStateCopyWithImpl(this._self, this._then);
final VerifyPhoneState _self;
final $Res Function(VerifyPhoneState) _then;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? status = null,}) {
return _then(_self.copyWith(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
/// Adds pattern-matching-related methods to [VerifyPhoneState].
extension VerifyPhoneStatePatterns on VerifyPhoneState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _VerifyPhoneState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _VerifyPhoneState value) $default,){
final _that = this;
switch (_that) {
case _VerifyPhoneState():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _VerifyPhoneState value)? $default,){
final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( RequestStatus status)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that.status);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( RequestStatus status) $default,) {final _that = this;
switch (_that) {
case _VerifyPhoneState():
return $default(_that.status);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( RequestStatus status)? $default,) {final _that = this;
switch (_that) {
case _VerifyPhoneState() when $default != null:
return $default(_that.status);case _:
return null;
}
}
}
/// @nodoc
class _VerifyPhoneState implements VerifyPhoneState {
const _VerifyPhoneState({this.status = RequestStatus.initial});
@override@JsonKey() final RequestStatus status;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$VerifyPhoneStateCopyWith<_VerifyPhoneState> get copyWith => __$VerifyPhoneStateCopyWithImpl<_VerifyPhoneState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyPhoneState&&(identical(other.status, status) || other.status == status));
}
@override
int get hashCode => Object.hash(runtimeType,status);
@override
String toString() {
return 'VerifyPhoneState(status: $status)';
}
}
/// @nodoc
abstract mixin class _$VerifyPhoneStateCopyWith<$Res> implements $VerifyPhoneStateCopyWith<$Res> {
factory _$VerifyPhoneStateCopyWith(_VerifyPhoneState value, $Res Function(_VerifyPhoneState) _then) = __$VerifyPhoneStateCopyWithImpl;
@override @useResult
$Res call({
RequestStatus status
});
}
/// @nodoc
class __$VerifyPhoneStateCopyWithImpl<$Res>
implements _$VerifyPhoneStateCopyWith<$Res> {
__$VerifyPhoneStateCopyWithImpl(this._self, this._then);
final _VerifyPhoneState _self;
final $Res Function(_VerifyPhoneState) _then;
/// Create a copy of VerifyPhoneState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? status = null,}) {
return _then(_VerifyPhoneState(
status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
as RequestStatus,
));
}
}
// dart format on

View File

@@ -1,14 +0,0 @@
part of 'verify_phone_bloc.dart';
@freezed
class VerifyPhoneEvent with _$VerifyPhoneEvent {
const factory VerifyPhoneEvent.started() = _Started;
const factory VerifyPhoneEvent.verifyPhoneRegister(
VerifyPhoneNumberParams params,
) = _VerifyPhoneRegister;
const factory VerifyPhoneEvent.verifyPhoneReset(
VerifyPhoneNumberParams params,
) = _VerifyPhoneReset;
}

View File

@@ -1,8 +0,0 @@
part of 'verify_phone_bloc.dart';
@freezed
abstract class VerifyPhoneState with _$VerifyPhoneState {
const factory VerifyPhoneState({
@Default(RequestStatus.initial) RequestStatus status,
}) = _VerifyPhoneState;
}

View File

@@ -1,12 +0,0 @@
import '../../../../../food_delivery_client.dart';
class ForgotPasswordPage extends StatelessWidget {
const ForgotPasswordPage({super.key});
@override
Widget build(BuildContext context) {
return WLayout(
child: Scaffold(body: Column(children: [Text('Forgot password')])),
);
}
}

View File

@@ -1,18 +0,0 @@
import 'package:food_delivery_client/feature/auth/presentation/blocs/login_bloc/login_bloc.dart';
import 'package:food_delivery_client/feature/auth/presentation/pages/login_page/widgets/login_body.dart';
import '../../../../../food_delivery_client.dart';
class LoginPage extends StatelessWidget {
const LoginPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => sl<LoginBloc>(),
child: WLayout(
top: false,
child: Scaffold(resizeToAvoidBottomInset: true, body: WLoginBody()),
),
);
}
}

View File

@@ -1,175 +0,0 @@
import 'package:food_delivery_client/core/helpers/formatters.dart';
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
import '../../../../../../food_delivery_client.dart';
import '../../../../domain/usecases/login_usecase.dart';
import '../../../blocs/login_bloc/login_bloc.dart';
class WLoginBody extends StatefulWidget {
const WLoginBody({super.key});
@override
State<WLoginBody> createState() => _WLoginBodyState();
}
class _WLoginBodyState extends State<WLoginBody> {
late final TextEditingController _phoneController;
late final TextEditingController _passwordController;
final _formKey = GlobalKey<FormState>();
@override
void initState() {
_phoneController = TextEditingController();
_passwordController = TextEditingController();
super.initState();
}
@override
void dispose() {
_phoneController.dispose();
_passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocConsumer<LoginBloc, LoginState>(
listener: (context, state) {
if (state.status.isLoaded()) {
context.go(Routes.main);
}
},
builder: (context, state) {
return Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
child: WAuthBackground(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
25.verticalSpace,
Align(
alignment: AlignmentGeometry.center,
child: Text(
context.loc.login,
style: AppTextStyles.size24Bold,
),
),
20.verticalSpace,
Text(
context.loc.phone_number,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
hintText: context.loc.enter_phone_number,
prefixIcon: Text(
"+ 998",
style: AppTextStyles.size16Regular.copyWith(fontSize: 16),
),
borderRadius: AppUtils.kBorderRadius8,
controller: _phoneController,
keyBoardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
Formatters.phoneFormatter,
LengthLimitingTextInputFormatter(12),
],
validator: (value) {
return Validators.validatePhoneNumber(
_phoneController.text.trim(),
);
},
),
10.verticalSpace,
Text(
context.loc.password,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
height: 50,
obscureText: true,
hintText: context.loc.enter_password,
keyBoardType: TextInputType.text,
borderRadius: AppUtils.kBorderRadius8,
controller: _passwordController,
validator: (value) {
return Validators.validatePassword(
_passwordController.text.trim(),
);
},
),
Align(
alignment: AlignmentGeometry.centerRight,
child: TextButton(
onPressed: () {
context.push(Routes.verifyPhoneNumber, extra: false);
},
child: Text(
context.loc.forgot_password,
style: AppTextStyles.size14Medium.copyWith(
color: AppColors.c34A853,
),
),
),
),
40.verticalSpace,
AppButton(
name: context.loc.continue_str,
isLoading: state.status.isLoading(),
trailing: SvgPicture.asset(
AppIcons.icArrowRightLight,
).paddingOnly(left: 10),
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
context.read<LoginBloc>().add(
LoginEvent.login(
LoginParams(
phoneNumber:
"+998${_phoneController.text.trim().replaceAll(" ", "")}",
password: _passwordController.text.trim(),
),
),
);
}
},
borderRadius: 15,
backgroundColor: AppColors.c34A853,
),
20.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
context.loc.dont_have_account,
style: AppTextStyles.size14Medium,
),
TextButton(
onPressed: () {
context.push(Routes.verifyPhoneNumber, extra: true);
},
child: Text(
context.loc.sign_up,
style: AppTextStyles.size15Bold.copyWith(
color: AppColors.c34A853,
),
),
),
],
),
20.verticalSpace,
],
).paddingSymmetric(horizontal: 16),
),
);
},
);
}
}

View File

@@ -1,25 +0,0 @@
import 'package:food_delivery_client/feature/auth/presentation/pages/register_page/widgets/w_register_body.dart';
import '../../../../../food_delivery_client.dart';
import '../../blocs/register_bloc/register_bloc.dart';
class RegisterPage extends StatelessWidget {
const RegisterPage({super.key, required this.phoneNumber});
final String phoneNumber;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => sl<RegisterBloc>(),
child: BlocBuilder<RegisterBloc, RegisterState>(
builder: (context, state) {
return WLayout(
top: false,
child: Scaffold(body: WRegisterBody(phoneNumber: phoneNumber)),
);
},
),
);
}
}

View File

@@ -1,230 +0,0 @@
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/register_usecase.dart';
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
import '../../../../../../food_delivery_client.dart';
import '../../../blocs/register_bloc/register_bloc.dart';
class WRegisterBody extends StatefulWidget {
const WRegisterBody({super.key, required this.phoneNumber});
final String phoneNumber;
@override
State<WRegisterBody> createState() => _WRegisterBodyState();
}
class _WRegisterBodyState extends State<WRegisterBody> {
late TextEditingController _firstNameController;
late TextEditingController _lastNameController;
late TextEditingController _phoneNumberController;
late TextEditingController _passwordController;
late TextEditingController _repeatPasswordController;
final _formKey = GlobalKey<FormState>();
@override
void initState() {
_firstNameController = TextEditingController();
_lastNameController = TextEditingController();
_phoneNumberController = TextEditingController();
_passwordController = TextEditingController();
_repeatPasswordController = TextEditingController();
super.initState();
}
@override
void dispose() {
_firstNameController.dispose();
_lastNameController.dispose();
_phoneNumberController.dispose();
_passwordController.dispose();
_repeatPasswordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocConsumer<RegisterBloc, RegisterState>(
listener: (context, state) {
if (state.status.isLoaded()) {
context.go(Routes.login);
}
},
builder: (context, state) {
return Form(
key: _formKey,
child: WAuthBackground(
child: SizedBox(
width: context.w,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
20.verticalSpace,
Align(
alignment: AlignmentGeometry.center,
child: Text(
context.loc.sign_up,
style: AppTextStyles.size24Bold,
),
),
20.verticalSpace,
Text(
context.loc.first_name,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
hintText: context.loc.enter_first_name,
controller: _firstNameController,
borderRadius: AppUtils.kBorderRadius8,
keyBoardType: TextInputType.name,
validator: (value) {
return Validators.validateFields(
_firstNameController.text.trim(),
);
},
),
10.verticalSpace,
Text(
'Last name',
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
hintText: "Enter LastName",
controller: _lastNameController,
borderRadius: AppUtils.kBorderRadius8,
keyBoardType: TextInputType.text,
validator: (value) {
return Validators.validateFields(
_lastNameController.text.trim(),
);
},
),
10.verticalSpace,
/* Text(
context.loc.phone_number,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
hintText: context.loc.enter_phone_number,
controller: _phoneNumberController,
borderRadius: AppUtils.kBorderRadius8,
keyBoardType: TextInputType.phone,
prefixIcon: Text("+ 998", style: AppTextStyles.size16Regular),
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
Formatters.phoneFormatter,
LengthLimitingTextInputFormatter(12),
],
validator: (value) {
return Validators.validatePhoneNumber(
_phoneNumberController.text.trim(),
);
},
),
*/
10.verticalSpace,
Text(
context.loc.enter_password,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
obscureText: true,
hintText: context.loc.password,
controller: _passwordController,
borderRadius: AppUtils.kBorderRadius8,
keyBoardType: TextInputType.visiblePassword,
validator: (value) {
return Validators.validatePassword(
_passwordController.text.trim(),
);
},
),
10.verticalSpace,
Text(
context.loc.repeat_password,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
obscureText: true,
hintText: context.loc.enter_repeat_password,
controller: _repeatPasswordController,
borderRadius: AppUtils.kBorderRadius8,
keyBoardType: TextInputType.visiblePassword,
validator: (value) {
return Validators.validateRepeatPassword(
_repeatPasswordController.text.trim(),
_passwordController.text.trim(),
);
},
),
20.verticalSpace,
AppButton(
isLoading: state.status.isLoading(),
name: context.loc.continue_str,
borderRadius: 15,
backgroundColor: AppColors.c34A853,
trailing: SvgPicture.asset(
AppIcons.icArrowRightLight,
).paddingOnly(left: 8),
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
context.read<RegisterBloc>().add(
RegisterEvent.loaded(
RegisterParams(
phoneNumber: widget.phoneNumber,
password: _passwordController.text.trim(),
firstName: _firstNameController.text.trim(),
lastName: _lastNameController.text.trim(),
),
),
);
}
},
),
20.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
context.loc.already_has_account,
style: AppTextStyles.size14Medium,
),
TextButton(
onPressed: () {
context.pushReplacement(Routes.login);
},
child: Text(
context.loc.login,
style: AppTextStyles.size15Bold.copyWith(
color: AppColors.c34A853,
),
),
),
],
),
],
).paddingSymmetric(horizontal: 16),
),
),
);
},
);
}
}

View File

@@ -1,138 +0,0 @@
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/reset_password_usecase.dart';
import 'package:food_delivery_client/feature/auth/presentation/blocs/reset_password_bloc/reset_password_bloc.dart';
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
import '../../../../../food_delivery_client.dart';
class ResetPasswordPage extends StatefulWidget {
const ResetPasswordPage({super.key, required this.phoneNumber});
final String phoneNumber;
@override
State<ResetPasswordPage> createState() => _ResetPasswordPageState();
}
class _ResetPasswordPageState extends State<ResetPasswordPage> {
late TextEditingController _passwordController;
late TextEditingController _repeatPasswordController;
final _formKey = GlobalKey<FormState>();
@override
void initState() {
_passwordController = TextEditingController();
_repeatPasswordController = TextEditingController();
super.initState();
}
@override
void dispose() {
_passwordController.dispose();
_repeatPasswordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => sl<ResetPasswordBloc>(),
child: BlocConsumer<ResetPasswordBloc, ResetPasswordState>(
listener: (context, state) {
if (state.status.isLoaded()) {
context.go(Routes.login);
}
},
builder: (context, state) {
return Form(
key: _formKey,
child: WLayout(
top: false,
child: Scaffold(
body: WAuthBackground(
child: SizedBox(
width: context.w,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
25.verticalSpace,
Text(
context.loc.reset_password,
style: AppTextStyles.size20Medium,
),
20.verticalSpace,
Text(
context.loc.new_password,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
obscureText: true,
controller: _passwordController,
borderRadius: AppUtils.kBorderRadius8,
hintText: context.loc.enter_password,
keyBoardType: TextInputType.visiblePassword,
validator: (value) {
return Validators.validatePassword(
_passwordController.text.trim(),
);
},
),
20.verticalSpace,
Text(
context.loc.password,
style: AppTextStyles.size14Regular.copyWith(
color: AppColors.c6A6E7F,
),
),
5.verticalSpace,
AppTextFormField(
obscureText: true,
controller: _repeatPasswordController,
borderRadius: AppUtils.kBorderRadius8,
hintText: context.loc.enter_password,
keyBoardType: TextInputType.visiblePassword,
validator: (value) {
return Validators.validateRepeatPassword(
_repeatPasswordController.text.trim(),
_passwordController.text.trim(),
);
},
),
25.verticalSpace,
AppButton(
name: context.loc.continue_str,
trailing: SvgPicture.asset(
AppIcons.icArrowRightLight,
).paddingOnly(left: 8),
isLoading: state.status.isLoading(),
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
context.read<ResetPasswordBloc>().add(
ResetPasswordEvent.loaded(
ResetPasswordParams(
phoneNumber: widget.phoneNumber,
newPassword: _passwordController.text
.trim(),
),
),
);
}
},
backgroundColor: AppColors.c34A853,
borderRadius: 15,
),
],
).paddingSymmetric(horizontal: 16),
),
),
),
),
);
},
),
);
}
}

View File

@@ -1,193 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:food_delivery_client/core/helpers/time_formatters.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/presentation/blocs/verify_otp_bloc/verify_otp_bloc.dart';
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
import 'package:pinput/pinput.dart';
import '../../../../../food_delivery_client.dart';
class VerifyOtpCodePage extends StatefulWidget {
const VerifyOtpCodePage({super.key, required this.params});
final OtpCodePageParams params;
@override
State<VerifyOtpCodePage> createState() => _VerifyOtpCodePageState();
}
class _VerifyOtpCodePageState extends State<VerifyOtpCodePage> {
late TextEditingController _controller;
@override
void initState() {
_controller = TextEditingController();
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
final defaultPinTheme = PinTheme(
height: 56,
width: 56,
textStyle: AppTextStyles.size18Medium,
decoration: BoxDecoration(
borderRadius: AppUtils.kBorderRadius8,
border: Border.all(color: Color.fromRGBO(234, 239, 243, 1)),
color: Color.fromRGBO(234, 234, 243, 1),
),
);
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => sl<VerifyOtpBloc>()..add(VerifyOtpEvent.started()),
child: BlocConsumer<VerifyOtpBloc, VerifyOtpState>(
listener: (context, state) {
if (state.status.isLoaded()) {
if (widget.params.isRegister) {
context.push(Routes.register, extra: widget.params.phoneNumber);
} else {
context.push(
Routes.resetPassword,
extra: widget.params.phoneNumber,
);
}
}
},
builder: (context, state) {
return WLayout(
top: false,
child: Scaffold(
body: WAuthBackground(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
40.verticalSpace,
Text(
context.loc.enter_otp_code(widget.params.phoneNumber),
style: AppTextStyles.size20Medium,
),
20.verticalSpace,
Pinput(
length: 5,
enabled: true,
controller: _controller,
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
crossAxisAlignment: CrossAxisAlignment.center,
autofocus: true,
showCursor: true,
defaultPinTheme: defaultPinTheme,
focusedPinTheme: defaultPinTheme.copyWith(
decoration: defaultPinTheme.decoration!.copyWith(
color: Color.fromRGBO(234, 239, 243, 1),
),
),
submittedPinTheme: defaultPinTheme.copyWith(
decoration: defaultPinTheme.decoration!.copyWith(
color: Color.fromRGBO(234, 239, 243, 1),
),
),
onChanged: (value) {
if (value.length == 5 && state.time > 0) {}
},
),
10.verticalSpace,
SizedBox(
height: 40,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
context.loc.resend_otp_after,
style: AppTextStyles.size14Regular,
),
if (state.time != 0)
Text(
TimeFormatters.formatMinutesToTime(state.time),
),
if (state.time == 0)
state.resendStatus.isLoading()
? CircularProgressIndicator.adaptive()
: IconButton(
onPressed: () {
if (widget.params.isRegister) {
context.read<VerifyOtpBloc>().add(
VerifyOtpEvent.resendRegister(
widget.params.phoneNumber,
),
);
} else {
context.read<VerifyOtpBloc>().add(
VerifyOtpEvent.resendForgot(
widget.params.phoneNumber,
),
);
}
},
icon: Icon(
CupertinoIcons.restart,
color: AppColors.c000000,
),
),
],
),
),
20.verticalSpace,
AppButton(
name: context.loc.continue_str,
onPressed: () {
if (_controller.text.trim().length == 5 &&
state.time > 0) {
if (widget.params.isRegister) {
context.read<VerifyOtpBloc>().add(
VerifyOtpEvent.verifyOtpRegister(
VerifyOtpCodeParams(
phoneNumber: widget.params.phoneNumber,
otpCode: _controller.text.trim().substring(
0,
4,
),
),
),
);
} else {
context.read<VerifyOtpBloc>().add(
VerifyOtpEvent.verifyOtpReset(
VerifyOtpCodeParams(
phoneNumber: widget.params.phoneNumber,
otpCode: int.tryParse(
_controller.text.trim().substring(0, 4),
),
),
),
);
}
}
},
isLoading: state.status.isLoading(),
backgroundColor: AppColors.c34A853,
borderRadius: 15,
trailing: SvgPicture.asset(
AppIcons.icArrowRightLight,
).paddingOnly(left: 8),
),
],
).paddingSymmetric(horizontal: 16),
),
),
);
},
),
);
}
}

View File

@@ -1,141 +0,0 @@
import 'package:food_delivery_client/core/helpers/formatters.dart';
import 'package:food_delivery_client/core/helpers/validator_helpers.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_otp_code_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/domain/usecases/verify_phone_login_usecase.dart';
import 'package:food_delivery_client/feature/auth/presentation/blocs/verify_phone_bloc/verify_phone_bloc.dart';
import 'package:food_delivery_client/feature/auth/presentation/widgets/w_auth_background.dart';
import '../../../../../food_delivery_client.dart';
class VerifyPhoneNumberPage extends StatefulWidget {
const VerifyPhoneNumberPage({super.key, required this.isRegister});
final bool isRegister;
@override
State<VerifyPhoneNumberPage> createState() => _VerifyPhoneNumberPageState();
}
class _VerifyPhoneNumberPageState extends State<VerifyPhoneNumberPage> {
late TextEditingController _phoneNumberController;
final _formKey = GlobalKey<FormState>();
@override
void initState() {
_phoneNumberController = TextEditingController();
super.initState();
}
@override
void dispose() {
_phoneNumberController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => sl<VerifyPhoneBloc>(),
child: BlocConsumer<VerifyPhoneBloc, VerifyPhoneState>(
listener: (context, state) {
if (state.status.isLoaded()) {
context.push(
Routes.verifyOtpCode,
extra: OtpCodePageParams(
phoneNumber:
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
isRegister: widget.isRegister,
),
);
}
},
builder: (context, state) {
return Form(
key: _formKey,
child: WLayout(
top: false,
child: Scaffold(
body: WAuthBackground(
child: SizedBox(
width: context.w,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
50.verticalSpace,
Text(
context.loc.enter_phone_number,
style: AppTextStyles.size20Medium,
),
20.verticalSpace,
AppTextFormField(
controller: _phoneNumberController,
borderRadius: AppUtils.kBorderRadius8,
hintText: context.loc.phone_number,
keyBoardType: TextInputType.phone,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
Formatters.phoneFormatter,
LengthLimitingTextInputFormatter(12),
],
prefixIcon: Text(
"+ 998",
style: AppTextStyles.size16Regular,
),
validator: (value) {
return Validators.validatePhoneNumber(
_phoneNumberController.text.trim(),
);
},
),
25.verticalSpace,
AppButton(
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
if (widget.isRegister) {
context.read<VerifyPhoneBloc>().add(
VerifyPhoneEvent.verifyPhoneRegister(
VerifyPhoneNumberParams(
phoneNumber:
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
),
),
);
} else {
context.read<VerifyPhoneBloc>().add(
VerifyPhoneEvent.verifyPhoneReset(
VerifyPhoneNumberParams(
phoneNumber:
"+998${_phoneNumberController.text.trim().replaceAll(" ", "")}",
),
),
);
}
}
},
isLoading: state.status.isLoading(),
name: context.loc.continue_str,
borderRadius: 15,
backgroundColor: AppColors.c34A853,
),
10.verticalSpace,
Text(
context.loc.consent_message("Felix Eats"),
style: AppTextStyles.size12Medium.copyWith(
color: AppColors.c888888,
),
),
],
).paddingSymmetric(horizontal: 16),
),
),
),
),
);
},
),
);
}
}

View File

@@ -1,35 +0,0 @@
import '../../../../food_delivery_client.dart';
class WAuthBackground extends StatelessWidget {
const WAuthBackground({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
return Stack(
children: [
SizedBox(
height: context.h * .3,
child: Image.asset(AppImages.imgBurger2, fit: BoxFit.cover),
),
SingleChildScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
child: Column(
children: [
SizedBox(height: context.h * .2),
DecoratedBox(
decoration: BoxDecoration(
color: AppColors.cFFFFFF,
borderRadius: AppUtils.kBorderRadiusTop20,
),
child: child,
),
],
),
),
],
);
}
}