Compare commits

..

No commits in common. "3b26b19b25c7980ec620d84807f92ef8d24e920c" and "13c55afe3c2f3e45a724f52eb62bc6a66118da41" have entirely different histories.

33 changed files with 1 additions and 6576 deletions

View File

@ -1,61 +0,0 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart';
part 'login_form_event.dart';
part 'login_form_state.dart';
part 'login_form_bloc.freezed.dart';
@injectable
class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
final IAuthRepository _authRepository;
LoginFormBloc(this._authRepository) : super(LoginFormState.initial()) {
on<LoginFormEvent>(_onLoginFormEvent);
}
Future<void> _onLoginFormEvent(
LoginFormEvent event,
Emitter<LoginFormState> emit,
) {
return event.map(
phoneNumberChanged: (e) async {
emit(
state.copyWith(
phoneNumber: e.phoneNumber,
failureOrLoginOption: none(),
),
);
},
passwordChanged: (e) async {
emit(
state.copyWith(password: e.password, failureOrLoginOption: none()),
);
},
submitted: (e) async {
Either<AuthFailure, Login>? failureOrLogin;
emit(state.copyWith(isSubmitting: true, failureOrLoginOption: none()));
final phoneNumberValid = state.phoneNumber.isNotEmpty;
final passwordValid = state.password.isNotEmpty;
if (phoneNumberValid && passwordValid) {
failureOrLogin = await _authRepository.login(
phoneNumber: state.phoneNumber,
password: state.password,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrLoginOption: optionOf(failureOrLogin),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}

View File

@ -1,740 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'login_form_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$LoginFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String password) passwordChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String password)? passwordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LoginFormEventCopyWith<$Res> {
factory $LoginFormEventCopyWith(
LoginFormEvent value,
$Res Function(LoginFormEvent) then,
) = _$LoginFormEventCopyWithImpl<$Res, LoginFormEvent>;
}
/// @nodoc
class _$LoginFormEventCopyWithImpl<$Res, $Val extends LoginFormEvent>
implements $LoginFormEventCopyWith<$Res> {
_$LoginFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$PhoneNumberChangedImplCopyWith<$Res> {
factory _$$PhoneNumberChangedImplCopyWith(
_$PhoneNumberChangedImpl value,
$Res Function(_$PhoneNumberChangedImpl) then,
) = __$$PhoneNumberChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String phoneNumber});
}
/// @nodoc
class __$$PhoneNumberChangedImplCopyWithImpl<$Res>
extends _$LoginFormEventCopyWithImpl<$Res, _$PhoneNumberChangedImpl>
implements _$$PhoneNumberChangedImplCopyWith<$Res> {
__$$PhoneNumberChangedImplCopyWithImpl(
_$PhoneNumberChangedImpl _value,
$Res Function(_$PhoneNumberChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? phoneNumber = null}) {
return _then(
_$PhoneNumberChangedImpl(
null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$PhoneNumberChangedImpl implements _PhoneNumberChanged {
const _$PhoneNumberChangedImpl(this.phoneNumber);
@override
final String phoneNumber;
@override
String toString() {
return 'LoginFormEvent.phoneNumberChanged(phoneNumber: $phoneNumber)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PhoneNumberChangedImpl &&
(identical(other.phoneNumber, phoneNumber) ||
other.phoneNumber == phoneNumber));
}
@override
int get hashCode => Object.hash(runtimeType, phoneNumber);
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith =>
__$$PhoneNumberChangedImplCopyWithImpl<_$PhoneNumberChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String password) passwordChanged,
required TResult Function() submitted,
}) {
return phoneNumberChanged(phoneNumber);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function()? submitted,
}) {
return phoneNumberChanged?.call(phoneNumber);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String password)? passwordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (phoneNumberChanged != null) {
return phoneNumberChanged(phoneNumber);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return phoneNumberChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return phoneNumberChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (phoneNumberChanged != null) {
return phoneNumberChanged(this);
}
return orElse();
}
}
abstract class _PhoneNumberChanged implements LoginFormEvent {
const factory _PhoneNumberChanged(final String phoneNumber) =
_$PhoneNumberChangedImpl;
String get phoneNumber;
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$PasswordChangedImplCopyWith<$Res> {
factory _$$PasswordChangedImplCopyWith(
_$PasswordChangedImpl value,
$Res Function(_$PasswordChangedImpl) then,
) = __$$PasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String password});
}
/// @nodoc
class __$$PasswordChangedImplCopyWithImpl<$Res>
extends _$LoginFormEventCopyWithImpl<$Res, _$PasswordChangedImpl>
implements _$$PasswordChangedImplCopyWith<$Res> {
__$$PasswordChangedImplCopyWithImpl(
_$PasswordChangedImpl _value,
$Res Function(_$PasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? password = null}) {
return _then(
_$PasswordChangedImpl(
null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$PasswordChangedImpl implements _PasswordChanged {
const _$PasswordChangedImpl(this.password);
@override
final String password;
@override
String toString() {
return 'LoginFormEvent.passwordChanged(password: $password)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PasswordChangedImpl &&
(identical(other.password, password) ||
other.password == password));
}
@override
int get hashCode => Object.hash(runtimeType, password);
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
__$$PasswordChangedImplCopyWithImpl<_$PasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String password) passwordChanged,
required TResult Function() submitted,
}) {
return passwordChanged(password);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function()? submitted,
}) {
return passwordChanged?.call(password);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String password)? passwordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (passwordChanged != null) {
return passwordChanged(password);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return passwordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return passwordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (passwordChanged != null) {
return passwordChanged(this);
}
return orElse();
}
}
abstract class _PasswordChanged implements LoginFormEvent {
const factory _PasswordChanged(final String password) = _$PasswordChangedImpl;
String get password;
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$LoginFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'LoginFormEvent.submitted()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String password) passwordChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String password)? passwordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements LoginFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$LoginFormState {
String get phoneNumber => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
Option<Either<AuthFailure, Login>> get failureOrLoginOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of LoginFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoginFormStateCopyWith<LoginFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LoginFormStateCopyWith<$Res> {
factory $LoginFormStateCopyWith(
LoginFormState value,
$Res Function(LoginFormState) then,
) = _$LoginFormStateCopyWithImpl<$Res, LoginFormState>;
@useResult
$Res call({
String phoneNumber,
String password,
Option<Either<AuthFailure, Login>> failureOrLoginOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$LoginFormStateCopyWithImpl<$Res, $Val extends LoginFormState>
implements $LoginFormStateCopyWith<$Res> {
_$LoginFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of LoginFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? phoneNumber = null,
Object? password = null,
Object? failureOrLoginOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
phoneNumber: null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
failureOrLoginOption: null == failureOrLoginOption
? _value.failureOrLoginOption
: failureOrLoginOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Login>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$LoginFormStateImplCopyWith<$Res>
implements $LoginFormStateCopyWith<$Res> {
factory _$$LoginFormStateImplCopyWith(
_$LoginFormStateImpl value,
$Res Function(_$LoginFormStateImpl) then,
) = __$$LoginFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String phoneNumber,
String password,
Option<Either<AuthFailure, Login>> failureOrLoginOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$LoginFormStateImplCopyWithImpl<$Res>
extends _$LoginFormStateCopyWithImpl<$Res, _$LoginFormStateImpl>
implements _$$LoginFormStateImplCopyWith<$Res> {
__$$LoginFormStateImplCopyWithImpl(
_$LoginFormStateImpl _value,
$Res Function(_$LoginFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of LoginFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? phoneNumber = null,
Object? password = null,
Object? failureOrLoginOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$LoginFormStateImpl(
phoneNumber: null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
failureOrLoginOption: null == failureOrLoginOption
? _value.failureOrLoginOption
: failureOrLoginOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Login>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$LoginFormStateImpl implements _LoginFormState {
const _$LoginFormStateImpl({
required this.phoneNumber,
required this.password,
required this.failureOrLoginOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String phoneNumber;
@override
final String password;
@override
final Option<Either<AuthFailure, Login>> failureOrLoginOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'LoginFormState(phoneNumber: $phoneNumber, password: $password, failureOrLoginOption: $failureOrLoginOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LoginFormStateImpl &&
(identical(other.phoneNumber, phoneNumber) ||
other.phoneNumber == phoneNumber) &&
(identical(other.password, password) ||
other.password == password) &&
(identical(other.failureOrLoginOption, failureOrLoginOption) ||
other.failureOrLoginOption == failureOrLoginOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
phoneNumber,
password,
failureOrLoginOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of LoginFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LoginFormStateImplCopyWith<_$LoginFormStateImpl> get copyWith =>
__$$LoginFormStateImplCopyWithImpl<_$LoginFormStateImpl>(
this,
_$identity,
);
}
abstract class _LoginFormState implements LoginFormState {
const factory _LoginFormState({
required final String phoneNumber,
required final String password,
required final Option<Either<AuthFailure, Login>> failureOrLoginOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$LoginFormStateImpl;
@override
String get phoneNumber;
@override
String get password;
@override
Option<Either<AuthFailure, Login>> get failureOrLoginOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of LoginFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LoginFormStateImplCopyWith<_$LoginFormStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,10 +0,0 @@
part of 'login_form_bloc.dart';
@freezed
class LoginFormEvent with _$LoginFormEvent {
const factory LoginFormEvent.phoneNumberChanged(String phoneNumber) =
_PhoneNumberChanged;
const factory LoginFormEvent.passwordChanged(String password) =
_PasswordChanged;
const factory LoginFormEvent.submitted() = _Submitted;
}

View File

@ -1,18 +0,0 @@
part of 'login_form_bloc.dart';
@freezed
class LoginFormState with _$LoginFormState {
const factory LoginFormState({
required String phoneNumber,
required String password,
required Option<Either<AuthFailure, Login>> failureOrLoginOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _LoginFormState;
factory LoginFormState.initial() => LoginFormState(
phoneNumber: '',
password: '',
failureOrLoginOption: none(),
);
}

View File

@ -1,59 +0,0 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart';
part 'resend_form_event.dart';
part 'resend_form_state.dart';
part 'resend_form_bloc.freezed.dart';
@injectable
class ResendFormBloc extends Bloc<ResendFormEvent, ResendFormState> {
final IAuthRepository _repository;
ResendFormBloc(this._repository) : super(ResendFormState.initial()) {
on<ResendFormEvent>(_onResendFormEvent);
}
Future<void> _onResendFormEvent(
ResendFormEvent event,
Emitter<ResendFormState> emit,
) {
return event.map(
phoneNumberChanged: (e) async {
emit(
state.copyWith(
phoneNumber: e.phoneNumber,
failureOrResendOption: none(),
),
);
},
purposeChanged: (e) async {
emit(state.copyWith(purpose: e.purpose, failureOrResendOption: none()));
},
submitted: (e) async {
Either<AuthFailure, Resend>? failureOrResend;
emit(state.copyWith(isSubmitting: true, failureOrResendOption: none()));
final phoneNumberValid = state.phoneNumber.isNotEmpty;
final purposeValid = state.purpose.isNotEmpty;
if (phoneNumberValid && purposeValid) {
failureOrResend = await _repository.resend(
phoneNumber: state.phoneNumber,
purpose: state.purpose,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrResendOption: optionOf(failureOrResend),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}

View File

@ -1,738 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'resend_form_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$ResendFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String purpose) purposeChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String purpose)? purposeChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String purpose)? purposeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PurposeChanged value) purposeChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PurposeChanged value)? purposeChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PurposeChanged value)? purposeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ResendFormEventCopyWith<$Res> {
factory $ResendFormEventCopyWith(
ResendFormEvent value,
$Res Function(ResendFormEvent) then,
) = _$ResendFormEventCopyWithImpl<$Res, ResendFormEvent>;
}
/// @nodoc
class _$ResendFormEventCopyWithImpl<$Res, $Val extends ResendFormEvent>
implements $ResendFormEventCopyWith<$Res> {
_$ResendFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$PhoneNumberChangedImplCopyWith<$Res> {
factory _$$PhoneNumberChangedImplCopyWith(
_$PhoneNumberChangedImpl value,
$Res Function(_$PhoneNumberChangedImpl) then,
) = __$$PhoneNumberChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String phoneNumber});
}
/// @nodoc
class __$$PhoneNumberChangedImplCopyWithImpl<$Res>
extends _$ResendFormEventCopyWithImpl<$Res, _$PhoneNumberChangedImpl>
implements _$$PhoneNumberChangedImplCopyWith<$Res> {
__$$PhoneNumberChangedImplCopyWithImpl(
_$PhoneNumberChangedImpl _value,
$Res Function(_$PhoneNumberChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? phoneNumber = null}) {
return _then(
_$PhoneNumberChangedImpl(
null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$PhoneNumberChangedImpl implements _PhoneNumberChanged {
const _$PhoneNumberChangedImpl(this.phoneNumber);
@override
final String phoneNumber;
@override
String toString() {
return 'ResendFormEvent.phoneNumberChanged(phoneNumber: $phoneNumber)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PhoneNumberChangedImpl &&
(identical(other.phoneNumber, phoneNumber) ||
other.phoneNumber == phoneNumber));
}
@override
int get hashCode => Object.hash(runtimeType, phoneNumber);
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith =>
__$$PhoneNumberChangedImplCopyWithImpl<_$PhoneNumberChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String purpose) purposeChanged,
required TResult Function() submitted,
}) {
return phoneNumberChanged(phoneNumber);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String purpose)? purposeChanged,
TResult? Function()? submitted,
}) {
return phoneNumberChanged?.call(phoneNumber);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String purpose)? purposeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (phoneNumberChanged != null) {
return phoneNumberChanged(phoneNumber);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PurposeChanged value) purposeChanged,
required TResult Function(_Submitted value) submitted,
}) {
return phoneNumberChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PurposeChanged value)? purposeChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return phoneNumberChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PurposeChanged value)? purposeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (phoneNumberChanged != null) {
return phoneNumberChanged(this);
}
return orElse();
}
}
abstract class _PhoneNumberChanged implements ResendFormEvent {
const factory _PhoneNumberChanged(final String phoneNumber) =
_$PhoneNumberChangedImpl;
String get phoneNumber;
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$PurposeChangedImplCopyWith<$Res> {
factory _$$PurposeChangedImplCopyWith(
_$PurposeChangedImpl value,
$Res Function(_$PurposeChangedImpl) then,
) = __$$PurposeChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String purpose});
}
/// @nodoc
class __$$PurposeChangedImplCopyWithImpl<$Res>
extends _$ResendFormEventCopyWithImpl<$Res, _$PurposeChangedImpl>
implements _$$PurposeChangedImplCopyWith<$Res> {
__$$PurposeChangedImplCopyWithImpl(
_$PurposeChangedImpl _value,
$Res Function(_$PurposeChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? purpose = null}) {
return _then(
_$PurposeChangedImpl(
null == purpose
? _value.purpose
: purpose // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$PurposeChangedImpl implements _PurposeChanged {
const _$PurposeChangedImpl(this.purpose);
@override
final String purpose;
@override
String toString() {
return 'ResendFormEvent.purposeChanged(purpose: $purpose)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PurposeChangedImpl &&
(identical(other.purpose, purpose) || other.purpose == purpose));
}
@override
int get hashCode => Object.hash(runtimeType, purpose);
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PurposeChangedImplCopyWith<_$PurposeChangedImpl> get copyWith =>
__$$PurposeChangedImplCopyWithImpl<_$PurposeChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String purpose) purposeChanged,
required TResult Function() submitted,
}) {
return purposeChanged(purpose);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String purpose)? purposeChanged,
TResult? Function()? submitted,
}) {
return purposeChanged?.call(purpose);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String purpose)? purposeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (purposeChanged != null) {
return purposeChanged(purpose);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PurposeChanged value) purposeChanged,
required TResult Function(_Submitted value) submitted,
}) {
return purposeChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PurposeChanged value)? purposeChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return purposeChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PurposeChanged value)? purposeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (purposeChanged != null) {
return purposeChanged(this);
}
return orElse();
}
}
abstract class _PurposeChanged implements ResendFormEvent {
const factory _PurposeChanged(final String purpose) = _$PurposeChangedImpl;
String get purpose;
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PurposeChangedImplCopyWith<_$PurposeChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$ResendFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of ResendFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'ResendFormEvent.submitted()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String phoneNumber) phoneNumberChanged,
required TResult Function(String purpose) purposeChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String phoneNumber)? phoneNumberChanged,
TResult? Function(String purpose)? purposeChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String phoneNumber)? phoneNumberChanged,
TResult Function(String purpose)? purposeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_PhoneNumberChanged value) phoneNumberChanged,
required TResult Function(_PurposeChanged value) purposeChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult? Function(_PurposeChanged value)? purposeChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_PhoneNumberChanged value)? phoneNumberChanged,
TResult Function(_PurposeChanged value)? purposeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements ResendFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$ResendFormState {
String get phoneNumber => throw _privateConstructorUsedError;
String get purpose => throw _privateConstructorUsedError;
Option<Either<AuthFailure, Resend>> get failureOrResendOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of ResendFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ResendFormStateCopyWith<ResendFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ResendFormStateCopyWith<$Res> {
factory $ResendFormStateCopyWith(
ResendFormState value,
$Res Function(ResendFormState) then,
) = _$ResendFormStateCopyWithImpl<$Res, ResendFormState>;
@useResult
$Res call({
String phoneNumber,
String purpose,
Option<Either<AuthFailure, Resend>> failureOrResendOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$ResendFormStateCopyWithImpl<$Res, $Val extends ResendFormState>
implements $ResendFormStateCopyWith<$Res> {
_$ResendFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ResendFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? phoneNumber = null,
Object? purpose = null,
Object? failureOrResendOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
phoneNumber: null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
purpose: null == purpose
? _value.purpose
: purpose // ignore: cast_nullable_to_non_nullable
as String,
failureOrResendOption: null == failureOrResendOption
? _value.failureOrResendOption
: failureOrResendOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Resend>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ResendFormStateImplCopyWith<$Res>
implements $ResendFormStateCopyWith<$Res> {
factory _$$ResendFormStateImplCopyWith(
_$ResendFormStateImpl value,
$Res Function(_$ResendFormStateImpl) then,
) = __$$ResendFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String phoneNumber,
String purpose,
Option<Either<AuthFailure, Resend>> failureOrResendOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$ResendFormStateImplCopyWithImpl<$Res>
extends _$ResendFormStateCopyWithImpl<$Res, _$ResendFormStateImpl>
implements _$$ResendFormStateImplCopyWith<$Res> {
__$$ResendFormStateImplCopyWithImpl(
_$ResendFormStateImpl _value,
$Res Function(_$ResendFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of ResendFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? phoneNumber = null,
Object? purpose = null,
Object? failureOrResendOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$ResendFormStateImpl(
phoneNumber: null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
purpose: null == purpose
? _value.purpose
: purpose // ignore: cast_nullable_to_non_nullable
as String,
failureOrResendOption: null == failureOrResendOption
? _value.failureOrResendOption
: failureOrResendOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Resend>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$ResendFormStateImpl implements _ResendFormState {
const _$ResendFormStateImpl({
required this.phoneNumber,
required this.purpose,
required this.failureOrResendOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String phoneNumber;
@override
final String purpose;
@override
final Option<Either<AuthFailure, Resend>> failureOrResendOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'ResendFormState(phoneNumber: $phoneNumber, purpose: $purpose, failureOrResendOption: $failureOrResendOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ResendFormStateImpl &&
(identical(other.phoneNumber, phoneNumber) ||
other.phoneNumber == phoneNumber) &&
(identical(other.purpose, purpose) || other.purpose == purpose) &&
(identical(other.failureOrResendOption, failureOrResendOption) ||
other.failureOrResendOption == failureOrResendOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
phoneNumber,
purpose,
failureOrResendOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of ResendFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ResendFormStateImplCopyWith<_$ResendFormStateImpl> get copyWith =>
__$$ResendFormStateImplCopyWithImpl<_$ResendFormStateImpl>(
this,
_$identity,
);
}
abstract class _ResendFormState implements ResendFormState {
const factory _ResendFormState({
required final String phoneNumber,
required final String purpose,
required final Option<Either<AuthFailure, Resend>> failureOrResendOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$ResendFormStateImpl;
@override
String get phoneNumber;
@override
String get purpose;
@override
Option<Either<AuthFailure, Resend>> get failureOrResendOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of ResendFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ResendFormStateImplCopyWith<_$ResendFormStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,10 +0,0 @@
part of 'resend_form_bloc.dart';
@freezed
class ResendFormEvent with _$ResendFormEvent {
const factory ResendFormEvent.phoneNumberChanged(String phoneNumber) =
_PhoneNumberChanged;
const factory ResendFormEvent.purposeChanged(String purpose) =
_PurposeChanged;
const factory ResendFormEvent.submitted() = _Submitted;
}

View File

@ -1,18 +0,0 @@
part of 'resend_form_bloc.dart';
@freezed
class ResendFormState with _$ResendFormState {
const factory ResendFormState({
required String phoneNumber,
required String purpose,
required Option<Either<AuthFailure, Resend>> failureOrResendOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _ResendFormState;
factory ResendFormState.initial() => ResendFormState(
phoneNumber: '',
purpose: '',
failureOrResendOption: none(),
);
}

View File

@ -1,81 +0,0 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart';
part 'set_password_form_event.dart';
part 'set_password_form_state.dart';
part 'set_password_form_bloc.freezed.dart';
@injectable
class SetPasswordFormBloc
extends Bloc<SetPasswordFormEvent, SetPasswordFormState> {
final IAuthRepository _repository;
SetPasswordFormBloc(this._repository)
: super(SetPasswordFormState.initial()) {
on<SetPasswordFormEvent>(_onSetPasswordFormEvent);
}
Future<void> _onSetPasswordFormEvent(
SetPasswordFormEvent event,
Emitter<SetPasswordFormState> emit,
) {
return event.map(
registrationTokenChanged: (e) async {
emit(
state.copyWith(
registrationToken: e.registrationToken,
failureOrSetPasswordOption: none(),
),
);
},
passwordChanged: (e) async {
emit(
state.copyWith(
password: e.password,
failureOrSetPasswordOption: none(),
),
);
},
confirmPasswordChanged: (e) async {
emit(
state.copyWith(
confirmPassword: e.confirmPassword,
failureOrSetPasswordOption: none(),
),
);
},
submitted: (e) async {
Either<AuthFailure, Login>? failureOrSetPassword;
emit(
state.copyWith(
isSubmitting: true,
failureOrSetPasswordOption: none(),
),
);
final registrationTokenValid = state.registrationToken.isNotEmpty;
final passwordValid = state.password.isNotEmpty;
final confirmPasswordValid = state.confirmPassword.isNotEmpty;
if (registrationTokenValid && passwordValid && confirmPasswordValid) {
failureOrSetPassword = await _repository.setPassword(
registrationToken: state.registrationToken,
password: state.password,
confirmPassword: state.confirmPassword,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrSetPasswordOption: optionOf(failureOrSetPassword),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}

View File

@ -1,980 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'set_password_form_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$SetPasswordFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SetPasswordFormEventCopyWith<$Res> {
factory $SetPasswordFormEventCopyWith(
SetPasswordFormEvent value,
$Res Function(SetPasswordFormEvent) then,
) = _$SetPasswordFormEventCopyWithImpl<$Res, SetPasswordFormEvent>;
}
/// @nodoc
class _$SetPasswordFormEventCopyWithImpl<
$Res,
$Val extends SetPasswordFormEvent
>
implements $SetPasswordFormEventCopyWith<$Res> {
_$SetPasswordFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$RegistrationTokenChangedImplCopyWith<$Res> {
factory _$$RegistrationTokenChangedImplCopyWith(
_$RegistrationTokenChangedImpl value,
$Res Function(_$RegistrationTokenChangedImpl) then,
) = __$$RegistrationTokenChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String registrationToken});
}
/// @nodoc
class __$$RegistrationTokenChangedImplCopyWithImpl<$Res>
extends
_$SetPasswordFormEventCopyWithImpl<$Res, _$RegistrationTokenChangedImpl>
implements _$$RegistrationTokenChangedImplCopyWith<$Res> {
__$$RegistrationTokenChangedImplCopyWithImpl(
_$RegistrationTokenChangedImpl _value,
$Res Function(_$RegistrationTokenChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? registrationToken = null}) {
return _then(
_$RegistrationTokenChangedImpl(
null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$RegistrationTokenChangedImpl implements _RegistrationTokenChanged {
const _$RegistrationTokenChangedImpl(this.registrationToken);
@override
final String registrationToken;
@override
String toString() {
return 'SetPasswordFormEvent.registrationTokenChanged(registrationToken: $registrationToken)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$RegistrationTokenChangedImpl &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken));
}
@override
int get hashCode => Object.hash(runtimeType, registrationToken);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
get copyWith =>
__$$RegistrationTokenChangedImplCopyWithImpl<
_$RegistrationTokenChangedImpl
>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return registrationTokenChanged(registrationToken);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return registrationTokenChanged?.call(registrationToken);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (registrationTokenChanged != null) {
return registrationTokenChanged(registrationToken);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return registrationTokenChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return registrationTokenChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (registrationTokenChanged != null) {
return registrationTokenChanged(this);
}
return orElse();
}
}
abstract class _RegistrationTokenChanged implements SetPasswordFormEvent {
const factory _RegistrationTokenChanged(final String registrationToken) =
_$RegistrationTokenChangedImpl;
String get registrationToken;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$PasswordChangedImplCopyWith<$Res> {
factory _$$PasswordChangedImplCopyWith(
_$PasswordChangedImpl value,
$Res Function(_$PasswordChangedImpl) then,
) = __$$PasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String password});
}
/// @nodoc
class __$$PasswordChangedImplCopyWithImpl<$Res>
extends _$SetPasswordFormEventCopyWithImpl<$Res, _$PasswordChangedImpl>
implements _$$PasswordChangedImplCopyWith<$Res> {
__$$PasswordChangedImplCopyWithImpl(
_$PasswordChangedImpl _value,
$Res Function(_$PasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? password = null}) {
return _then(
_$PasswordChangedImpl(
null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$PasswordChangedImpl implements _PasswordChanged {
const _$PasswordChangedImpl(this.password);
@override
final String password;
@override
String toString() {
return 'SetPasswordFormEvent.passwordChanged(password: $password)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$PasswordChangedImpl &&
(identical(other.password, password) ||
other.password == password));
}
@override
int get hashCode => Object.hash(runtimeType, password);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
__$$PasswordChangedImplCopyWithImpl<_$PasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return passwordChanged(password);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return passwordChanged?.call(password);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (passwordChanged != null) {
return passwordChanged(password);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return passwordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return passwordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (passwordChanged != null) {
return passwordChanged(this);
}
return orElse();
}
}
abstract class _PasswordChanged implements SetPasswordFormEvent {
const factory _PasswordChanged(final String password) = _$PasswordChangedImpl;
String get password;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$ConfirmPasswordChangedImplCopyWith<$Res> {
factory _$$ConfirmPasswordChangedImplCopyWith(
_$ConfirmPasswordChangedImpl value,
$Res Function(_$ConfirmPasswordChangedImpl) then,
) = __$$ConfirmPasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String confirmPassword});
}
/// @nodoc
class __$$ConfirmPasswordChangedImplCopyWithImpl<$Res>
extends
_$SetPasswordFormEventCopyWithImpl<$Res, _$ConfirmPasswordChangedImpl>
implements _$$ConfirmPasswordChangedImplCopyWith<$Res> {
__$$ConfirmPasswordChangedImplCopyWithImpl(
_$ConfirmPasswordChangedImpl _value,
$Res Function(_$ConfirmPasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? confirmPassword = null}) {
return _then(
_$ConfirmPasswordChangedImpl(
null == confirmPassword
? _value.confirmPassword
: confirmPassword // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$ConfirmPasswordChangedImpl implements _ConfirmPasswordChanged {
const _$ConfirmPasswordChangedImpl(this.confirmPassword);
@override
final String confirmPassword;
@override
String toString() {
return 'SetPasswordFormEvent.confirmPasswordChanged(confirmPassword: $confirmPassword)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ConfirmPasswordChangedImpl &&
(identical(other.confirmPassword, confirmPassword) ||
other.confirmPassword == confirmPassword));
}
@override
int get hashCode => Object.hash(runtimeType, confirmPassword);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ConfirmPasswordChangedImplCopyWith<_$ConfirmPasswordChangedImpl>
get copyWith =>
__$$ConfirmPasswordChangedImplCopyWithImpl<_$ConfirmPasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return confirmPasswordChanged(confirmPassword);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return confirmPasswordChanged?.call(confirmPassword);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (confirmPasswordChanged != null) {
return confirmPasswordChanged(confirmPassword);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return confirmPasswordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return confirmPasswordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (confirmPasswordChanged != null) {
return confirmPasswordChanged(this);
}
return orElse();
}
}
abstract class _ConfirmPasswordChanged implements SetPasswordFormEvent {
const factory _ConfirmPasswordChanged(final String confirmPassword) =
_$ConfirmPasswordChangedImpl;
String get confirmPassword;
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ConfirmPasswordChangedImplCopyWith<_$ConfirmPasswordChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$SetPasswordFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'SetPasswordFormEvent.submitted()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String password) passwordChanged,
required TResult Function(String confirmPassword) confirmPasswordChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String password)? passwordChanged,
TResult? Function(String confirmPassword)? confirmPasswordChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String password)? passwordChanged,
TResult Function(String confirmPassword)? confirmPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_PasswordChanged value) passwordChanged,
required TResult Function(_ConfirmPasswordChanged value)
confirmPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_PasswordChanged value)? passwordChanged,
TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_PasswordChanged value)? passwordChanged,
TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements SetPasswordFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$SetPasswordFormState {
String get registrationToken => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
String get confirmPassword => throw _privateConstructorUsedError;
Option<Either<AuthFailure, Login>> get failureOrSetPasswordOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SetPasswordFormStateCopyWith<SetPasswordFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SetPasswordFormStateCopyWith<$Res> {
factory $SetPasswordFormStateCopyWith(
SetPasswordFormState value,
$Res Function(SetPasswordFormState) then,
) = _$SetPasswordFormStateCopyWithImpl<$Res, SetPasswordFormState>;
@useResult
$Res call({
String registrationToken,
String password,
String confirmPassword,
Option<Either<AuthFailure, Login>> failureOrSetPasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$SetPasswordFormStateCopyWithImpl<
$Res,
$Val extends SetPasswordFormState
>
implements $SetPasswordFormStateCopyWith<$Res> {
_$SetPasswordFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? registrationToken = null,
Object? password = null,
Object? confirmPassword = null,
Object? failureOrSetPasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
confirmPassword: null == confirmPassword
? _value.confirmPassword
: confirmPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrSetPasswordOption: null == failureOrSetPasswordOption
? _value.failureOrSetPasswordOption
: failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Login>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$SetPasswordFormStateImplCopyWith<$Res>
implements $SetPasswordFormStateCopyWith<$Res> {
factory _$$SetPasswordFormStateImplCopyWith(
_$SetPasswordFormStateImpl value,
$Res Function(_$SetPasswordFormStateImpl) then,
) = __$$SetPasswordFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String registrationToken,
String password,
String confirmPassword,
Option<Either<AuthFailure, Login>> failureOrSetPasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$SetPasswordFormStateImplCopyWithImpl<$Res>
extends _$SetPasswordFormStateCopyWithImpl<$Res, _$SetPasswordFormStateImpl>
implements _$$SetPasswordFormStateImplCopyWith<$Res> {
__$$SetPasswordFormStateImplCopyWithImpl(
_$SetPasswordFormStateImpl _value,
$Res Function(_$SetPasswordFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? registrationToken = null,
Object? password = null,
Object? confirmPassword = null,
Object? failureOrSetPasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$SetPasswordFormStateImpl(
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
confirmPassword: null == confirmPassword
? _value.confirmPassword
: confirmPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrSetPasswordOption: null == failureOrSetPasswordOption
? _value.failureOrSetPasswordOption
: failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Login>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$SetPasswordFormStateImpl implements _SetPasswordFormState {
const _$SetPasswordFormStateImpl({
required this.registrationToken,
required this.password,
required this.confirmPassword,
required this.failureOrSetPasswordOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String registrationToken;
@override
final String password;
@override
final String confirmPassword;
@override
final Option<Either<AuthFailure, Login>> failureOrSetPasswordOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'SetPasswordFormState(registrationToken: $registrationToken, password: $password, confirmPassword: $confirmPassword, failureOrSetPasswordOption: $failureOrSetPasswordOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SetPasswordFormStateImpl &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken) &&
(identical(other.password, password) ||
other.password == password) &&
(identical(other.confirmPassword, confirmPassword) ||
other.confirmPassword == confirmPassword) &&
(identical(
other.failureOrSetPasswordOption,
failureOrSetPasswordOption,
) ||
other.failureOrSetPasswordOption ==
failureOrSetPasswordOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
registrationToken,
password,
confirmPassword,
failureOrSetPasswordOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SetPasswordFormStateImplCopyWith<_$SetPasswordFormStateImpl>
get copyWith =>
__$$SetPasswordFormStateImplCopyWithImpl<_$SetPasswordFormStateImpl>(
this,
_$identity,
);
}
abstract class _SetPasswordFormState implements SetPasswordFormState {
const factory _SetPasswordFormState({
required final String registrationToken,
required final String password,
required final String confirmPassword,
required final Option<Either<AuthFailure, Login>>
failureOrSetPasswordOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$SetPasswordFormStateImpl;
@override
String get registrationToken;
@override
String get password;
@override
String get confirmPassword;
@override
Option<Either<AuthFailure, Login>> get failureOrSetPasswordOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of SetPasswordFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SetPasswordFormStateImplCopyWith<_$SetPasswordFormStateImpl>
get copyWith => throw _privateConstructorUsedError;
}

View File

@ -1,14 +0,0 @@
part of 'set_password_form_bloc.dart';
@freezed
class SetPasswordFormEvent with _$SetPasswordFormEvent {
const factory SetPasswordFormEvent.registrationTokenChanged(
String registrationToken,
) = _RegistrationTokenChanged;
const factory SetPasswordFormEvent.passwordChanged(String password) =
_PasswordChanged;
const factory SetPasswordFormEvent.confirmPasswordChanged(
String confirmPassword,
) = _ConfirmPasswordChanged;
const factory SetPasswordFormEvent.submitted() = _Submitted;
}

View File

@ -1,20 +0,0 @@
part of 'set_password_form_bloc.dart';
@freezed
class SetPasswordFormState with _$SetPasswordFormState {
const factory SetPasswordFormState({
required String registrationToken,
required String password,
required String confirmPassword,
required Option<Either<AuthFailure, Login>> failureOrSetPasswordOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _SetPasswordFormState;
factory SetPasswordFormState.initial() => SetPasswordFormState(
registrationToken: '',
password: '',
confirmPassword: '',
failureOrSetPasswordOption: none(),
);
}

View File

@ -1,58 +0,0 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart';
part 'verify_form_event.dart';
part 'verify_form_state.dart';
part 'verify_form_bloc.freezed.dart';
@injectable
class VerifyFormBloc extends Bloc<VerifyFormEvent, VerifyFormState> {
final IAuthRepository _repository;
VerifyFormBloc(this._repository) : super(VerifyFormState.initial()) {
on<VerifyFormEvent>(_onVerifyFormEvent);
}
Future<void> _onVerifyFormEvent(
VerifyFormEvent event,
Emitter<VerifyFormState> emit,
) {
return event.map(
registrationTokenChanged: (e) async {
emit(
state.copyWith(
registrationToken: e.registrationToken,
failureOrVerifyOption: none(),
),
);
},
otpCodeChanged: (e) async {
emit(state.copyWith(otpCode: e.otpCode, failureOrVerifyOption: none()));
},
submitted: (e) async {
Either<AuthFailure, Verify>? failureOrVerify;
emit(state.copyWith(isSubmitting: true, failureOrVerifyOption: none()));
final otpCodeValid = state.otpCode.isNotEmpty;
final registrationTokenValid = state.registrationToken.isNotEmpty;
if (registrationTokenValid && otpCodeValid) {
failureOrVerify = await _repository.verify(
registrationToken: state.registrationToken,
otpCode: state.otpCode,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrVerifyOption: optionOf(failureOrVerify),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}

View File

@ -1,750 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'verify_form_bloc.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
);
/// @nodoc
mixin _$VerifyFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String otpCode) otpCodeChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String otpCode)? otpCodeChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String otpCode)? otpCodeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $VerifyFormEventCopyWith<$Res> {
factory $VerifyFormEventCopyWith(
VerifyFormEvent value,
$Res Function(VerifyFormEvent) then,
) = _$VerifyFormEventCopyWithImpl<$Res, VerifyFormEvent>;
}
/// @nodoc
class _$VerifyFormEventCopyWithImpl<$Res, $Val extends VerifyFormEvent>
implements $VerifyFormEventCopyWith<$Res> {
_$VerifyFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$RegistrationTokenChangedImplCopyWith<$Res> {
factory _$$RegistrationTokenChangedImplCopyWith(
_$RegistrationTokenChangedImpl value,
$Res Function(_$RegistrationTokenChangedImpl) then,
) = __$$RegistrationTokenChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String registrationToken});
}
/// @nodoc
class __$$RegistrationTokenChangedImplCopyWithImpl<$Res>
extends _$VerifyFormEventCopyWithImpl<$Res, _$RegistrationTokenChangedImpl>
implements _$$RegistrationTokenChangedImplCopyWith<$Res> {
__$$RegistrationTokenChangedImplCopyWithImpl(
_$RegistrationTokenChangedImpl _value,
$Res Function(_$RegistrationTokenChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? registrationToken = null}) {
return _then(
_$RegistrationTokenChangedImpl(
null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$RegistrationTokenChangedImpl implements _RegistrationTokenChanged {
const _$RegistrationTokenChangedImpl(this.registrationToken);
@override
final String registrationToken;
@override
String toString() {
return 'VerifyFormEvent.registrationTokenChanged(registrationToken: $registrationToken)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$RegistrationTokenChangedImpl &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken));
}
@override
int get hashCode => Object.hash(runtimeType, registrationToken);
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
get copyWith =>
__$$RegistrationTokenChangedImplCopyWithImpl<
_$RegistrationTokenChangedImpl
>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String otpCode) otpCodeChanged,
required TResult Function() submitted,
}) {
return registrationTokenChanged(registrationToken);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String otpCode)? otpCodeChanged,
TResult? Function()? submitted,
}) {
return registrationTokenChanged?.call(registrationToken);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String otpCode)? otpCodeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (registrationTokenChanged != null) {
return registrationTokenChanged(registrationToken);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
required TResult Function(_Submitted value) submitted,
}) {
return registrationTokenChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return registrationTokenChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (registrationTokenChanged != null) {
return registrationTokenChanged(this);
}
return orElse();
}
}
abstract class _RegistrationTokenChanged implements VerifyFormEvent {
const factory _RegistrationTokenChanged(final String registrationToken) =
_$RegistrationTokenChangedImpl;
String get registrationToken;
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$OtpCodeChangedImplCopyWith<$Res> {
factory _$$OtpCodeChangedImplCopyWith(
_$OtpCodeChangedImpl value,
$Res Function(_$OtpCodeChangedImpl) then,
) = __$$OtpCodeChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String otpCode});
}
/// @nodoc
class __$$OtpCodeChangedImplCopyWithImpl<$Res>
extends _$VerifyFormEventCopyWithImpl<$Res, _$OtpCodeChangedImpl>
implements _$$OtpCodeChangedImplCopyWith<$Res> {
__$$OtpCodeChangedImplCopyWithImpl(
_$OtpCodeChangedImpl _value,
$Res Function(_$OtpCodeChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? otpCode = null}) {
return _then(
_$OtpCodeChangedImpl(
null == otpCode
? _value.otpCode
: otpCode // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$OtpCodeChangedImpl implements _OtpCodeChanged {
const _$OtpCodeChangedImpl(this.otpCode);
@override
final String otpCode;
@override
String toString() {
return 'VerifyFormEvent.otpCodeChanged(otpCode: $otpCode)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$OtpCodeChangedImpl &&
(identical(other.otpCode, otpCode) || other.otpCode == otpCode));
}
@override
int get hashCode => Object.hash(runtimeType, otpCode);
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$OtpCodeChangedImplCopyWith<_$OtpCodeChangedImpl> get copyWith =>
__$$OtpCodeChangedImplCopyWithImpl<_$OtpCodeChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String otpCode) otpCodeChanged,
required TResult Function() submitted,
}) {
return otpCodeChanged(otpCode);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String otpCode)? otpCodeChanged,
TResult? Function()? submitted,
}) {
return otpCodeChanged?.call(otpCode);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String otpCode)? otpCodeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (otpCodeChanged != null) {
return otpCodeChanged(otpCode);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
required TResult Function(_Submitted value) submitted,
}) {
return otpCodeChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return otpCodeChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (otpCodeChanged != null) {
return otpCodeChanged(this);
}
return orElse();
}
}
abstract class _OtpCodeChanged implements VerifyFormEvent {
const factory _OtpCodeChanged(final String otpCode) = _$OtpCodeChangedImpl;
String get otpCode;
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$OtpCodeChangedImplCopyWith<_$OtpCodeChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$VerifyFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of VerifyFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'VerifyFormEvent.submitted()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String registrationToken)
registrationTokenChanged,
required TResult Function(String otpCode) otpCodeChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String registrationToken)? registrationTokenChanged,
TResult? Function(String otpCode)? otpCodeChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String registrationToken)? registrationTokenChanged,
TResult Function(String otpCode)? otpCodeChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RegistrationTokenChanged value)
registrationTokenChanged,
required TResult Function(_OtpCodeChanged value) otpCodeChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RegistrationTokenChanged value)?
registrationTokenChanged,
TResult? Function(_OtpCodeChanged value)? otpCodeChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged,
TResult Function(_OtpCodeChanged value)? otpCodeChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements VerifyFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$VerifyFormState {
String get registrationToken => throw _privateConstructorUsedError;
String get otpCode => throw _privateConstructorUsedError;
Option<Either<AuthFailure, Verify>> get failureOrVerifyOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of VerifyFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$VerifyFormStateCopyWith<VerifyFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $VerifyFormStateCopyWith<$Res> {
factory $VerifyFormStateCopyWith(
VerifyFormState value,
$Res Function(VerifyFormState) then,
) = _$VerifyFormStateCopyWithImpl<$Res, VerifyFormState>;
@useResult
$Res call({
String registrationToken,
String otpCode,
Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$VerifyFormStateCopyWithImpl<$Res, $Val extends VerifyFormState>
implements $VerifyFormStateCopyWith<$Res> {
_$VerifyFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of VerifyFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? registrationToken = null,
Object? otpCode = null,
Object? failureOrVerifyOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
otpCode: null == otpCode
? _value.otpCode
: otpCode // ignore: cast_nullable_to_non_nullable
as String,
failureOrVerifyOption: null == failureOrVerifyOption
? _value.failureOrVerifyOption
: failureOrVerifyOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Verify>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$VerifyFormStateImplCopyWith<$Res>
implements $VerifyFormStateCopyWith<$Res> {
factory _$$VerifyFormStateImplCopyWith(
_$VerifyFormStateImpl value,
$Res Function(_$VerifyFormStateImpl) then,
) = __$$VerifyFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String registrationToken,
String otpCode,
Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$VerifyFormStateImplCopyWithImpl<$Res>
extends _$VerifyFormStateCopyWithImpl<$Res, _$VerifyFormStateImpl>
implements _$$VerifyFormStateImplCopyWith<$Res> {
__$$VerifyFormStateImplCopyWithImpl(
_$VerifyFormStateImpl _value,
$Res Function(_$VerifyFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of VerifyFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? registrationToken = null,
Object? otpCode = null,
Object? failureOrVerifyOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$VerifyFormStateImpl(
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
otpCode: null == otpCode
? _value.otpCode
: otpCode // ignore: cast_nullable_to_non_nullable
as String,
failureOrVerifyOption: null == failureOrVerifyOption
? _value.failureOrVerifyOption
: failureOrVerifyOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Verify>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$VerifyFormStateImpl implements _VerifyFormState {
const _$VerifyFormStateImpl({
required this.registrationToken,
required this.otpCode,
required this.failureOrVerifyOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String registrationToken;
@override
final String otpCode;
@override
final Option<Either<AuthFailure, Verify>> failureOrVerifyOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'VerifyFormState(registrationToken: $registrationToken, otpCode: $otpCode, failureOrVerifyOption: $failureOrVerifyOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$VerifyFormStateImpl &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken) &&
(identical(other.otpCode, otpCode) || other.otpCode == otpCode) &&
(identical(other.failureOrVerifyOption, failureOrVerifyOption) ||
other.failureOrVerifyOption == failureOrVerifyOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
registrationToken,
otpCode,
failureOrVerifyOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of VerifyFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$VerifyFormStateImplCopyWith<_$VerifyFormStateImpl> get copyWith =>
__$$VerifyFormStateImplCopyWithImpl<_$VerifyFormStateImpl>(
this,
_$identity,
);
}
abstract class _VerifyFormState implements VerifyFormState {
const factory _VerifyFormState({
required final String registrationToken,
required final String otpCode,
required final Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$VerifyFormStateImpl;
@override
String get registrationToken;
@override
String get otpCode;
@override
Option<Either<AuthFailure, Verify>> get failureOrVerifyOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of VerifyFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$VerifyFormStateImplCopyWith<_$VerifyFormStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,11 +0,0 @@
part of 'verify_form_bloc.dart';
@freezed
class VerifyFormEvent with _$VerifyFormEvent {
const factory VerifyFormEvent.registrationTokenChanged(
String registrationToken,
) = _RegistrationTokenChanged;
const factory VerifyFormEvent.otpCodeChanged(String otpCode) =
_OtpCodeChanged;
const factory VerifyFormEvent.submitted() = _Submitted;
}

View File

@ -1,18 +0,0 @@
part of 'verify_form_bloc.dart';
@freezed
class VerifyFormState with _$VerifyFormState {
const factory VerifyFormState({
required String registrationToken,
required String otpCode,
required Option<Either<AuthFailure, Verify>> failureOrVerifyOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _VerifyFormState;
factory VerifyFormState.initial() => VerifyFormState(
registrationToken: '',
otpCode: '',
failureOrVerifyOption: none(),
);
}

View File

@ -15,15 +15,4 @@ extension StringExt on String {
return CheckPhoneStatus.unknown; return CheckPhoneStatus.unknown;
} }
} }
ResendStatus toResendStatus() {
switch (this) {
case 'RESEND_NOT_ALLOWED':
return ResendStatus.resendNotAllowed;
case 'SUCCESS':
return ResendStatus.success;
default:
return ResendStatus.unknown;
}
}
} }

View File

@ -1,8 +1,4 @@
class ApiPath { class ApiPath {
static String checkPhone = '/api/v1/customer-auth/check-phone'; static String checkPhone = '/api/v1/customer-auth/check-phone';
static String register = '/api/v1/customer-auth/register/start'; static String register = '/api/v1/customer-auth/register/start';
static String verify = '/api/v1/customer-auth/register/verify-otp';
static String setPassword = '/api/v1/customer-auth/register/set-password';
static String login = '/api/v1/customer-auth/register/login';
static String resend = '/api/v1/customer-auth/register/resend-otp';
} }

View File

@ -7,9 +7,6 @@ part 'auth.freezed.dart';
part 'entities/check_phone_entity.dart'; part 'entities/check_phone_entity.dart';
part 'entities/register_entity.dart'; part 'entities/register_entity.dart';
part 'entities/verify_entity.dart';
part 'entities/login_entity.dart';
part 'entities/resend_entity.dart';
part 'failures/auth_failure.dart'; part 'failures/auth_failure.dart';
part 'repositories/i_auth_repository.dart'; part 'repositories/i_auth_repository.dart';
@ -25,16 +22,3 @@ extension CheckPhoneStatusX on CheckPhoneStatus {
bool get isNotRegistered => this == CheckPhoneStatus.notRegistered; bool get isNotRegistered => this == CheckPhoneStatus.notRegistered;
bool get isPasswordRequired => this == CheckPhoneStatus.passwordRequired; bool get isPasswordRequired => this == CheckPhoneStatus.passwordRequired;
} }
enum ResendStatus { resendNotAllowed, success, unknown }
extension ResendStatusX on ResendStatus {
String toStringType() => switch (this) {
ResendStatus.resendNotAllowed => 'RESEND_NOT_ALLOWED',
ResendStatus.success => 'SUCCESS',
ResendStatus.unknown => '',
};
bool get isResendNotAllowed => this == ResendStatus.resendNotAllowed;
bool get isSuccess => this == ResendStatus.success;
}

View File

@ -424,845 +424,6 @@ abstract class _Register implements Register {
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
/// @nodoc
mixin _$Verify {
String get status => throw _privateConstructorUsedError;
String get message => throw _privateConstructorUsedError;
String get registrationToken => throw _privateConstructorUsedError;
/// Create a copy of Verify
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$VerifyCopyWith<Verify> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $VerifyCopyWith<$Res> {
factory $VerifyCopyWith(Verify value, $Res Function(Verify) then) =
_$VerifyCopyWithImpl<$Res, Verify>;
@useResult
$Res call({String status, String message, String registrationToken});
}
/// @nodoc
class _$VerifyCopyWithImpl<$Res, $Val extends Verify>
implements $VerifyCopyWith<$Res> {
_$VerifyCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Verify
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = null,
Object? message = null,
Object? registrationToken = null,
}) {
return _then(
_value.copyWith(
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$VerifyImplCopyWith<$Res> implements $VerifyCopyWith<$Res> {
factory _$$VerifyImplCopyWith(
_$VerifyImpl value,
$Res Function(_$VerifyImpl) then,
) = __$$VerifyImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String status, String message, String registrationToken});
}
/// @nodoc
class __$$VerifyImplCopyWithImpl<$Res>
extends _$VerifyCopyWithImpl<$Res, _$VerifyImpl>
implements _$$VerifyImplCopyWith<$Res> {
__$$VerifyImplCopyWithImpl(
_$VerifyImpl _value,
$Res Function(_$VerifyImpl) _then,
) : super(_value, _then);
/// Create a copy of Verify
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = null,
Object? message = null,
Object? registrationToken = null,
}) {
return _then(
_$VerifyImpl(
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
registrationToken: null == registrationToken
? _value.registrationToken
: registrationToken // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$VerifyImpl implements _Verify {
const _$VerifyImpl({
required this.status,
required this.message,
required this.registrationToken,
});
@override
final String status;
@override
final String message;
@override
final String registrationToken;
@override
String toString() {
return 'Verify(status: $status, message: $message, registrationToken: $registrationToken)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$VerifyImpl &&
(identical(other.status, status) || other.status == status) &&
(identical(other.message, message) || other.message == message) &&
(identical(other.registrationToken, registrationToken) ||
other.registrationToken == registrationToken));
}
@override
int get hashCode =>
Object.hash(runtimeType, status, message, registrationToken);
/// Create a copy of Verify
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$VerifyImplCopyWith<_$VerifyImpl> get copyWith =>
__$$VerifyImplCopyWithImpl<_$VerifyImpl>(this, _$identity);
}
abstract class _Verify implements Verify {
const factory _Verify({
required final String status,
required final String message,
required final String registrationToken,
}) = _$VerifyImpl;
@override
String get status;
@override
String get message;
@override
String get registrationToken;
/// Create a copy of Verify
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$VerifyImplCopyWith<_$VerifyImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$Login {
String get status => throw _privateConstructorUsedError;
String get message => throw _privateConstructorUsedError;
String get accessToken => throw _privateConstructorUsedError;
String get refreshToken => throw _privateConstructorUsedError;
User get user => throw _privateConstructorUsedError;
/// Create a copy of Login
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LoginCopyWith<Login> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LoginCopyWith<$Res> {
factory $LoginCopyWith(Login value, $Res Function(Login) then) =
_$LoginCopyWithImpl<$Res, Login>;
@useResult
$Res call({
String status,
String message,
String accessToken,
String refreshToken,
User user,
});
$UserCopyWith<$Res> get user;
}
/// @nodoc
class _$LoginCopyWithImpl<$Res, $Val extends Login>
implements $LoginCopyWith<$Res> {
_$LoginCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Login
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = null,
Object? message = null,
Object? accessToken = null,
Object? refreshToken = null,
Object? user = null,
}) {
return _then(
_value.copyWith(
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
accessToken: null == accessToken
? _value.accessToken
: accessToken // ignore: cast_nullable_to_non_nullable
as String,
refreshToken: null == refreshToken
? _value.refreshToken
: refreshToken // ignore: cast_nullable_to_non_nullable
as String,
user: null == user
? _value.user
: user // ignore: cast_nullable_to_non_nullable
as User,
)
as $Val,
);
}
/// Create a copy of Login
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$UserCopyWith<$Res> get user {
return $UserCopyWith<$Res>(_value.user, (value) {
return _then(_value.copyWith(user: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$LoginImplCopyWith<$Res> implements $LoginCopyWith<$Res> {
factory _$$LoginImplCopyWith(
_$LoginImpl value,
$Res Function(_$LoginImpl) then,
) = __$$LoginImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String status,
String message,
String accessToken,
String refreshToken,
User user,
});
@override
$UserCopyWith<$Res> get user;
}
/// @nodoc
class __$$LoginImplCopyWithImpl<$Res>
extends _$LoginCopyWithImpl<$Res, _$LoginImpl>
implements _$$LoginImplCopyWith<$Res> {
__$$LoginImplCopyWithImpl(
_$LoginImpl _value,
$Res Function(_$LoginImpl) _then,
) : super(_value, _then);
/// Create a copy of Login
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = null,
Object? message = null,
Object? accessToken = null,
Object? refreshToken = null,
Object? user = null,
}) {
return _then(
_$LoginImpl(
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
accessToken: null == accessToken
? _value.accessToken
: accessToken // ignore: cast_nullable_to_non_nullable
as String,
refreshToken: null == refreshToken
? _value.refreshToken
: refreshToken // ignore: cast_nullable_to_non_nullable
as String,
user: null == user
? _value.user
: user // ignore: cast_nullable_to_non_nullable
as User,
),
);
}
}
/// @nodoc
class _$LoginImpl implements _Login {
const _$LoginImpl({
required this.status,
required this.message,
required this.accessToken,
required this.refreshToken,
required this.user,
});
@override
final String status;
@override
final String message;
@override
final String accessToken;
@override
final String refreshToken;
@override
final User user;
@override
String toString() {
return 'Login(status: $status, message: $message, accessToken: $accessToken, refreshToken: $refreshToken, user: $user)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LoginImpl &&
(identical(other.status, status) || other.status == status) &&
(identical(other.message, message) || other.message == message) &&
(identical(other.accessToken, accessToken) ||
other.accessToken == accessToken) &&
(identical(other.refreshToken, refreshToken) ||
other.refreshToken == refreshToken) &&
(identical(other.user, user) || other.user == user));
}
@override
int get hashCode => Object.hash(
runtimeType,
status,
message,
accessToken,
refreshToken,
user,
);
/// Create a copy of Login
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LoginImplCopyWith<_$LoginImpl> get copyWith =>
__$$LoginImplCopyWithImpl<_$LoginImpl>(this, _$identity);
}
abstract class _Login implements Login {
const factory _Login({
required final String status,
required final String message,
required final String accessToken,
required final String refreshToken,
required final User user,
}) = _$LoginImpl;
@override
String get status;
@override
String get message;
@override
String get accessToken;
@override
String get refreshToken;
@override
User get user;
/// Create a copy of Login
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LoginImplCopyWith<_$LoginImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$User {
String get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
String get phoneNumber => throw _privateConstructorUsedError;
String get birthDate => throw _privateConstructorUsedError;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserCopyWith<User> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserCopyWith<$Res> {
factory $UserCopyWith(User value, $Res Function(User) then) =
_$UserCopyWithImpl<$Res, User>;
@useResult
$Res call({String id, String name, String phoneNumber, String birthDate});
}
/// @nodoc
class _$UserCopyWithImpl<$Res, $Val extends User>
implements $UserCopyWith<$Res> {
_$UserCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? phoneNumber = null,
Object? birthDate = null,
}) {
return _then(
_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
phoneNumber: null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
birthDate: null == birthDate
? _value.birthDate
: birthDate // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> {
factory _$$UserImplCopyWith(
_$UserImpl value,
$Res Function(_$UserImpl) then,
) = __$$UserImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String name, String phoneNumber, String birthDate});
}
/// @nodoc
class __$$UserImplCopyWithImpl<$Res>
extends _$UserCopyWithImpl<$Res, _$UserImpl>
implements _$$UserImplCopyWith<$Res> {
__$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then)
: super(_value, _then);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? phoneNumber = null,
Object? birthDate = null,
}) {
return _then(
_$UserImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
phoneNumber: null == phoneNumber
? _value.phoneNumber
: phoneNumber // ignore: cast_nullable_to_non_nullable
as String,
birthDate: null == birthDate
? _value.birthDate
: birthDate // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$UserImpl implements _User {
const _$UserImpl({
required this.id,
required this.name,
required this.phoneNumber,
required this.birthDate,
});
@override
final String id;
@override
final String name;
@override
final String phoneNumber;
@override
final String birthDate;
@override
String toString() {
return 'User(id: $id, name: $name, phoneNumber: $phoneNumber, birthDate: $birthDate)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.phoneNumber, phoneNumber) ||
other.phoneNumber == phoneNumber) &&
(identical(other.birthDate, birthDate) ||
other.birthDate == birthDate));
}
@override
int get hashCode =>
Object.hash(runtimeType, id, name, phoneNumber, birthDate);
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
__$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity);
}
abstract class _User implements User {
const factory _User({
required final String id,
required final String name,
required final String phoneNumber,
required final String birthDate,
}) = _$UserImpl;
@override
String get id;
@override
String get name;
@override
String get phoneNumber;
@override
String get birthDate;
/// Create a copy of User
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserImplCopyWith<_$UserImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$Resend {
String get status => throw _privateConstructorUsedError;
String get message => throw _privateConstructorUsedError;
String get otpToken => throw _privateConstructorUsedError;
int get expiresIn => throw _privateConstructorUsedError;
int get nextResendIn => throw _privateConstructorUsedError;
/// Create a copy of Resend
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ResendCopyWith<Resend> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ResendCopyWith<$Res> {
factory $ResendCopyWith(Resend value, $Res Function(Resend) then) =
_$ResendCopyWithImpl<$Res, Resend>;
@useResult
$Res call({
String status,
String message,
String otpToken,
int expiresIn,
int nextResendIn,
});
}
/// @nodoc
class _$ResendCopyWithImpl<$Res, $Val extends Resend>
implements $ResendCopyWith<$Res> {
_$ResendCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of Resend
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = null,
Object? message = null,
Object? otpToken = null,
Object? expiresIn = null,
Object? nextResendIn = null,
}) {
return _then(
_value.copyWith(
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
otpToken: null == otpToken
? _value.otpToken
: otpToken // ignore: cast_nullable_to_non_nullable
as String,
expiresIn: null == expiresIn
? _value.expiresIn
: expiresIn // ignore: cast_nullable_to_non_nullable
as int,
nextResendIn: null == nextResendIn
? _value.nextResendIn
: nextResendIn // ignore: cast_nullable_to_non_nullable
as int,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ResendImplCopyWith<$Res> implements $ResendCopyWith<$Res> {
factory _$$ResendImplCopyWith(
_$ResendImpl value,
$Res Function(_$ResendImpl) then,
) = __$$ResendImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String status,
String message,
String otpToken,
int expiresIn,
int nextResendIn,
});
}
/// @nodoc
class __$$ResendImplCopyWithImpl<$Res>
extends _$ResendCopyWithImpl<$Res, _$ResendImpl>
implements _$$ResendImplCopyWith<$Res> {
__$$ResendImplCopyWithImpl(
_$ResendImpl _value,
$Res Function(_$ResendImpl) _then,
) : super(_value, _then);
/// Create a copy of Resend
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = null,
Object? message = null,
Object? otpToken = null,
Object? expiresIn = null,
Object? nextResendIn = null,
}) {
return _then(
_$ResendImpl(
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String,
otpToken: null == otpToken
? _value.otpToken
: otpToken // ignore: cast_nullable_to_non_nullable
as String,
expiresIn: null == expiresIn
? _value.expiresIn
: expiresIn // ignore: cast_nullable_to_non_nullable
as int,
nextResendIn: null == nextResendIn
? _value.nextResendIn
: nextResendIn // ignore: cast_nullable_to_non_nullable
as int,
),
);
}
}
/// @nodoc
class _$ResendImpl implements _Resend {
const _$ResendImpl({
required this.status,
required this.message,
required this.otpToken,
required this.expiresIn,
required this.nextResendIn,
});
@override
final String status;
@override
final String message;
@override
final String otpToken;
@override
final int expiresIn;
@override
final int nextResendIn;
@override
String toString() {
return 'Resend(status: $status, message: $message, otpToken: $otpToken, expiresIn: $expiresIn, nextResendIn: $nextResendIn)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ResendImpl &&
(identical(other.status, status) || other.status == status) &&
(identical(other.message, message) || other.message == message) &&
(identical(other.otpToken, otpToken) ||
other.otpToken == otpToken) &&
(identical(other.expiresIn, expiresIn) ||
other.expiresIn == expiresIn) &&
(identical(other.nextResendIn, nextResendIn) ||
other.nextResendIn == nextResendIn));
}
@override
int get hashCode => Object.hash(
runtimeType,
status,
message,
otpToken,
expiresIn,
nextResendIn,
);
/// Create a copy of Resend
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ResendImplCopyWith<_$ResendImpl> get copyWith =>
__$$ResendImplCopyWithImpl<_$ResendImpl>(this, _$identity);
}
abstract class _Resend implements Resend {
const factory _Resend({
required final String status,
required final String message,
required final String otpToken,
required final int expiresIn,
required final int nextResendIn,
}) = _$ResendImpl;
@override
String get status;
@override
String get message;
@override
String get otpToken;
@override
int get expiresIn;
@override
int get nextResendIn;
/// Create a copy of Resend
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ResendImplCopyWith<_$ResendImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc /// @nodoc
mixin _$AuthFailure { mixin _$AuthFailure {
@optionalTypeArgs @optionalTypeArgs

View File

@ -1,33 +0,0 @@
part of '../auth.dart';
@freezed
class Login with _$Login {
const factory Login({
required String status,
required String message,
required String accessToken,
required String refreshToken,
required User user,
}) = _Login;
factory Login.empty() => Login(
status: '',
message: '',
accessToken: '',
refreshToken: '',
user: User.empty(),
);
}
@freezed
class User with _$User {
const factory User({
required String id,
required String name,
required String phoneNumber,
required String birthDate,
}) = _User;
factory User.empty() =>
const User(id: '', name: '', phoneNumber: '', birthDate: '');
}

View File

@ -1,20 +0,0 @@
part of '../auth.dart';
@freezed
class Resend with _$Resend {
const factory Resend({
required String status,
required String message,
required String otpToken,
required int expiresIn,
required int nextResendIn,
}) = _Resend;
factory Resend.empty() => const Resend(
status: '',
message: '',
otpToken: '',
expiresIn: 0,
nextResendIn: 0,
);
}

View File

@ -1,13 +0,0 @@
part of '../auth.dart';
@freezed
class Verify with _$Verify {
const factory Verify({
required String status,
required String message,
required String registrationToken,
}) = _Verify;
factory Verify.empty() =>
const Verify(status: '', message: '', registrationToken: '');
}

View File

@ -10,25 +10,4 @@ abstract class IAuthRepository {
required String name, required String name,
required DateTime birthDate, required DateTime birthDate,
}); });
Future<Either<AuthFailure, Verify>> verify({
required String registrationToken,
required String otpCode,
});
Future<Either<AuthFailure, Login>> setPassword({
required String registrationToken,
required String password,
required String confirmPassword,
});
Future<Either<AuthFailure, Login>> login({
required String phoneNumber,
required String password,
});
Future<Either<AuthFailure, Resend>> resend({
required String phoneNumber,
required String purpose,
});
} }

View File

@ -7,6 +7,3 @@ part 'auth_dtos.g.dart';
part 'dto/check_phone_dto.dart'; part 'dto/check_phone_dto.dart';
part 'dto/register_dto.dart'; part 'dto/register_dto.dart';
part 'dto/verify_dto.dart';
part 'dto/login_dto.dart';
part 'dto/resend_dto.dart';

File diff suppressed because it is too large Load Diff

View File

@ -61,105 +61,3 @@ Map<String, dynamic> _$$RegisterDataDtoImplToJson(
'otp_token': instance.otpToken, 'otp_token': instance.otpToken,
'expires_in': instance.expiresIn, 'expires_in': instance.expiresIn,
}; };
_$VerifyDtoImpl _$$VerifyDtoImplFromJson(Map<String, dynamic> json) =>
_$VerifyDtoImpl(
status: json['status'] as String?,
message: json['message'] as String?,
data: json['data'] == null
? null
: VerifyDataDto.fromJson(json['data'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$VerifyDtoImplToJson(_$VerifyDtoImpl instance) =>
<String, dynamic>{
'status': instance.status,
'message': instance.message,
'data': instance.data,
};
_$VerifyDataDtoImpl _$$VerifyDataDtoImplFromJson(Map<String, dynamic> json) =>
_$VerifyDataDtoImpl(
registrationToken: json['registration_token'] as String?,
);
Map<String, dynamic> _$$VerifyDataDtoImplToJson(_$VerifyDataDtoImpl instance) =>
<String, dynamic>{'registration_token': instance.registrationToken};
_$LoginDtoImpl _$$LoginDtoImplFromJson(Map<String, dynamic> json) =>
_$LoginDtoImpl(
status: json['status'] as String?,
message: json['message'] as String?,
data: json['data'] == null
? null
: LoginDataDto.fromJson(json['data'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$LoginDtoImplToJson(_$LoginDtoImpl instance) =>
<String, dynamic>{
'status': instance.status,
'message': instance.message,
'data': instance.data,
};
_$LoginDataDtoImpl _$$LoginDataDtoImplFromJson(Map<String, dynamic> json) =>
_$LoginDataDtoImpl(
accessToken: json['access_token'] as String?,
refreshToken: json['refresh_token'] as String?,
user: json['user'] == null
? null
: UserDto.fromJson(json['user'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$LoginDataDtoImplToJson(_$LoginDataDtoImpl instance) =>
<String, dynamic>{
'access_token': instance.accessToken,
'refresh_token': instance.refreshToken,
'user': instance.user,
};
_$UserDtoImpl _$$UserDtoImplFromJson(Map<String, dynamic> json) =>
_$UserDtoImpl(
id: json['id'] as String?,
name: json['name'] as String?,
phoneNumber: json['phone_number'] as String?,
birthDate: json['birth_date'] as String?,
);
Map<String, dynamic> _$$UserDtoImplToJson(_$UserDtoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'phone_number': instance.phoneNumber,
'birth_date': instance.birthDate,
};
_$ResendDtoImpl _$$ResendDtoImplFromJson(Map<String, dynamic> json) =>
_$ResendDtoImpl(
status: json['status'] as String?,
message: json['message'] as String?,
data: json['data'] == null
? null
: ResendDataDto.fromJson(json['data'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$ResendDtoImplToJson(_$ResendDtoImpl instance) =>
<String, dynamic>{
'status': instance.status,
'message': instance.message,
'data': instance.data,
};
_$ResendDataDtoImpl _$$ResendDataDtoImplFromJson(Map<String, dynamic> json) =>
_$ResendDataDtoImpl(
otpToken: json['otp_token'] as String?,
expiresIn: (json['expires_in'] as num?)?.toInt(),
nextResendIn: (json['next_resend_in'] as num?)?.toInt(),
);
Map<String, dynamic> _$$ResendDataDtoImplToJson(_$ResendDataDtoImpl instance) =>
<String, dynamic>{
'otp_token': instance.otpToken,
'expires_in': instance.expiresIn,
'next_resend_in': instance.nextResendIn,
};

View File

@ -96,155 +96,4 @@ class AuthRemoteDataProvider {
return DC.error(AuthFailure.serverError(e)); return DC.error(AuthFailure.serverError(e));
} }
} }
Future<DC<AuthFailure, VerifyDto>> verify({
required String registrationToken,
required String otpCode,
}) async {
try {
final response = await _apiClient.post(
ApiPath.verify,
data: {'registration_token': registrationToken, 'otp_code': otpCode},
);
if (response.data['success'] == false) {
if ((response.data['errors'] as List).isNotEmpty) {
if (response.data['errors'][0]['code'] == "900") {
return DC.error(
AuthFailure.dynamicErrorMessage('Kode OTP Tidak Sesuai'),
);
} else {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
} else {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
}
final dto = VerifyDto.fromJson(response.data['data']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('verify', name: _logName, error: e, stackTrace: s);
return DC.error(AuthFailure.serverError(e));
}
}
Future<DC<AuthFailure, LoginDto>> setPassword({
required String registrationToken,
required String password,
required String confirmPassword,
}) async {
try {
final response = await _apiClient.post(
ApiPath.setPassword,
data: {
'registration_token': registrationToken,
'password': password,
'confirm_password': confirmPassword,
},
);
if (response.data['success'] == false) {
if ((response.data['errors'] as List).isNotEmpty) {
if (response.data['errors'][0]['code'] == "900") {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Invalid Registration, Lakukan kembali dari awal',
),
);
} else {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
} else {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
}
final dto = LoginDto.fromJson(response.data['data']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('setPassword', name: _logName, error: e, stackTrace: s);
return DC.error(AuthFailure.serverError(e));
}
}
Future<DC<AuthFailure, LoginDto>> login({
required String phoneNumber,
required String password,
}) async {
try {
final response = await _apiClient.post(
ApiPath.login,
data: {'phone_number': phoneNumber, 'password': password},
);
if (response.data['success'] == false) {
if ((response.data['errors'] as List).isNotEmpty) {
if (response.data['errors'][0]['code'] == "900") {
return DC.error(
AuthFailure.dynamicErrorMessage('Kamu Belum Terdaftar'),
);
} else {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
} else {
return DC.error(
AuthFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
}
final dto = LoginDto.fromJson(response.data['data']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('login', name: _logName, error: e, stackTrace: s);
return DC.error(AuthFailure.serverError(e));
}
}
Future<DC<AuthFailure, ResendDto>> resend({
required String phoneNumber,
required String purpose, //login or registration
}) async {
try {
final response = await _apiClient.post(
ApiPath.resend,
data: {'phone_number': phoneNumber, 'purpose': purpose},
);
if (response.data['success'] == false) {
return DC.error(
AuthFailure.dynamicErrorMessage('Terjadi kesalahan coba lagi nanti'),
);
}
final dto = ResendDto.fromJson(response.data['data']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('resend', name: _logName, error: e, stackTrace: s);
return DC.error(AuthFailure.serverError(e));
}
}
} }

View File

@ -1,58 +0,0 @@
part of '../auth_dtos.dart';
@freezed
class LoginDto with _$LoginDto {
const factory LoginDto({
@JsonKey(name: 'status') String? status,
@JsonKey(name: 'message') String? message,
@JsonKey(name: 'data') LoginDataDto? data,
}) = _LoginDto;
factory LoginDto.fromJson(Map<String, dynamic> json) =>
_$LoginDtoFromJson(json);
const LoginDto._();
/// mapping ke domain
Login toDomain() => Login(
status: status ?? '',
message: message ?? '',
accessToken: data?.accessToken ?? '',
refreshToken: data?.refreshToken ?? '',
user: data?.user?.toDomain() ?? User.empty(),
);
}
@freezed
class LoginDataDto with _$LoginDataDto {
const factory LoginDataDto({
@JsonKey(name: 'access_token') String? accessToken,
@JsonKey(name: 'refresh_token') String? refreshToken,
@JsonKey(name: 'user') UserDto? user,
}) = _LoginDataDto;
factory LoginDataDto.fromJson(Map<String, dynamic> json) =>
_$LoginDataDtoFromJson(json);
}
@freezed
class UserDto with _$UserDto {
const factory UserDto({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'phone_number') String? phoneNumber,
@JsonKey(name: 'birth_date') String? birthDate,
}) = _UserDto;
factory UserDto.fromJson(Map<String, dynamic> json) =>
_$UserDtoFromJson(json);
const UserDto._();
User toDomain() => User(
id: id ?? '',
name: name ?? '',
phoneNumber: phoneNumber ?? '',
birthDate: birthDate ?? '',
);
}

View File

@ -1,36 +0,0 @@
part of '../auth_dtos.dart';
@freezed
class ResendDto with _$ResendDto {
const factory ResendDto({
@JsonKey(name: 'status') String? status,
@JsonKey(name: 'message') String? message,
@JsonKey(name: 'data') ResendDataDto? data,
}) = _ResendDto;
factory ResendDto.fromJson(Map<String, dynamic> json) =>
_$ResendDtoFromJson(json);
const ResendDto._();
/// mapping ke domain
Resend toDomain() => Resend(
status: status ?? '',
message: message ?? '',
otpToken: data?.otpToken ?? '',
expiresIn: data?.expiresIn ?? 0,
nextResendIn: data?.nextResendIn ?? 0,
);
}
@freezed
class ResendDataDto with _$ResendDataDto {
const factory ResendDataDto({
@JsonKey(name: 'otp_token') String? otpToken,
@JsonKey(name: 'expires_in') int? expiresIn,
@JsonKey(name: 'next_resend_in') int? nextResendIn,
}) = _ResendDataDto;
factory ResendDataDto.fromJson(Map<String, dynamic> json) =>
_$ResendDataDtoFromJson(json);
}

View File

@ -1,32 +0,0 @@
part of '../auth_dtos.dart';
@freezed
class VerifyDto with _$VerifyDto {
const factory VerifyDto({
@JsonKey(name: 'status') String? status,
@JsonKey(name: 'message') String? message,
@JsonKey(name: 'data') VerifyDataDto? data,
}) = _VerifyDto;
factory VerifyDto.fromJson(Map<String, dynamic> json) =>
_$VerifyDtoFromJson(json);
const VerifyDto._(); // biar bisa bikin method
/// mapping ke domain
Verify toDomain() => Verify(
status: status ?? '',
message: message ?? '',
registrationToken: data?.registrationToken ?? '',
);
}
@freezed
class VerifyDataDto with _$VerifyDataDto {
const factory VerifyDataDto({
@JsonKey(name: 'registration_token') String? registrationToken,
}) = _VerifyDataDto;
factory VerifyDataDto.fromJson(Map<String, dynamic> json) =>
_$VerifyDataDtoFromJson(json);
}

View File

@ -57,105 +57,7 @@ class AuthRepository implements IAuthRepository {
return right(auth); return right(auth);
} catch (e, s) { } catch (e, s) {
log('registerError', name: _logName, error: e, stackTrace: s); log('checkPhoneError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError());
}
}
@override
Future<Either<AuthFailure, Verify>> verify({
required String registrationToken,
required String otpCode,
}) async {
try {
final result = await _remoteDataProvider.verify(
registrationToken: registrationToken,
otpCode: otpCode,
);
if (result.hasError) {
return left(result.error!);
}
final auth = result.data!.toDomain();
return right(auth);
} catch (e, s) {
log('verifyError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError());
}
}
@override
Future<Either<AuthFailure, Login>> setPassword({
required String registrationToken,
required String password,
required String confirmPassword,
}) async {
try {
final result = await _remoteDataProvider.setPassword(
registrationToken: registrationToken,
password: password,
confirmPassword: confirmPassword,
);
if (result.hasError) {
return left(result.error!);
}
final auth = result.data!.toDomain();
return right(auth);
} catch (e, s) {
log('setPasswordError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError());
}
}
@override
Future<Either<AuthFailure, Login>> login({
required String phoneNumber,
required String password,
}) async {
try {
final result = await _remoteDataProvider.login(
phoneNumber: phoneNumber,
password: password,
);
if (result.hasError) {
return left(result.error!);
}
final auth = result.data!.toDomain();
return right(auth);
} catch (e, s) {
log('loginError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError());
}
}
@override
Future<Either<AuthFailure, Resend>> resend({
required String phoneNumber,
required String purpose,
}) async {
try {
final result = await _remoteDataProvider.resend(
phoneNumber: phoneNumber,
purpose: purpose,
);
if (result.hasError) {
return left(result.error!);
}
final auth = result.data!.toDomain();
return right(auth);
} catch (e, s) {
log('resendError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError()); return left(const AuthFailure.unexpectedError());
} }
} }

View File

@ -13,16 +13,8 @@ import 'package:connectivity_plus/connectivity_plus.dart' as _i895;
import 'package:dio/dio.dart' as _i361; import 'package:dio/dio.dart' as _i361;
import 'package:enaklo/application/auth/check_phone_form/check_phone_form_bloc.dart' import 'package:enaklo/application/auth/check_phone_form/check_phone_form_bloc.dart'
as _i869; as _i869;
import 'package:enaklo/application/auth/login_form/login_form_bloc.dart'
as _i510;
import 'package:enaklo/application/auth/register_form/register_form_bloc.dart' import 'package:enaklo/application/auth/register_form/register_form_bloc.dart'
as _i260; as _i260;
import 'package:enaklo/application/auth/resend_form/resend_form_bloc.dart'
as _i627;
import 'package:enaklo/application/auth/set_password/set_password_form_bloc.dart'
as _i174;
import 'package:enaklo/application/auth/verify_form/verify_form_bloc.dart'
as _i521;
import 'package:enaklo/common/api/api_client.dart' as _i842; import 'package:enaklo/common/api/api_client.dart' as _i842;
import 'package:enaklo/common/di/di_auto_route.dart' as _i619; import 'package:enaklo/common/di/di_auto_route.dart' as _i619;
import 'package:enaklo/common/di/di_connectivity.dart' as _i644; import 'package:enaklo/common/di/di_connectivity.dart' as _i644;
@ -75,24 +67,12 @@ extension GetItInjectableX on _i174.GetIt {
gh.factory<_i995.IAuthRepository>( gh.factory<_i995.IAuthRepository>(
() => _i879.AuthRepository(gh<_i818.AuthRemoteDataProvider>()), () => _i879.AuthRepository(gh<_i818.AuthRemoteDataProvider>()),
); );
gh.factory<_i510.LoginFormBloc>(
() => _i510.LoginFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i869.CheckPhoneFormBloc>( gh.factory<_i869.CheckPhoneFormBloc>(
() => _i869.CheckPhoneFormBloc(gh<_i995.IAuthRepository>()), () => _i869.CheckPhoneFormBloc(gh<_i995.IAuthRepository>()),
); );
gh.factory<_i260.RegisterFormBloc>( gh.factory<_i260.RegisterFormBloc>(
() => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()), () => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()),
); );
gh.factory<_i521.VerifyFormBloc>(
() => _i521.VerifyFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i174.SetPasswordFormBloc>(
() => _i174.SetPasswordFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i627.ResendFormBloc>(
() => _i627.ResendFormBloc(gh<_i995.IAuthRepository>()),
);
return this; return this;
} }
} }