Compare commits

..
23 Commits
Author SHA1 Message Date
aefril 2560c1890b Merge pull request 'dev' (#2) from dev into main
Reviewed-on: #2
2026-01-18 16:03:39 +00:00
Efril 7887704a5c update service type 2026-01-16 16:07:56 +07:00
Efril 4c12244d3c checkout page 2026-01-16 15:53:06 +07:00
Efril f4f775b9ed menu detail page 2026-01-16 14:41:09 +07:00
Efril 44d48d41d4 menu page 2026-01-16 13:27:09 +07:00
efrilm 82e1f93cce update 2026-01-16 12:26:06 +07:00
efrilm 1ce980a87b mystery box 2025-10-12 13:27:39 +07:00
aefril a09fda0585 Merge pull request 'dev' (#1) from dev into main
Reviewed-on: #1
2025-09-18 08:07:46 +00:00
efrilm 909c312af0 Ferish Wheel and Music 2025-09-18 14:53:39 +07:00
efrilm 73918430b2 Customer Point 2025-09-18 13:01:31 +07:00
efrilm a5d66c63b7 State Is Authenticated 2025-09-18 12:25:48 +07:00
efrilm 3c596461c6 Game Prize and Logout 2025-09-18 10:39:54 +07:00
efrilm 006486bc2a Auth 2025-09-18 09:31:42 +07:00
efrilm 2e00207343 Set Password 2025-09-18 09:17:25 +07:00
efrilm 8e35582f93 Otp Page 2025-09-18 09:03:50 +07:00
efrilm 0ea1a6fa56 Register Impl 2025-09-18 08:48:36 +07:00
efrilm cee78e179b login impl 2025-09-18 08:17:24 +07:00
efrilm 1ca1a45126 check phone impl 2025-09-18 08:01:49 +07:00
efrilm 214dfe3262 Update 2025-09-18 07:28:01 +07:00
efrilm 3b26b19b25 Resend 2025-09-18 07:16:56 +07:00
efrilm b20854f329 Login Repo 2025-09-18 07:04:06 +07:00
efrilm 1a0c0cf49b Set Password Repo 2025-09-18 06:57:08 +07:00
efrilm c40f96fc88 verify repo 2025-09-18 06:38:50 +07:00
156 changed files with 18356 additions and 1899 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

+49
View File
@@ -0,0 +1,49 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../domain/auth/auth.dart';
part 'auth_event.dart';
part 'auth_state.dart';
part 'auth_bloc.freezed.dart';
@injectable
class AuthBloc extends Bloc<AuthEvent, AuthState> {
final IAuthRepository _repository;
AuthBloc(this._repository) : super(AuthState.initial()) {
on<AuthEvent>(_onAuthEvent);
}
Future<void> _onAuthEvent(AuthEvent event, Emitter<AuthState> emit) {
return event.map(
fetchCurrentUser: (e) async {
emit(state.copyWith(failureOption: none()));
final token = await _repository.hasToken();
final failureOrAuth = await _repository.currentUser();
failureOrAuth.fold(
(f) => emit(
state.copyWith(
failureOption: optionOf(f),
status: token
? AuthStatus.authenticated()
: AuthStatus.unauthenticated(),
),
),
(user) => emit(
state.copyWith(
user: user,
status: token
? AuthStatus.authenticated()
: AuthStatus.unauthenticated(),
),
),
);
},
);
}
}
+806
View File
@@ -0,0 +1,806 @@
// 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 'auth_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 _$AuthEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchCurrentUser,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchCurrentUser,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchCurrentUser,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchCurrentUser value) fetchCurrentUser,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchCurrentUser value)? fetchCurrentUser,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchCurrentUser value)? fetchCurrentUser,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AuthEventCopyWith<$Res> {
factory $AuthEventCopyWith(AuthEvent value, $Res Function(AuthEvent) then) =
_$AuthEventCopyWithImpl<$Res, AuthEvent>;
}
/// @nodoc
class _$AuthEventCopyWithImpl<$Res, $Val extends AuthEvent>
implements $AuthEventCopyWith<$Res> {
_$AuthEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of AuthEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchCurrentUserImplCopyWith<$Res> {
factory _$$FetchCurrentUserImplCopyWith(
_$FetchCurrentUserImpl value,
$Res Function(_$FetchCurrentUserImpl) then,
) = __$$FetchCurrentUserImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchCurrentUserImplCopyWithImpl<$Res>
extends _$AuthEventCopyWithImpl<$Res, _$FetchCurrentUserImpl>
implements _$$FetchCurrentUserImplCopyWith<$Res> {
__$$FetchCurrentUserImplCopyWithImpl(
_$FetchCurrentUserImpl _value,
$Res Function(_$FetchCurrentUserImpl) _then,
) : super(_value, _then);
/// Create a copy of AuthEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchCurrentUserImpl implements _FetchCurrentUser {
const _$FetchCurrentUserImpl();
@override
String toString() {
return 'AuthEvent.fetchCurrentUser()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchCurrentUserImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchCurrentUser,
}) {
return fetchCurrentUser();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchCurrentUser,
}) {
return fetchCurrentUser?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchCurrentUser,
required TResult orElse(),
}) {
if (fetchCurrentUser != null) {
return fetchCurrentUser();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchCurrentUser value) fetchCurrentUser,
}) {
return fetchCurrentUser(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchCurrentUser value)? fetchCurrentUser,
}) {
return fetchCurrentUser?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchCurrentUser value)? fetchCurrentUser,
required TResult orElse(),
}) {
if (fetchCurrentUser != null) {
return fetchCurrentUser(this);
}
return orElse();
}
}
abstract class _FetchCurrentUser implements AuthEvent {
const factory _FetchCurrentUser() = _$FetchCurrentUserImpl;
}
/// @nodoc
mixin _$AuthState {
User get user => throw _privateConstructorUsedError;
AuthStatus get status => throw _privateConstructorUsedError;
Option<AuthFailure> get failureOption => throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of AuthState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$AuthStateCopyWith<AuthState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AuthStateCopyWith<$Res> {
factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) =
_$AuthStateCopyWithImpl<$Res, AuthState>;
@useResult
$Res call({
User user,
AuthStatus status,
Option<AuthFailure> failureOption,
bool isFetching,
});
$UserCopyWith<$Res> get user;
$AuthStatusCopyWith<$Res> get status;
}
/// @nodoc
class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState>
implements $AuthStateCopyWith<$Res> {
_$AuthStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of AuthState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? user = null,
Object? status = null,
Object? failureOption = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
user: null == user
? _value.user
: user // ignore: cast_nullable_to_non_nullable
as User,
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as AuthStatus,
failureOption: null == failureOption
? _value.failureOption
: failureOption // ignore: cast_nullable_to_non_nullable
as Option<AuthFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of AuthState
/// 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);
});
}
/// Create a copy of AuthState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$AuthStatusCopyWith<$Res> get status {
return $AuthStatusCopyWith<$Res>(_value.status, (value) {
return _then(_value.copyWith(status: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$AuthStateImplCopyWith<$Res>
implements $AuthStateCopyWith<$Res> {
factory _$$AuthStateImplCopyWith(
_$AuthStateImpl value,
$Res Function(_$AuthStateImpl) then,
) = __$$AuthStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
User user,
AuthStatus status,
Option<AuthFailure> failureOption,
bool isFetching,
});
@override
$UserCopyWith<$Res> get user;
@override
$AuthStatusCopyWith<$Res> get status;
}
/// @nodoc
class __$$AuthStateImplCopyWithImpl<$Res>
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateImpl>
implements _$$AuthStateImplCopyWith<$Res> {
__$$AuthStateImplCopyWithImpl(
_$AuthStateImpl _value,
$Res Function(_$AuthStateImpl) _then,
) : super(_value, _then);
/// Create a copy of AuthState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? user = null,
Object? status = null,
Object? failureOption = null,
Object? isFetching = null,
}) {
return _then(
_$AuthStateImpl(
user: null == user
? _value.user
: user // ignore: cast_nullable_to_non_nullable
as User,
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as AuthStatus,
failureOption: null == failureOption
? _value.failureOption
: failureOption // ignore: cast_nullable_to_non_nullable
as Option<AuthFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$AuthStateImpl extends _AuthState {
const _$AuthStateImpl({
required this.user,
this.status = const AuthStatus.initial(),
required this.failureOption,
this.isFetching = false,
}) : super._();
@override
final User user;
@override
@JsonKey()
final AuthStatus status;
@override
final Option<AuthFailure> failureOption;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'AuthState(user: $user, status: $status, failureOption: $failureOption, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$AuthStateImpl &&
(identical(other.user, user) || other.user == user) &&
(identical(other.status, status) || other.status == status) &&
(identical(other.failureOption, failureOption) ||
other.failureOption == failureOption) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode =>
Object.hash(runtimeType, user, status, failureOption, isFetching);
/// Create a copy of AuthState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$AuthStateImplCopyWith<_$AuthStateImpl> get copyWith =>
__$$AuthStateImplCopyWithImpl<_$AuthStateImpl>(this, _$identity);
}
abstract class _AuthState extends AuthState {
const factory _AuthState({
required final User user,
final AuthStatus status,
required final Option<AuthFailure> failureOption,
final bool isFetching,
}) = _$AuthStateImpl;
const _AuthState._() : super._();
@override
User get user;
@override
AuthStatus get status;
@override
Option<AuthFailure> get failureOption;
@override
bool get isFetching;
/// Create a copy of AuthState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$AuthStateImplCopyWith<_$AuthStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$AuthStatus {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() authenticated,
required TResult Function() unauthenticated,
required TResult Function() initial,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? authenticated,
TResult? Function()? unauthenticated,
TResult? Function()? initial,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? authenticated,
TResult Function()? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Authenticated value) authenticated,
required TResult Function(_Unauthenticated value) unauthenticated,
required TResult Function(_Initial value) initial,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Authenticated value)? authenticated,
TResult? Function(_Unauthenticated value)? unauthenticated,
TResult? Function(_Initial value)? initial,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Authenticated value)? authenticated,
TResult Function(_Unauthenticated value)? unauthenticated,
TResult Function(_Initial value)? initial,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AuthStatusCopyWith<$Res> {
factory $AuthStatusCopyWith(
AuthStatus value,
$Res Function(AuthStatus) then,
) = _$AuthStatusCopyWithImpl<$Res, AuthStatus>;
}
/// @nodoc
class _$AuthStatusCopyWithImpl<$Res, $Val extends AuthStatus>
implements $AuthStatusCopyWith<$Res> {
_$AuthStatusCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of AuthStatus
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$AuthenticatedImplCopyWith<$Res> {
factory _$$AuthenticatedImplCopyWith(
_$AuthenticatedImpl value,
$Res Function(_$AuthenticatedImpl) then,
) = __$$AuthenticatedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$AuthenticatedImplCopyWithImpl<$Res>
extends _$AuthStatusCopyWithImpl<$Res, _$AuthenticatedImpl>
implements _$$AuthenticatedImplCopyWith<$Res> {
__$$AuthenticatedImplCopyWithImpl(
_$AuthenticatedImpl _value,
$Res Function(_$AuthenticatedImpl) _then,
) : super(_value, _then);
/// Create a copy of AuthStatus
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$AuthenticatedImpl implements _Authenticated {
const _$AuthenticatedImpl();
@override
String toString() {
return 'AuthStatus.authenticated()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$AuthenticatedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() authenticated,
required TResult Function() unauthenticated,
required TResult Function() initial,
}) {
return authenticated();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? authenticated,
TResult? Function()? unauthenticated,
TResult? Function()? initial,
}) {
return authenticated?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? authenticated,
TResult Function()? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) {
if (authenticated != null) {
return authenticated();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Authenticated value) authenticated,
required TResult Function(_Unauthenticated value) unauthenticated,
required TResult Function(_Initial value) initial,
}) {
return authenticated(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Authenticated value)? authenticated,
TResult? Function(_Unauthenticated value)? unauthenticated,
TResult? Function(_Initial value)? initial,
}) {
return authenticated?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Authenticated value)? authenticated,
TResult Function(_Unauthenticated value)? unauthenticated,
TResult Function(_Initial value)? initial,
required TResult orElse(),
}) {
if (authenticated != null) {
return authenticated(this);
}
return orElse();
}
}
abstract class _Authenticated implements AuthStatus {
const factory _Authenticated() = _$AuthenticatedImpl;
}
/// @nodoc
abstract class _$$UnauthenticatedImplCopyWith<$Res> {
factory _$$UnauthenticatedImplCopyWith(
_$UnauthenticatedImpl value,
$Res Function(_$UnauthenticatedImpl) then,
) = __$$UnauthenticatedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$UnauthenticatedImplCopyWithImpl<$Res>
extends _$AuthStatusCopyWithImpl<$Res, _$UnauthenticatedImpl>
implements _$$UnauthenticatedImplCopyWith<$Res> {
__$$UnauthenticatedImplCopyWithImpl(
_$UnauthenticatedImpl _value,
$Res Function(_$UnauthenticatedImpl) _then,
) : super(_value, _then);
/// Create a copy of AuthStatus
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$UnauthenticatedImpl implements _Unauthenticated {
const _$UnauthenticatedImpl();
@override
String toString() {
return 'AuthStatus.unauthenticated()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$UnauthenticatedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() authenticated,
required TResult Function() unauthenticated,
required TResult Function() initial,
}) {
return unauthenticated();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? authenticated,
TResult? Function()? unauthenticated,
TResult? Function()? initial,
}) {
return unauthenticated?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? authenticated,
TResult Function()? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) {
if (unauthenticated != null) {
return unauthenticated();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Authenticated value) authenticated,
required TResult Function(_Unauthenticated value) unauthenticated,
required TResult Function(_Initial value) initial,
}) {
return unauthenticated(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Authenticated value)? authenticated,
TResult? Function(_Unauthenticated value)? unauthenticated,
TResult? Function(_Initial value)? initial,
}) {
return unauthenticated?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Authenticated value)? authenticated,
TResult Function(_Unauthenticated value)? unauthenticated,
TResult Function(_Initial value)? initial,
required TResult orElse(),
}) {
if (unauthenticated != null) {
return unauthenticated(this);
}
return orElse();
}
}
abstract class _Unauthenticated implements AuthStatus {
const factory _Unauthenticated() = _$UnauthenticatedImpl;
}
/// @nodoc
abstract class _$$InitialImplCopyWith<$Res> {
factory _$$InitialImplCopyWith(
_$InitialImpl value,
$Res Function(_$InitialImpl) then,
) = __$$InitialImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$InitialImplCopyWithImpl<$Res>
extends _$AuthStatusCopyWithImpl<$Res, _$InitialImpl>
implements _$$InitialImplCopyWith<$Res> {
__$$InitialImplCopyWithImpl(
_$InitialImpl _value,
$Res Function(_$InitialImpl) _then,
) : super(_value, _then);
/// Create a copy of AuthStatus
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$InitialImpl implements _Initial {
const _$InitialImpl();
@override
String toString() {
return 'AuthStatus.initial()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$InitialImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() authenticated,
required TResult Function() unauthenticated,
required TResult Function() initial,
}) {
return initial();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? authenticated,
TResult? Function()? unauthenticated,
TResult? Function()? initial,
}) {
return initial?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? authenticated,
TResult Function()? unauthenticated,
TResult Function()? initial,
required TResult orElse(),
}) {
if (initial != null) {
return initial();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Authenticated value) authenticated,
required TResult Function(_Unauthenticated value) unauthenticated,
required TResult Function(_Initial value) initial,
}) {
return initial(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Authenticated value)? authenticated,
TResult? Function(_Unauthenticated value)? unauthenticated,
TResult? Function(_Initial value)? initial,
}) {
return initial?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Authenticated value)? authenticated,
TResult Function(_Unauthenticated value)? unauthenticated,
TResult Function(_Initial value)? initial,
required TResult orElse(),
}) {
if (initial != null) {
return initial(this);
}
return orElse();
}
}
abstract class _Initial implements AuthStatus {
const factory _Initial() = _$InitialImpl;
}
+6
View File
@@ -0,0 +1,6 @@
part of 'auth_bloc.dart';
@freezed
class AuthEvent with _$AuthEvent {
const factory AuthEvent.fetchCurrentUser() = _FetchCurrentUser;
}
+26
View File
@@ -0,0 +1,26 @@
part of 'auth_bloc.dart';
@freezed
class AuthState with _$AuthState {
const AuthState._();
const factory AuthState({
required User user,
@Default(AuthStatus.initial()) AuthStatus status,
required Option<AuthFailure> failureOption,
@Default(false) bool isFetching,
}) = _AuthState;
factory AuthState.initial() =>
AuthState(user: User.empty(), failureOption: none());
bool get isAuthenticated => status == const AuthStatus.authenticated();
bool get isInitial => status == const AuthStatus.initial();
}
@freezed
sealed class AuthStatus with _$AuthStatus {
const factory AuthStatus.authenticated() = _Authenticated;
const factory AuthStatus.unauthenticated() = _Unauthenticated;
const factory AuthStatus.initial() = _Initial;
}
@@ -3,6 +3,7 @@ import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../common/function/app_function.dart';
import '../../../domain/auth/auth.dart';
part 'check_phone_form_event.dart';
@@ -40,7 +41,7 @@ class CheckPhoneFormBloc
if (phoneNumberValid) {
failureOrCheckPhone = await _repository.checkPhone(
phoneNumber: state.phoneNumber,
phoneNumber: getNormalizePhone(state.phoneNumber),
);
emit(
state.copyWith(
@@ -0,0 +1,67 @@
import 'dart:developer';
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;
log(
'phoneNumberValid: $phoneNumberValid, passwordValid: $passwordValid, phoneNumber: ${state.phoneNumber}, password: ${state.password}',
);
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));
},
);
}
}
@@ -0,0 +1,740 @@
// 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;
}
@@ -0,0 +1,10 @@
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;
}
@@ -0,0 +1,18 @@
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(),
);
}
@@ -0,0 +1,37 @@
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 'logout_form_event.dart';
part 'logout_form_state.dart';
part 'logout_form_bloc.freezed.dart';
@injectable
class LogoutFormBloc extends Bloc<LogoutFormEvent, LogoutFormState> {
final IAuthRepository _repository;
LogoutFormBloc(this._repository) : super(LogoutFormState.initial()) {
on<LogoutFormEvent>(_onLogoutFormEvent);
}
Future<void> _onLogoutFormEvent(
LogoutFormEvent event,
Emitter<LogoutFormState> emit,
) {
return event.map(
submitted: (e) async {
emit(state.copyWith(isSubmitting: true, failureOrAuthOption: none()));
final failureOrAuth = await _repository.logout();
emit(
state.copyWith(
isSubmitting: false,
failureOrAuthOption: optionOf(failureOrAuth),
),
);
},
);
}
}
@@ -0,0 +1,335 @@
// 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 'logout_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 _$LogoutFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LogoutFormEventCopyWith<$Res> {
factory $LogoutFormEventCopyWith(
LogoutFormEvent value,
$Res Function(LogoutFormEvent) then,
) = _$LogoutFormEventCopyWithImpl<$Res, LogoutFormEvent>;
}
/// @nodoc
class _$LogoutFormEventCopyWithImpl<$Res, $Val extends LogoutFormEvent>
implements $LogoutFormEventCopyWith<$Res> {
_$LogoutFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of LogoutFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$LogoutFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of LogoutFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'LogoutFormEvent.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() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements LogoutFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$LogoutFormState {
Option<Either<AuthFailure, Unit>> get failureOrAuthOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
/// Create a copy of LogoutFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$LogoutFormStateCopyWith<LogoutFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $LogoutFormStateCopyWith<$Res> {
factory $LogoutFormStateCopyWith(
LogoutFormState value,
$Res Function(LogoutFormState) then,
) = _$LogoutFormStateCopyWithImpl<$Res, LogoutFormState>;
@useResult
$Res call({
Option<Either<AuthFailure, Unit>> failureOrAuthOption,
bool isSubmitting,
});
}
/// @nodoc
class _$LogoutFormStateCopyWithImpl<$Res, $Val extends LogoutFormState>
implements $LogoutFormStateCopyWith<$Res> {
_$LogoutFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of LogoutFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failureOrAuthOption = null, Object? isSubmitting = null}) {
return _then(
_value.copyWith(
failureOrAuthOption: null == failureOrAuthOption
? _value.failureOrAuthOption
: failureOrAuthOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Unit>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$LogoutFormStateImplCopyWith<$Res>
implements $LogoutFormStateCopyWith<$Res> {
factory _$$LogoutFormStateImplCopyWith(
_$LogoutFormStateImpl value,
$Res Function(_$LogoutFormStateImpl) then,
) = __$$LogoutFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
Option<Either<AuthFailure, Unit>> failureOrAuthOption,
bool isSubmitting,
});
}
/// @nodoc
class __$$LogoutFormStateImplCopyWithImpl<$Res>
extends _$LogoutFormStateCopyWithImpl<$Res, _$LogoutFormStateImpl>
implements _$$LogoutFormStateImplCopyWith<$Res> {
__$$LogoutFormStateImplCopyWithImpl(
_$LogoutFormStateImpl _value,
$Res Function(_$LogoutFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of LogoutFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failureOrAuthOption = null, Object? isSubmitting = null}) {
return _then(
_$LogoutFormStateImpl(
failureOrAuthOption: null == failureOrAuthOption
? _value.failureOrAuthOption
: failureOrAuthOption // ignore: cast_nullable_to_non_nullable
as Option<Either<AuthFailure, Unit>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$LogoutFormStateImpl implements _LogoutFormState {
const _$LogoutFormStateImpl({
required this.failureOrAuthOption,
this.isSubmitting = false,
});
@override
final Option<Either<AuthFailure, Unit>> failureOrAuthOption;
@override
@JsonKey()
final bool isSubmitting;
@override
String toString() {
return 'LogoutFormState(failureOrAuthOption: $failureOrAuthOption, isSubmitting: $isSubmitting)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LogoutFormStateImpl &&
(identical(other.failureOrAuthOption, failureOrAuthOption) ||
other.failureOrAuthOption == failureOrAuthOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting));
}
@override
int get hashCode =>
Object.hash(runtimeType, failureOrAuthOption, isSubmitting);
/// Create a copy of LogoutFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$LogoutFormStateImplCopyWith<_$LogoutFormStateImpl> get copyWith =>
__$$LogoutFormStateImplCopyWithImpl<_$LogoutFormStateImpl>(
this,
_$identity,
);
}
abstract class _LogoutFormState implements LogoutFormState {
const factory _LogoutFormState({
required final Option<Either<AuthFailure, Unit>> failureOrAuthOption,
final bool isSubmitting,
}) = _$LogoutFormStateImpl;
@override
Option<Either<AuthFailure, Unit>> get failureOrAuthOption;
@override
bool get isSubmitting;
/// Create a copy of LogoutFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$LogoutFormStateImplCopyWith<_$LogoutFormStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'logout_form_bloc.dart';
@freezed
class LogoutFormEvent with _$LogoutFormEvent {
const factory LogoutFormEvent.submitted() = _Submitted;
}
@@ -0,0 +1,12 @@
part of 'logout_form_bloc.dart';
@freezed
class LogoutFormState with _$LogoutFormState {
const factory LogoutFormState({
required Option<Either<AuthFailure, Unit>> failureOrAuthOption,
@Default(false) bool isSubmitting,
}) = _LogoutFormState;
factory LogoutFormState.initial() =>
LogoutFormState(failureOrAuthOption: none(), isSubmitting: false);
}
@@ -0,0 +1,59 @@
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));
},
);
}
}
@@ -0,0 +1,738 @@
// 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;
}
@@ -0,0 +1,10 @@
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;
}
@@ -0,0 +1,18 @@
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(),
);
}
@@ -0,0 +1,81 @@
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));
},
);
}
}
@@ -0,0 +1,980 @@
// 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;
}
@@ -0,0 +1,14 @@
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;
}
@@ -0,0 +1,20 @@
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(),
);
}
@@ -0,0 +1,58 @@
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));
},
);
}
}
@@ -0,0 +1,750 @@
// 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;
}
@@ -0,0 +1,11 @@
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;
}
@@ -0,0 +1,18 @@
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(),
);
}
@@ -0,0 +1,42 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/customer/customer.dart';
part 'customer_point_loader_event.dart';
part 'customer_point_loader_state.dart';
part 'customer_point_loader_bloc.freezed.dart';
@injectable
class CustomerPointLoaderBloc
extends Bloc<CustomerPointLoaderEvent, CustomerPointLoaderState> {
final ICustomerRepository _repository;
CustomerPointLoaderBloc(this._repository)
: super(CustomerPointLoaderState.initial()) {
on<CustomerPointLoaderEvent>(_onCustomerPointLoaderEvent);
}
Future<void> _onCustomerPointLoaderEvent(
CustomerPointLoaderEvent event,
Emitter<CustomerPointLoaderState> emit,
) {
return event.map(
fetched: (e) async {
emit(
state.copyWith(isFetching: true, failureOptionCustomerPoint: none()),
);
final result = await _repository.getPoints();
var data = result.fold(
(f) => state.copyWith(failureOptionCustomerPoint: optionOf(f)),
(customerPoint) => state.copyWith(customerPoint: customerPoint),
);
emit(data.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,391 @@
// 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 'customer_point_loader_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 _$CustomerPointLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CustomerPointLoaderEventCopyWith<$Res> {
factory $CustomerPointLoaderEventCopyWith(
CustomerPointLoaderEvent value,
$Res Function(CustomerPointLoaderEvent) then,
) = _$CustomerPointLoaderEventCopyWithImpl<$Res, CustomerPointLoaderEvent>;
}
/// @nodoc
class _$CustomerPointLoaderEventCopyWithImpl<
$Res,
$Val extends CustomerPointLoaderEvent
>
implements $CustomerPointLoaderEventCopyWith<$Res> {
_$CustomerPointLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CustomerPointLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
_$FetchedImpl value,
$Res Function(_$FetchedImpl) then,
) = __$$FetchedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedImplCopyWithImpl<$Res>
extends _$CustomerPointLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
implements _$$FetchedImplCopyWith<$Res> {
__$$FetchedImplCopyWithImpl(
_$FetchedImpl _value,
$Res Function(_$FetchedImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerPointLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl();
@override
String toString() {
return 'CustomerPointLoaderEvent.fetched()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({required TResult Function() fetched}) {
return fetched();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? fetched}) {
return fetched?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
}) {
return fetched(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
}) {
return fetched?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(this);
}
return orElse();
}
}
abstract class _Fetched implements CustomerPointLoaderEvent {
const factory _Fetched() = _$FetchedImpl;
}
/// @nodoc
mixin _$CustomerPointLoaderState {
CustomerPoint get customerPoint => throw _privateConstructorUsedError;
Option<CustomerFailure> get failureOptionCustomerPoint =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of CustomerPointLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$CustomerPointLoaderStateCopyWith<CustomerPointLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CustomerPointLoaderStateCopyWith<$Res> {
factory $CustomerPointLoaderStateCopyWith(
CustomerPointLoaderState value,
$Res Function(CustomerPointLoaderState) then,
) = _$CustomerPointLoaderStateCopyWithImpl<$Res, CustomerPointLoaderState>;
@useResult
$Res call({
CustomerPoint customerPoint,
Option<CustomerFailure> failureOptionCustomerPoint,
bool isFetching,
});
$CustomerPointCopyWith<$Res> get customerPoint;
}
/// @nodoc
class _$CustomerPointLoaderStateCopyWithImpl<
$Res,
$Val extends CustomerPointLoaderState
>
implements $CustomerPointLoaderStateCopyWith<$Res> {
_$CustomerPointLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CustomerPointLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? customerPoint = null,
Object? failureOptionCustomerPoint = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
customerPoint: null == customerPoint
? _value.customerPoint
: customerPoint // ignore: cast_nullable_to_non_nullable
as CustomerPoint,
failureOptionCustomerPoint: null == failureOptionCustomerPoint
? _value.failureOptionCustomerPoint
: failureOptionCustomerPoint // ignore: cast_nullable_to_non_nullable
as Option<CustomerFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of CustomerPointLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$CustomerPointCopyWith<$Res> get customerPoint {
return $CustomerPointCopyWith<$Res>(_value.customerPoint, (value) {
return _then(_value.copyWith(customerPoint: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$CustomerPointLoaderStateImplCopyWith<$Res>
implements $CustomerPointLoaderStateCopyWith<$Res> {
factory _$$CustomerPointLoaderStateImplCopyWith(
_$CustomerPointLoaderStateImpl value,
$Res Function(_$CustomerPointLoaderStateImpl) then,
) = __$$CustomerPointLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
CustomerPoint customerPoint,
Option<CustomerFailure> failureOptionCustomerPoint,
bool isFetching,
});
@override
$CustomerPointCopyWith<$Res> get customerPoint;
}
/// @nodoc
class __$$CustomerPointLoaderStateImplCopyWithImpl<$Res>
extends
_$CustomerPointLoaderStateCopyWithImpl<
$Res,
_$CustomerPointLoaderStateImpl
>
implements _$$CustomerPointLoaderStateImplCopyWith<$Res> {
__$$CustomerPointLoaderStateImplCopyWithImpl(
_$CustomerPointLoaderStateImpl _value,
$Res Function(_$CustomerPointLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerPointLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? customerPoint = null,
Object? failureOptionCustomerPoint = null,
Object? isFetching = null,
}) {
return _then(
_$CustomerPointLoaderStateImpl(
customerPoint: null == customerPoint
? _value.customerPoint
: customerPoint // ignore: cast_nullable_to_non_nullable
as CustomerPoint,
failureOptionCustomerPoint: null == failureOptionCustomerPoint
? _value.failureOptionCustomerPoint
: failureOptionCustomerPoint // ignore: cast_nullable_to_non_nullable
as Option<CustomerFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$CustomerPointLoaderStateImpl implements _CustomerPointLoaderState {
const _$CustomerPointLoaderStateImpl({
required this.customerPoint,
required this.failureOptionCustomerPoint,
this.isFetching = false,
});
@override
final CustomerPoint customerPoint;
@override
final Option<CustomerFailure> failureOptionCustomerPoint;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'CustomerPointLoaderState(customerPoint: $customerPoint, failureOptionCustomerPoint: $failureOptionCustomerPoint, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CustomerPointLoaderStateImpl &&
(identical(other.customerPoint, customerPoint) ||
other.customerPoint == customerPoint) &&
(identical(
other.failureOptionCustomerPoint,
failureOptionCustomerPoint,
) ||
other.failureOptionCustomerPoint ==
failureOptionCustomerPoint) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode => Object.hash(
runtimeType,
customerPoint,
failureOptionCustomerPoint,
isFetching,
);
/// Create a copy of CustomerPointLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CustomerPointLoaderStateImplCopyWith<_$CustomerPointLoaderStateImpl>
get copyWith =>
__$$CustomerPointLoaderStateImplCopyWithImpl<
_$CustomerPointLoaderStateImpl
>(this, _$identity);
}
abstract class _CustomerPointLoaderState implements CustomerPointLoaderState {
const factory _CustomerPointLoaderState({
required final CustomerPoint customerPoint,
required final Option<CustomerFailure> failureOptionCustomerPoint,
final bool isFetching,
}) = _$CustomerPointLoaderStateImpl;
@override
CustomerPoint get customerPoint;
@override
Option<CustomerFailure> get failureOptionCustomerPoint;
@override
bool get isFetching;
/// Create a copy of CustomerPointLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CustomerPointLoaderStateImplCopyWith<_$CustomerPointLoaderStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'customer_point_loader_bloc.dart';
@freezed
class CustomerPointLoaderEvent with _$CustomerPointLoaderEvent {
const factory CustomerPointLoaderEvent.fetched() = _Fetched;
}
@@ -0,0 +1,15 @@
part of 'customer_point_loader_bloc.dart';
@freezed
class CustomerPointLoaderState with _$CustomerPointLoaderState {
const factory CustomerPointLoaderState({
required CustomerPoint customerPoint,
required Option<CustomerFailure> failureOptionCustomerPoint,
@Default(false) bool isFetching,
}) = _CustomerPointLoaderState;
factory CustomerPointLoaderState.initial() => CustomerPointLoaderState(
customerPoint: CustomerPoint.empty(),
failureOptionCustomerPoint: none(),
);
}
@@ -0,0 +1,42 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/game/game.dart';
part 'ferris_wheel_loader_event.dart';
part 'ferris_wheel_loader_state.dart';
part 'ferris_wheel_loader_bloc.freezed.dart';
@injectable
class FerrisWheelLoaderBloc
extends Bloc<FerrisWheelLoaderEvent, FerrisWheelLoaderState> {
final IGameRepository _repository;
FerrisWheelLoaderBloc(this._repository)
: super(FerrisWheelLoaderState.initial()) {
on<FerrisWheelLoaderEvent>(_onFerrisWheelLoaderEvent);
}
Future<void> _onFerrisWheelLoaderEvent(
FerrisWheelLoaderEvent event,
Emitter<FerrisWheelLoaderState> emit,
) {
return event.map(
fetched: (e) async {
emit(
state.copyWith(isFetching: true, failureOptionFerrisWheel: none()),
);
final result = await _repository.ferrisWheel();
var data = result.fold(
(f) => state.copyWith(failureOptionFerrisWheel: optionOf(f)),
(ferrisWheel) => state.copyWith(ferrisWheel: ferrisWheel),
);
emit(data.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,388 @@
// 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 'ferris_wheel_loader_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 _$FerrisWheelLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $FerrisWheelLoaderEventCopyWith<$Res> {
factory $FerrisWheelLoaderEventCopyWith(
FerrisWheelLoaderEvent value,
$Res Function(FerrisWheelLoaderEvent) then,
) = _$FerrisWheelLoaderEventCopyWithImpl<$Res, FerrisWheelLoaderEvent>;
}
/// @nodoc
class _$FerrisWheelLoaderEventCopyWithImpl<
$Res,
$Val extends FerrisWheelLoaderEvent
>
implements $FerrisWheelLoaderEventCopyWith<$Res> {
_$FerrisWheelLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of FerrisWheelLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
_$FetchedImpl value,
$Res Function(_$FetchedImpl) then,
) = __$$FetchedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedImplCopyWithImpl<$Res>
extends _$FerrisWheelLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
implements _$$FetchedImplCopyWith<$Res> {
__$$FetchedImplCopyWithImpl(
_$FetchedImpl _value,
$Res Function(_$FetchedImpl) _then,
) : super(_value, _then);
/// Create a copy of FerrisWheelLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl();
@override
String toString() {
return 'FerrisWheelLoaderEvent.fetched()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({required TResult Function() fetched}) {
return fetched();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? fetched}) {
return fetched?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Fetched value) fetched,
}) {
return fetched(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Fetched value)? fetched,
}) {
return fetched?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(this);
}
return orElse();
}
}
abstract class _Fetched implements FerrisWheelLoaderEvent {
const factory _Fetched() = _$FetchedImpl;
}
/// @nodoc
mixin _$FerrisWheelLoaderState {
Game get ferrisWheel => throw _privateConstructorUsedError;
Option<GameFailure> get failureOptionFerrisWheel =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of FerrisWheelLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$FerrisWheelLoaderStateCopyWith<FerrisWheelLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $FerrisWheelLoaderStateCopyWith<$Res> {
factory $FerrisWheelLoaderStateCopyWith(
FerrisWheelLoaderState value,
$Res Function(FerrisWheelLoaderState) then,
) = _$FerrisWheelLoaderStateCopyWithImpl<$Res, FerrisWheelLoaderState>;
@useResult
$Res call({
Game ferrisWheel,
Option<GameFailure> failureOptionFerrisWheel,
bool isFetching,
});
$GameCopyWith<$Res> get ferrisWheel;
}
/// @nodoc
class _$FerrisWheelLoaderStateCopyWithImpl<
$Res,
$Val extends FerrisWheelLoaderState
>
implements $FerrisWheelLoaderStateCopyWith<$Res> {
_$FerrisWheelLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of FerrisWheelLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? ferrisWheel = null,
Object? failureOptionFerrisWheel = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
ferrisWheel: null == ferrisWheel
? _value.ferrisWheel
: ferrisWheel // ignore: cast_nullable_to_non_nullable
as Game,
failureOptionFerrisWheel: null == failureOptionFerrisWheel
? _value.failureOptionFerrisWheel
: failureOptionFerrisWheel // ignore: cast_nullable_to_non_nullable
as Option<GameFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of FerrisWheelLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$GameCopyWith<$Res> get ferrisWheel {
return $GameCopyWith<$Res>(_value.ferrisWheel, (value) {
return _then(_value.copyWith(ferrisWheel: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$FerrisWheelLoaderStateImplCopyWith<$Res>
implements $FerrisWheelLoaderStateCopyWith<$Res> {
factory _$$FerrisWheelLoaderStateImplCopyWith(
_$FerrisWheelLoaderStateImpl value,
$Res Function(_$FerrisWheelLoaderStateImpl) then,
) = __$$FerrisWheelLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
Game ferrisWheel,
Option<GameFailure> failureOptionFerrisWheel,
bool isFetching,
});
@override
$GameCopyWith<$Res> get ferrisWheel;
}
/// @nodoc
class __$$FerrisWheelLoaderStateImplCopyWithImpl<$Res>
extends
_$FerrisWheelLoaderStateCopyWithImpl<$Res, _$FerrisWheelLoaderStateImpl>
implements _$$FerrisWheelLoaderStateImplCopyWith<$Res> {
__$$FerrisWheelLoaderStateImplCopyWithImpl(
_$FerrisWheelLoaderStateImpl _value,
$Res Function(_$FerrisWheelLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of FerrisWheelLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? ferrisWheel = null,
Object? failureOptionFerrisWheel = null,
Object? isFetching = null,
}) {
return _then(
_$FerrisWheelLoaderStateImpl(
ferrisWheel: null == ferrisWheel
? _value.ferrisWheel
: ferrisWheel // ignore: cast_nullable_to_non_nullable
as Game,
failureOptionFerrisWheel: null == failureOptionFerrisWheel
? _value.failureOptionFerrisWheel
: failureOptionFerrisWheel // ignore: cast_nullable_to_non_nullable
as Option<GameFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$FerrisWheelLoaderStateImpl implements _FerrisWheelLoaderState {
const _$FerrisWheelLoaderStateImpl({
required this.ferrisWheel,
required this.failureOptionFerrisWheel,
this.isFetching = false,
});
@override
final Game ferrisWheel;
@override
final Option<GameFailure> failureOptionFerrisWheel;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'FerrisWheelLoaderState(ferrisWheel: $ferrisWheel, failureOptionFerrisWheel: $failureOptionFerrisWheel, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FerrisWheelLoaderStateImpl &&
(identical(other.ferrisWheel, ferrisWheel) ||
other.ferrisWheel == ferrisWheel) &&
(identical(
other.failureOptionFerrisWheel,
failureOptionFerrisWheel,
) ||
other.failureOptionFerrisWheel == failureOptionFerrisWheel) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode => Object.hash(
runtimeType,
ferrisWheel,
failureOptionFerrisWheel,
isFetching,
);
/// Create a copy of FerrisWheelLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$FerrisWheelLoaderStateImplCopyWith<_$FerrisWheelLoaderStateImpl>
get copyWith =>
__$$FerrisWheelLoaderStateImplCopyWithImpl<_$FerrisWheelLoaderStateImpl>(
this,
_$identity,
);
}
abstract class _FerrisWheelLoaderState implements FerrisWheelLoaderState {
const factory _FerrisWheelLoaderState({
required final Game ferrisWheel,
required final Option<GameFailure> failureOptionFerrisWheel,
final bool isFetching,
}) = _$FerrisWheelLoaderStateImpl;
@override
Game get ferrisWheel;
@override
Option<GameFailure> get failureOptionFerrisWheel;
@override
bool get isFetching;
/// Create a copy of FerrisWheelLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$FerrisWheelLoaderStateImplCopyWith<_$FerrisWheelLoaderStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'ferris_wheel_loader_bloc.dart';
@freezed
class FerrisWheelLoaderEvent with _$FerrisWheelLoaderEvent {
const factory FerrisWheelLoaderEvent.fetched() = _Fetched;
}
@@ -0,0 +1,15 @@
part of 'ferris_wheel_loader_bloc.dart';
@freezed
class FerrisWheelLoaderState with _$FerrisWheelLoaderState {
const factory FerrisWheelLoaderState({
required Game ferrisWheel,
required Option<GameFailure> failureOptionFerrisWheel,
@Default(false) bool isFetching,
}) = _FerrisWheelLoaderState;
factory FerrisWheelLoaderState.initial() => FerrisWheelLoaderState(
ferrisWheel: Game.empty(),
failureOptionFerrisWheel: none(),
);
}
+1
View File
@@ -27,6 +27,7 @@ class ApiClient {
ApiClient(this._dio, this._env) {
_dio.options.baseUrl = _env.baseUrl;
_dio.options.connectTimeout = const Duration(seconds: 20);
_dio.options.validateStatus = (status) => true;
_dio.interceptors.add(BadNetworkErrorInterceptor());
_dio.interceptors.add(BadRequestErrorInterceptor());
_dio.interceptors.add(InternalServerErrorInterceptor());
@@ -1,15 +1,40 @@
import 'package:dio/dio.dart';
import 'dart:developer';
import 'package:auto_route/auto_route.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../presentation/router/app_router.gr.dart';
import '../../constant/local_storage_key.dart';
import '../errors/unauthorized_error.dart';
class UnauthorizedInterceptor extends Interceptor {
static final GlobalKey<NavigatorState> navigatorKey =
GlobalKey<NavigatorState>();
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
void onError(DioException err, ErrorInterceptorHandler handler) async {
if (err.response?.statusCode == 401 ||
err.response?.statusCode == 403 ||
err.response?.statusCode == 419) {
await _handleTokenExpired();
return super.onError(UnauthorizedError(err, null), handler);
}
super.onError(err, handler);
}
Future<void> _handleTokenExpired() async {
// Clear stored token
final prefs = await SharedPreferences.getInstance();
await prefs.remove(LocalStorageKey.token);
await prefs.remove(LocalStorageKey.user);
await prefs.clear(); // Optional: clear all user data
log('handleTokenExpired');
// Navigate to login page
final context = navigatorKey.currentContext;
if (context != null) {
// Option 1: Navigate and remove all previous routes
context.router.replaceAll([LoginRoute()]);
}
}
}
+7 -1
View File
@@ -1,3 +1,9 @@
import '../../sample/sample_data.dart';
class AppConstant {
static const String appName = "";
static const String appName = "Enaklo";
static const String coinName = "EnakCoin";
static const String poinName = "EnakPoin";
}
MerchantModel merchant = merchants.first;
@@ -0,0 +1,4 @@
class LocalStorageKey {
static const token = 'token';
static const user = 'user';
}
+26
View File
@@ -0,0 +1,26 @@
import '../../presentation/components/assets/assets.gen.dart';
class Service {
Service({
required this.name,
required this.description,
required this.imagePath,
});
final String name;
final String imagePath;
final String description;
}
List<Service> services = [
Service(
name: 'Dine In',
description: 'Makan langsung di tempat',
imagePath: Assets.icons.dineIn.path,
),
Service(
name: 'Take Away',
description: 'Pesan dan bawa pulang',
imagePath: Assets.icons.takeaway.path,
),
];
@@ -0,0 +1,28 @@
part of 'extension.dart';
extension DoubleExt on double {
String get currencyFormatRpV2 => NumberFormat.currency(
locale: 'id',
symbol: 'Rp ',
decimalDigits: 0,
).format(this);
}
extension StringX on String {
String get currencyFormatRp {
final parsedValue = int.tryParse(this) ?? 0;
return NumberFormat.currency(
locale: 'id',
symbol: 'Rp ',
decimalDigits: 0,
).format(parsedValue);
}
}
extension IntegerExt on int {
String get currencyFormatRp => NumberFormat.currency(
locale: 'id',
symbol: 'Rp ',
decimalDigits: 0,
).format(this);
}
+1 -1
View File
@@ -23,7 +23,7 @@ extension DateTimeIndonesia on DateTime {
/// Format: 13-08-2025
String get toServerDate {
return DateFormat('dd-MM-yyyy', 'id_ID').format(this);
return DateFormat('yyyy-MM-dd', 'id_ID').format(this);
}
/// Format jam: 14:30
+13 -1
View File
@@ -3,11 +3,12 @@ import 'package:intl/intl.dart';
import '../../domain/auth/auth.dart';
part 'date_extension.dart';
part 'currency_extension.dart';
extension StringExt on String {
CheckPhoneStatus toCheckPhoneStatus() {
switch (this) {
case 'NO_REGISTERED':
case 'NOT_REGISTERED':
return CheckPhoneStatus.notRegistered;
case 'PASSWORD_REQUIRED':
return CheckPhoneStatus.passwordRequired;
@@ -15,4 +16,15 @@ extension StringExt on String {
return CheckPhoneStatus.unknown;
}
}
ResendStatus toResendStatus() {
switch (this) {
case 'RESEND_NOT_ALLOWED':
return ResendStatus.resendNotAllowed;
case 'SUCCESS':
return ResendStatus.success;
default:
return ResendStatus.unknown;
}
}
}
+18
View File
@@ -1,4 +1,8 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../injection.dart';
import '../constant/local_storage_key.dart';
void dismissKeyboard(BuildContext context) {
final currentFocus = FocusScope.of(context);
@@ -6,3 +10,17 @@ void dismissKeyboard(BuildContext context) {
FocusManager.instance.primaryFocus?.unfocus();
}
}
String getNormalizePhone(String phoneNumber) {
final normalizedPhone = phoneNumber.startsWith('08')
? phoneNumber.replaceFirst('0', '')
: phoneNumber;
return '62$normalizedPhone';
}
Map<String, dynamic> getAuthorizationHeader() {
return {
'Authorization':
'Bearer ${getIt<SharedPreferences>().getString(LocalStorageKey.token)}',
};
}
+56 -92
View File
@@ -1,19 +1,21 @@
// wheel_painter.dart - Fixed implementation with consistent positioning
import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../../presentation/pages/mini_games/ferris_wheel/data/model.dart';
import '../theme/theme.dart';
import '../../domain/game/game.dart';
class WheelPainter extends CustomPainter {
final List<WheelSection> sections;
final List<GamePrize> gamePrizes;
final Color Function(GamePrize prize, int index) getPrizeColor;
WheelPainter({required this.sections});
WheelPainter({required this.gamePrizes, required this.getPrizeColor});
@override
void paint(Canvas canvas, Size size) {
if (gamePrizes.isEmpty) return;
final center = Offset(size.width / 2, size.height / 2);
final radius = size.width / 2;
final sectionAngle = 2 * math.pi / sections.length;
final sectionAngle = 2 * math.pi / gamePrizes.length;
// Draw outer white border
final outerBorderPaint = Paint()
@@ -33,13 +35,15 @@ class WheelPainter extends CustomPainter {
..style = PaintingStyle.fill;
canvas.drawCircle(center, radius - 20, innerWhitePaint);
// Draw sections
for (int i = 0; i < sections.length; i++) {
final startAngle = i * sectionAngle - math.pi / 2;
// Draw sections - KONSISTEN dengan logic spin
for (int i = 0; i < gamePrizes.length; i++) {
final prize = gamePrizes[i];
// Section 0 di top (-Ď€/2), section 1 di kanan atas, dst (clockwise)
final startAngle = (-math.pi / 2) + (i * sectionAngle);
// Section background
final sectionPaint = Paint()
..color = sections[i].color
..color = getPrizeColor(prize, i)
..style = PaintingStyle.fill;
canvas.drawArc(
@@ -50,82 +54,67 @@ class WheelPainter extends CustomPainter {
sectionPaint,
);
// Draw icon in each section
final iconAngle = startAngle + sectionAngle / 2;
final iconPosition = Offset(
center.dx + (radius - 60) * math.cos(iconAngle),
center.dy + (radius - 60) * math.sin(iconAngle),
);
// Draw icon background circle
final iconBgPaint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;
canvas.drawCircle(iconPosition, 16, iconBgPaint);
// Save canvas state for icon drawing
canvas.save();
canvas.translate(iconPosition.dx, iconPosition.dy);
// Draw icon using TextPainter to simulate Icon widget
final iconText = _getIconText(sections[i].icon);
final iconTextPainter = TextPainter(
text: TextSpan(
text: iconText,
style: TextStyle(
fontFamily: 'MaterialIcons',
fontSize: 20,
color: sections[i].color,
fontWeight: FontWeight.normal,
),
),
textDirection: TextDirection.ltr,
);
iconTextPainter.layout();
iconTextPainter.paint(
canvas,
Offset(-iconTextPainter.width / 2, -iconTextPainter.height / 2),
);
canvas.restore();
// Draw prize text
final textAngle = startAngle + sectionAngle / 2;
final textPosition = Offset(
center.dx + (radius - 100) * math.cos(textAngle),
center.dy + (radius - 100) * math.sin(textAngle),
center.dx + (radius - 80) * math.cos(textAngle),
center.dy + (radius - 80) * math.sin(textAngle),
);
// Save canvas state for text rotation
canvas.save();
canvas.translate(textPosition.dx, textPosition.dy);
canvas.rotate(textAngle + math.pi / 2);
final textPainter = TextPainter(
text: TextSpan(
text: sections[i].prize,
text: prize.name,
style: const TextStyle(
color: Colors.white,
fontSize: 10,
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
textDirection: TextDirection.ltr,
textAlign: TextAlign.center,
);
textPainter.layout(maxWidth: 100);
textPainter.paint(
canvas,
Offset(-textPainter.width / 2, -textPainter.height / 2),
);
canvas.restore();
// DEBUG: Draw section number
final numberPosition = Offset(
center.dx + (radius - 50) * math.cos(textAngle),
center.dy + (radius - 50) * math.sin(textAngle),
);
canvas.drawCircle(numberPosition, 15, Paint()..color = Colors.white);
final numberPainter = TextPainter(
text: TextSpan(
text: i.toString(),
style: const TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.bold,
),
),
textDirection: TextDirection.ltr,
);
textPainter.layout();
textPainter.paint(
numberPainter.layout();
numberPainter.paint(
canvas,
Offset(-textPainter.width / 2, -textPainter.height / 2),
Offset(
numberPosition.dx - numberPainter.width / 2,
numberPosition.dy - numberPainter.height / 2,
),
);
canvas.restore();
}
// Draw white dots around the outer edge
// Draw white dots
final dotPaint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;
for (int i = 0; i < 24; i++) {
final dotAngle = (2 * math.pi / 24) * i;
final dotPosition = Offset(
@@ -137,15 +126,14 @@ class WheelPainter extends CustomPainter {
// Draw section dividers
final dividerPaint = Paint()
..color = AppColor.white
..color = Colors.white
..style = PaintingStyle.stroke
..strokeWidth = 2;
for (int i = 0; i < sections.length; i++) {
final angle = i * sectionAngle - math.pi / 2;
for (int i = 0; i < gamePrizes.length; i++) {
final angle = (-math.pi / 2) + (i * sectionAngle);
final lineStart = Offset(
center.dx + (radius - 130) * math.cos(angle),
center.dy + (radius - 130) * math.sin(angle),
center.dx + (radius - 110) * math.cos(angle),
center.dy + (radius - 110) * math.sin(angle),
);
final lineEnd = Offset(
center.dx + (radius - 22) * math.cos(angle),
@@ -155,30 +143,6 @@ class WheelPainter extends CustomPainter {
}
}
String _getIconText(IconData icon) {
// Convert IconData to Unicode string for drawing
switch (icon.codePoint) {
case 0xe8f4: // Icons.visibility
return String.fromCharCode(0xe8f4);
case 0xe8f5: // Icons.visibility_off
return String.fromCharCode(0xe8f5);
case 0xe850: // Icons.account_balance_wallet
return String.fromCharCode(0xe850);
case 0xe151: // Icons.card_giftcard
return String.fromCharCode(0xe151);
case 0xe5d5: // Icons.refresh
return String.fromCharCode(0xe5d5);
case 0xe263: // Icons.attach_money
return String.fromCharCode(0xe263);
case 0xe8a1: // Icons.redeem
return String.fromCharCode(0xe8a1);
case 0xe57d: // Icons.monetization_on
return String.fromCharCode(0xe57d);
default:
return String.fromCharCode(0xe87c); // Default star icon
}
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
+5 -1
View File
@@ -1,3 +1,7 @@
part of 'theme.dart';
class AppValue {}
class AppValue {
static const double padding = 16;
static const double margin = 16;
static const double borderRadius = 12;
}
+35 -2
View File
@@ -16,12 +16,34 @@ class ThemeApp {
fontFamily: FontFamily.quicksand,
primaryColor: AppColor.primary,
scaffoldBackgroundColor: AppColor.white,
datePickerTheme: DatePickerThemeData(
backgroundColor: AppColor.white,
todayBackgroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.selected)) {
return AppColor.primary; // warna background tanggal terpilih
}
return null; // default
}),
todayBorder: BorderSide(color: AppColor.primary, width: 1),
dayBackgroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.selected)) {
return AppColor.primary; // warna background tanggal terpilih
}
return null; // default
}),
dayForegroundColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.selected)) {
return AppColor.white; // warna text tanggal terpilih
}
return null; // default
}),
),
appBarTheme: AppBarTheme(
backgroundColor: AppColor.white,
foregroundColor: AppColor.textPrimary,
elevation: 0,
titleTextStyle: AppStyle.xl.copyWith(
color: AppColor.primary,
color: AppColor.textPrimary,
fontWeight: FontWeight.w600,
),
centerTitle: true,
@@ -33,7 +55,18 @@ class ThemeApp {
backgroundColor: AppColor.primary,
foregroundColor: Colors.white,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppValue.borderRadius),
),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: OutlinedButton.styleFrom(
foregroundColor: AppColor.primary,
shape: RoundedRectangleBorder(
side: BorderSide(color: AppColor.border),
borderRadius: BorderRadiusGeometry.circular(AppValue.borderRadius),
),
),
),
inputDecorationTheme: InputDecorationTheme(
+10
View File
@@ -1,4 +1,14 @@
class ApiPath {
static String checkPhone = '/api/v1/customer-auth/check-phone';
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/login';
static String resend = '/api/v1/customer-auth/resend-otp';
// Marketing
static String ferrisWheel = '/api/v1/customer/ferris-wheel';
// Customer
static String customerPoint = '/api/v1/customer/points';
}
+16
View File
@@ -7,6 +7,9 @@ part 'auth.freezed.dart';
part 'entities/check_phone_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 'repositories/i_auth_repository.dart';
@@ -22,3 +25,16 @@ extension CheckPhoneStatusX on CheckPhoneStatus {
bool get isNotRegistered => this == CheckPhoneStatus.notRegistered;
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;
}
+847 -8
View File
@@ -17,7 +17,7 @@ final _privateConstructorUsedError = UnsupportedError(
/// @nodoc
mixin _$CheckPhone {
String get status => throw _privateConstructorUsedError;
CheckPhoneStatus get status => throw _privateConstructorUsedError;
String get message => throw _privateConstructorUsedError;
String get phoneNumber => throw _privateConstructorUsedError;
@@ -35,7 +35,7 @@ abstract class $CheckPhoneCopyWith<$Res> {
$Res Function(CheckPhone) then,
) = _$CheckPhoneCopyWithImpl<$Res, CheckPhone>;
@useResult
$Res call({String status, String message, String phoneNumber});
$Res call({CheckPhoneStatus status, String message, String phoneNumber});
}
/// @nodoc
@@ -62,7 +62,7 @@ class _$CheckPhoneCopyWithImpl<$Res, $Val extends CheckPhone>
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
as CheckPhoneStatus,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
@@ -86,7 +86,7 @@ abstract class _$$CheckPhoneImplCopyWith<$Res>
) = __$$CheckPhoneImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String status, String message, String phoneNumber});
$Res call({CheckPhoneStatus status, String message, String phoneNumber});
}
/// @nodoc
@@ -112,7 +112,7 @@ class __$$CheckPhoneImplCopyWithImpl<$Res>
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String,
as CheckPhoneStatus,
message: null == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
@@ -136,7 +136,7 @@ class _$CheckPhoneImpl implements _CheckPhone {
});
@override
final String status;
final CheckPhoneStatus status;
@override
final String message;
@override
@@ -172,13 +172,13 @@ class _$CheckPhoneImpl implements _CheckPhone {
abstract class _CheckPhone implements CheckPhone {
const factory _CheckPhone({
required final String status,
required final CheckPhoneStatus status,
required final String message,
required final String phoneNumber,
}) = _$CheckPhoneImpl;
@override
String get status;
CheckPhoneStatus get status;
@override
String get message;
@override
@@ -424,6 +424,845 @@ abstract class _Register implements Register {
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 {
ResendStatus 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({
ResendStatus 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 ResendStatus,
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({
ResendStatus 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 ResendStatus,
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 ResendStatus 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 ResendStatus status,
required final String message,
required final String otpToken,
required final int expiresIn,
required final int nextResendIn,
}) = _$ResendImpl;
@override
ResendStatus 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
mixin _$AuthFailure {
@optionalTypeArgs
@@ -3,11 +3,14 @@ part of '../auth.dart';
@freezed
class CheckPhone with _$CheckPhone {
const factory CheckPhone({
required String status,
required CheckPhoneStatus status,
required String message,
required String phoneNumber,
}) = _CheckPhone;
factory CheckPhone.empty() =>
const CheckPhone(status: '', message: '', phoneNumber: '');
factory CheckPhone.empty() => CheckPhone(
status: CheckPhoneStatus.unknown,
message: '',
phoneNumber: '',
);
}
@@ -0,0 +1,33 @@
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: '');
}
@@ -0,0 +1,20 @@
part of '../auth.dart';
@freezed
class Resend with _$Resend {
const factory Resend({
required ResendStatus status,
required String message,
required String otpToken,
required int expiresIn,
required int nextResendIn,
}) = _Resend;
factory Resend.empty() => Resend(
status: ResendStatus.unknown,
message: '',
otpToken: '',
expiresIn: 0,
nextResendIn: 0,
);
}
@@ -0,0 +1,13 @@
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: '');
}
@@ -10,4 +10,31 @@ abstract class IAuthRepository {
required String name,
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,
});
Future<bool> hasToken();
Future<Either<AuthFailure, User>> currentUser();
Future<Either<AuthFailure, Unit>> logout();
}
+10
View File
@@ -0,0 +1,10 @@
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../common/api/api_failure.dart';
part 'customer.freezed.dart';
part 'entities/customer_point_entity.dart';
part 'failures/customer_failures.dart';
part 'repositories/i_customer_repository.dart';
+713
View File
@@ -0,0 +1,713 @@
// 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 'customer.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 _$CustomerPoint {
String get status => throw _privateConstructorUsedError;
String get message => throw _privateConstructorUsedError;
int get totalPoints => throw _privateConstructorUsedError;
String get lastUpdated => throw _privateConstructorUsedError;
/// Create a copy of CustomerPoint
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$CustomerPointCopyWith<CustomerPoint> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CustomerPointCopyWith<$Res> {
factory $CustomerPointCopyWith(
CustomerPoint value,
$Res Function(CustomerPoint) then,
) = _$CustomerPointCopyWithImpl<$Res, CustomerPoint>;
@useResult
$Res call({
String status,
String message,
int totalPoints,
String lastUpdated,
});
}
/// @nodoc
class _$CustomerPointCopyWithImpl<$Res, $Val extends CustomerPoint>
implements $CustomerPointCopyWith<$Res> {
_$CustomerPointCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CustomerPoint
/// 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? totalPoints = null,
Object? lastUpdated = 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,
totalPoints: null == totalPoints
? _value.totalPoints
: totalPoints // ignore: cast_nullable_to_non_nullable
as int,
lastUpdated: null == lastUpdated
? _value.lastUpdated
: lastUpdated // ignore: cast_nullable_to_non_nullable
as String,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$CustomerPointImplCopyWith<$Res>
implements $CustomerPointCopyWith<$Res> {
factory _$$CustomerPointImplCopyWith(
_$CustomerPointImpl value,
$Res Function(_$CustomerPointImpl) then,
) = __$$CustomerPointImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String status,
String message,
int totalPoints,
String lastUpdated,
});
}
/// @nodoc
class __$$CustomerPointImplCopyWithImpl<$Res>
extends _$CustomerPointCopyWithImpl<$Res, _$CustomerPointImpl>
implements _$$CustomerPointImplCopyWith<$Res> {
__$$CustomerPointImplCopyWithImpl(
_$CustomerPointImpl _value,
$Res Function(_$CustomerPointImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerPoint
/// 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? totalPoints = null,
Object? lastUpdated = null,
}) {
return _then(
_$CustomerPointImpl(
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,
totalPoints: null == totalPoints
? _value.totalPoints
: totalPoints // ignore: cast_nullable_to_non_nullable
as int,
lastUpdated: null == lastUpdated
? _value.lastUpdated
: lastUpdated // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$CustomerPointImpl implements _CustomerPoint {
const _$CustomerPointImpl({
required this.status,
required this.message,
required this.totalPoints,
required this.lastUpdated,
});
@override
final String status;
@override
final String message;
@override
final int totalPoints;
@override
final String lastUpdated;
@override
String toString() {
return 'CustomerPoint(status: $status, message: $message, totalPoints: $totalPoints, lastUpdated: $lastUpdated)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CustomerPointImpl &&
(identical(other.status, status) || other.status == status) &&
(identical(other.message, message) || other.message == message) &&
(identical(other.totalPoints, totalPoints) ||
other.totalPoints == totalPoints) &&
(identical(other.lastUpdated, lastUpdated) ||
other.lastUpdated == lastUpdated));
}
@override
int get hashCode =>
Object.hash(runtimeType, status, message, totalPoints, lastUpdated);
/// Create a copy of CustomerPoint
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CustomerPointImplCopyWith<_$CustomerPointImpl> get copyWith =>
__$$CustomerPointImplCopyWithImpl<_$CustomerPointImpl>(this, _$identity);
}
abstract class _CustomerPoint implements CustomerPoint {
const factory _CustomerPoint({
required final String status,
required final String message,
required final int totalPoints,
required final String lastUpdated,
}) = _$CustomerPointImpl;
@override
String get status;
@override
String get message;
@override
int get totalPoints;
@override
String get lastUpdated;
/// Create a copy of CustomerPoint
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CustomerPointImplCopyWith<_$CustomerPointImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$CustomerFailure {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CustomerFailureCopyWith<$Res> {
factory $CustomerFailureCopyWith(
CustomerFailure value,
$Res Function(CustomerFailure) then,
) = _$CustomerFailureCopyWithImpl<$Res, CustomerFailure>;
}
/// @nodoc
class _$CustomerFailureCopyWithImpl<$Res, $Val extends CustomerFailure>
implements $CustomerFailureCopyWith<$Res> {
_$CustomerFailureCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$ServerErrorImplCopyWith<$Res> {
factory _$$ServerErrorImplCopyWith(
_$ServerErrorImpl value,
$Res Function(_$ServerErrorImpl) then,
) = __$$ServerErrorImplCopyWithImpl<$Res>;
@useResult
$Res call({ApiFailure failure});
$ApiFailureCopyWith<$Res> get failure;
}
/// @nodoc
class __$$ServerErrorImplCopyWithImpl<$Res>
extends _$CustomerFailureCopyWithImpl<$Res, _$ServerErrorImpl>
implements _$$ServerErrorImplCopyWith<$Res> {
__$$ServerErrorImplCopyWithImpl(
_$ServerErrorImpl _value,
$Res Function(_$ServerErrorImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? failure = null}) {
return _then(
_$ServerErrorImpl(
null == failure
? _value.failure
: failure // ignore: cast_nullable_to_non_nullable
as ApiFailure,
),
);
}
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ApiFailureCopyWith<$Res> get failure {
return $ApiFailureCopyWith<$Res>(_value.failure, (value) {
return _then(_value.copyWith(failure: value));
});
}
}
/// @nodoc
class _$ServerErrorImpl implements _ServerError {
const _$ServerErrorImpl(this.failure);
@override
final ApiFailure failure;
@override
String toString() {
return 'CustomerFailure.serverError(failure: $failure)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ServerErrorImpl &&
(identical(other.failure, failure) || other.failure == failure));
}
@override
int get hashCode => Object.hash(runtimeType, failure);
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith =>
__$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return serverError(failure);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return serverError?.call(failure);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (serverError != null) {
return serverError(failure);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return serverError(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return serverError?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (serverError != null) {
return serverError(this);
}
return orElse();
}
}
abstract class _ServerError implements CustomerFailure {
const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl;
ApiFailure get failure;
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$UnexpectedErrorImplCopyWith<$Res> {
factory _$$UnexpectedErrorImplCopyWith(
_$UnexpectedErrorImpl value,
$Res Function(_$UnexpectedErrorImpl) then,
) = __$$UnexpectedErrorImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$UnexpectedErrorImplCopyWithImpl<$Res>
extends _$CustomerFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl>
implements _$$UnexpectedErrorImplCopyWith<$Res> {
__$$UnexpectedErrorImplCopyWithImpl(
_$UnexpectedErrorImpl _value,
$Res Function(_$UnexpectedErrorImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$UnexpectedErrorImpl implements _UnexpectedError {
const _$UnexpectedErrorImpl();
@override
String toString() {
return 'CustomerFailure.unexpectedError()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return unexpectedError();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return unexpectedError?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (unexpectedError != null) {
return unexpectedError();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return unexpectedError(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return unexpectedError?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (unexpectedError != null) {
return unexpectedError(this);
}
return orElse();
}
}
abstract class _UnexpectedError implements CustomerFailure {
const factory _UnexpectedError() = _$UnexpectedErrorImpl;
}
/// @nodoc
abstract class _$$DynamicErrorMessageImplCopyWith<$Res> {
factory _$$DynamicErrorMessageImplCopyWith(
_$DynamicErrorMessageImpl value,
$Res Function(_$DynamicErrorMessageImpl) then,
) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>;
@useResult
$Res call({String erroMessage});
}
/// @nodoc
class __$$DynamicErrorMessageImplCopyWithImpl<$Res>
extends _$CustomerFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl>
implements _$$DynamicErrorMessageImplCopyWith<$Res> {
__$$DynamicErrorMessageImplCopyWithImpl(
_$DynamicErrorMessageImpl _value,
$Res Function(_$DynamicErrorMessageImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? erroMessage = null}) {
return _then(
_$DynamicErrorMessageImpl(
null == erroMessage
? _value.erroMessage
: erroMessage // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$DynamicErrorMessageImpl implements _DynamicErrorMessage {
const _$DynamicErrorMessageImpl(this.erroMessage);
@override
final String erroMessage;
@override
String toString() {
return 'CustomerFailure.dynamicErrorMessage(erroMessage: $erroMessage)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$DynamicErrorMessageImpl &&
(identical(other.erroMessage, erroMessage) ||
other.erroMessage == erroMessage));
}
@override
int get hashCode => Object.hash(runtimeType, erroMessage);
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith =>
__$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(ApiFailure failure) serverError,
required TResult Function() unexpectedError,
required TResult Function(String erroMessage) dynamicErrorMessage,
}) {
return dynamicErrorMessage(erroMessage);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(ApiFailure failure)? serverError,
TResult? Function()? unexpectedError,
TResult? Function(String erroMessage)? dynamicErrorMessage,
}) {
return dynamicErrorMessage?.call(erroMessage);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(ApiFailure failure)? serverError,
TResult Function()? unexpectedError,
TResult Function(String erroMessage)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (dynamicErrorMessage != null) {
return dynamicErrorMessage(erroMessage);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_ServerError value) serverError,
required TResult Function(_UnexpectedError value) unexpectedError,
required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage,
}) {
return dynamicErrorMessage(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_ServerError value)? serverError,
TResult? Function(_UnexpectedError value)? unexpectedError,
TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage,
}) {
return dynamicErrorMessage?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_ServerError value)? serverError,
TResult Function(_UnexpectedError value)? unexpectedError,
TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage,
required TResult orElse(),
}) {
if (dynamicErrorMessage != null) {
return dynamicErrorMessage(this);
}
return orElse();
}
}
abstract class _DynamicErrorMessage implements CustomerFailure {
const factory _DynamicErrorMessage(final String erroMessage) =
_$DynamicErrorMessageImpl;
String get erroMessage;
/// Create a copy of CustomerFailure
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -0,0 +1,18 @@
part of '../customer.dart';
@freezed
class CustomerPoint with _$CustomerPoint {
const factory CustomerPoint({
required String status,
required String message,
required int totalPoints,
required String lastUpdated,
}) = _CustomerPoint;
factory CustomerPoint.empty() => const CustomerPoint(
status: '',
message: '',
totalPoints: 0,
lastUpdated: '',
);
}
@@ -0,0 +1,9 @@
part of '../customer.dart';
@freezed
sealed class CustomerFailure with _$CustomerFailure {
const factory CustomerFailure.serverError(ApiFailure failure) = _ServerError;
const factory CustomerFailure.unexpectedError() = _UnexpectedError;
const factory CustomerFailure.dynamicErrorMessage(String erroMessage) =
_DynamicErrorMessage;
}
@@ -0,0 +1,5 @@
part of '../customer.dart';
abstract class ICustomerRepository {
Future<Either<CustomerFailure, CustomerPoint>> getPoints();
}
+26
View File
@@ -0,0 +1,26 @@
part of '../game.dart';
@freezed
class Game with _$Game {
const factory Game({
required String id,
required String name,
required String type,
required bool isActive,
required Map<String, dynamic> metadata,
required List<GamePrize> prizes,
required String createdAt,
required String updatedAt,
}) = _Game;
factory Game.empty() => const Game(
id: '',
name: '',
type: '',
isActive: false,
metadata: {},
prizes: [],
createdAt: '',
updatedAt: '',
);
}
@@ -0,0 +1,22 @@
part of '../game.dart';
@freezed
class GamePrize with _$GamePrize {
const factory GamePrize({
required String id,
required String gameId,
required String name,
required Map<String, dynamic> metadata,
required String createdAt,
required String updatedAt,
}) = _GamePrize;
factory GamePrize.empty() => const GamePrize(
id: '',
gameId: '',
name: '',
metadata: {},
createdAt: '',
updatedAt: '',
);
}
@@ -0,0 +1,9 @@
part of '../game.dart';
@freezed
sealed class GameFailure with _$GameFailure {
const factory GameFailure.serverError(ApiFailure failure) = _ServerError;
const factory GameFailure.unexpectedError() = _UnexpectedError;
const factory GameFailure.dynamicErrorMessage(String erroMessage) =
_DynamicErrorMessage;
}
+11
View File
@@ -0,0 +1,11 @@
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../common/api/api_failure.dart';
part 'game.freezed.dart';
part 'entity/game_entity.dart';
part 'entity/game_prize_entity.dart';
part 'failures/game_failure.dart';
part 'repositories/i_game_repository.dart';
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
part of '../game.dart';
abstract class IGameRepository {
Future<Either<GameFailure, Game>> ferrisWheel();
}
+3 -2
View File
@@ -9,12 +9,13 @@ abstract class Env {
@dev
class DevEnv implements Env {
@override
String get baseUrl => 'http://192.168.1.30:4000'; // example value
// String get baseUrl => 'http://192.168.1.30:4000'; // example value
String get baseUrl => 'https://api-pos.apskel.id'; // example value
}
@Injectable(as: Env)
@prod
class ProdEnv implements Env {
@override
String get baseUrl => 'https://enaklo-pos-be.altru.id';
String get baseUrl => 'https://api-pos.apskel.id';
}
+4
View File
@@ -1,5 +1,6 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../common/extension/extension.dart';
import '../../domain/auth/auth.dart';
part 'auth_dtos.freezed.dart';
@@ -7,3 +8,6 @@ part 'auth_dtos.g.dart';
part 'dto/check_phone_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
+102
View File
@@ -61,3 +61,105 @@ Map<String, dynamic> _$$RegisterDataDtoImplToJson(
'otp_token': instance.otpToken,
'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,
};
@@ -0,0 +1,60 @@
import 'dart:convert';
import 'dart:developer';
import 'package:injectable/injectable.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../common/constant/local_storage_key.dart';
import '../../../domain/auth/auth.dart';
import '../auth_dtos.dart';
@injectable
class AuthLocalDataProvider {
final SharedPreferences _sharedPreferences;
final String _logName = 'AuthLocalDataProvider';
AuthLocalDataProvider(this._sharedPreferences);
Future<void> saveToken(String token) async {
await _sharedPreferences.setString(LocalStorageKey.token, token);
}
Future<String?> getToken() async {
return _sharedPreferences.getString(LocalStorageKey.token);
}
Future<void> deleteToken() async {
await _sharedPreferences.remove(LocalStorageKey.token);
}
Future<bool> hasToken() async {
return _sharedPreferences.containsKey(LocalStorageKey.token);
}
Future<void> saveCurrentUser(UserDto user) async {
final userJsonString = jsonEncode(user.toJson());
await _sharedPreferences.setString(LocalStorageKey.user, userJsonString);
}
Future<User> currentUser() async {
final userString = _sharedPreferences.getString(LocalStorageKey.user);
if (userString == null) return User.empty();
final Map<String, dynamic> userMap = jsonDecode(userString);
final userDto = UserDto.fromJson(userMap);
return userDto.toDomain();
}
Future<void> deleteCurrentUser() async {
await _sharedPreferences.remove(LocalStorageKey.user);
}
Future<void> deleteAllAuth() async {
try {
await _sharedPreferences.remove(LocalStorageKey.token);
await _sharedPreferences.remove(LocalStorageKey.user);
} catch (e) {
log('deleteAllAuthError', name: _logName, error: e);
}
}
}
@@ -41,6 +41,13 @@ class AuthRemoteDataProvider {
AuthFailure.dynamicErrorMessage('No. Telepon Tidak Boleh Kosong'),
);
}
if (response.data['errors'][0]['code'] == 304) {
return DC.error(
AuthFailure.dynamicErrorMessage(
response.data['errors'][0]['cause'],
),
);
}
}
}
@@ -96,4 +103,163 @@ class AuthRemoteDataProvider {
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 if (response.data['errors'][0]['code'] == "304") {
return DC.error(
AuthFailure.dynamicErrorMessage(
response.data['errors'][0]['cause'],
),
);
} 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(
response.data['errors'][0]['cause'],
),
);
} 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));
}
}
}
@@ -13,7 +13,7 @@ class CheckPhoneDto with _$CheckPhoneDto {
factory CheckPhoneDto.fromJson(Map<String, dynamic> json) =>
_$CheckPhoneDtoFromJson(json);
CheckPhone toDomain() => CheckPhone(
status: status ?? '',
status: status?.toCheckPhoneStatus() ?? CheckPhoneStatus.unknown,
message: message ?? '',
phoneNumber: data?.phoneNumber ?? '',
);
@@ -0,0 +1,58 @@
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 ?? '',
);
}
@@ -0,0 +1,36 @@
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?.toResendStatus() ?? ResendStatus.unknown,
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);
}
@@ -0,0 +1,32 @@
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);
}
@@ -4,15 +4,17 @@ import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/auth/auth.dart';
import '../datasources/local_data_provider.dart';
import '../datasources/remote_data_provider.dart';
@Injectable(as: IAuthRepository)
class AuthRepository implements IAuthRepository {
final AuthLocalDataProvider _localDataProvider;
final AuthRemoteDataProvider _remoteDataProvider;
final String _logName = 'AuthRepository';
AuthRepository(this._remoteDataProvider);
AuthRepository(this._remoteDataProvider, this._localDataProvider);
@override
Future<Either<AuthFailure, CheckPhone>> checkPhone({
@@ -57,7 +59,138 @@ class AuthRepository implements IAuthRepository {
return right(auth);
} catch (e, s) {
log('checkPhoneError', name: _logName, error: e, stackTrace: s);
log('registerError', 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();
await _localDataProvider.saveToken(auth.accessToken);
await _localDataProvider.saveCurrentUser(result.data!.data!.user!);
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();
await _localDataProvider.saveToken(auth.accessToken);
await _localDataProvider.saveCurrentUser(result.data!.data!.user!);
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());
}
}
@override
Future<Either<AuthFailure, User>> currentUser() async {
try {
User user = await _localDataProvider.currentUser();
return right(user);
} catch (e, s) {
log('currentUserError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError());
}
}
@override
Future<bool> hasToken() async {
return await _localDataProvider.hasToken();
}
@override
Future<Either<AuthFailure, Unit>> logout() async {
try {
await _localDataProvider.deleteAllAuth();
return right(unit);
} catch (e, s) {
log('logoutError', name: _logName, error: e, stackTrace: s);
return left(const AuthFailure.unexpectedError());
}
}
@@ -0,0 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/customer/customer.dart';
part 'customer_dtos.freezed.dart';
part 'customer_dtos.g.dart';
part 'dtos/customer_point_dto.dart';
@@ -0,0 +1,443 @@
// 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 'customer_dtos.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',
);
CustomerPointDto _$CustomerPointDtoFromJson(Map<String, dynamic> json) {
return _CustomerPointDto.fromJson(json);
}
/// @nodoc
mixin _$CustomerPointDto {
@JsonKey(name: 'status')
String? get status => throw _privateConstructorUsedError;
@JsonKey(name: 'message')
String? get message => throw _privateConstructorUsedError;
@JsonKey(name: 'data')
CustomerPointDataDto? get data => throw _privateConstructorUsedError;
/// Serializes this CustomerPointDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of CustomerPointDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$CustomerPointDtoCopyWith<CustomerPointDto> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CustomerPointDtoCopyWith<$Res> {
factory $CustomerPointDtoCopyWith(
CustomerPointDto value,
$Res Function(CustomerPointDto) then,
) = _$CustomerPointDtoCopyWithImpl<$Res, CustomerPointDto>;
@useResult
$Res call({
@JsonKey(name: 'status') String? status,
@JsonKey(name: 'message') String? message,
@JsonKey(name: 'data') CustomerPointDataDto? data,
});
$CustomerPointDataDtoCopyWith<$Res>? get data;
}
/// @nodoc
class _$CustomerPointDtoCopyWithImpl<$Res, $Val extends CustomerPointDto>
implements $CustomerPointDtoCopyWith<$Res> {
_$CustomerPointDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CustomerPointDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = freezed,
Object? message = freezed,
Object? data = freezed,
}) {
return _then(
_value.copyWith(
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String?,
message: freezed == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String?,
data: freezed == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as CustomerPointDataDto?,
)
as $Val,
);
}
/// Create a copy of CustomerPointDto
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$CustomerPointDataDtoCopyWith<$Res>? get data {
if (_value.data == null) {
return null;
}
return $CustomerPointDataDtoCopyWith<$Res>(_value.data!, (value) {
return _then(_value.copyWith(data: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$CustomerPointDtoImplCopyWith<$Res>
implements $CustomerPointDtoCopyWith<$Res> {
factory _$$CustomerPointDtoImplCopyWith(
_$CustomerPointDtoImpl value,
$Res Function(_$CustomerPointDtoImpl) then,
) = __$$CustomerPointDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
@JsonKey(name: 'status') String? status,
@JsonKey(name: 'message') String? message,
@JsonKey(name: 'data') CustomerPointDataDto? data,
});
@override
$CustomerPointDataDtoCopyWith<$Res>? get data;
}
/// @nodoc
class __$$CustomerPointDtoImplCopyWithImpl<$Res>
extends _$CustomerPointDtoCopyWithImpl<$Res, _$CustomerPointDtoImpl>
implements _$$CustomerPointDtoImplCopyWith<$Res> {
__$$CustomerPointDtoImplCopyWithImpl(
_$CustomerPointDtoImpl _value,
$Res Function(_$CustomerPointDtoImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerPointDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? status = freezed,
Object? message = freezed,
Object? data = freezed,
}) {
return _then(
_$CustomerPointDtoImpl(
status: freezed == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String?,
message: freezed == message
? _value.message
: message // ignore: cast_nullable_to_non_nullable
as String?,
data: freezed == data
? _value.data
: data // ignore: cast_nullable_to_non_nullable
as CustomerPointDataDto?,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$CustomerPointDtoImpl extends _CustomerPointDto {
const _$CustomerPointDtoImpl({
@JsonKey(name: 'status') this.status,
@JsonKey(name: 'message') this.message,
@JsonKey(name: 'data') this.data,
}) : super._();
factory _$CustomerPointDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$CustomerPointDtoImplFromJson(json);
@override
@JsonKey(name: 'status')
final String? status;
@override
@JsonKey(name: 'message')
final String? message;
@override
@JsonKey(name: 'data')
final CustomerPointDataDto? data;
@override
String toString() {
return 'CustomerPointDto(status: $status, message: $message, data: $data)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CustomerPointDtoImpl &&
(identical(other.status, status) || other.status == status) &&
(identical(other.message, message) || other.message == message) &&
(identical(other.data, data) || other.data == data));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, status, message, data);
/// Create a copy of CustomerPointDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CustomerPointDtoImplCopyWith<_$CustomerPointDtoImpl> get copyWith =>
__$$CustomerPointDtoImplCopyWithImpl<_$CustomerPointDtoImpl>(
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$CustomerPointDtoImplToJson(this);
}
}
abstract class _CustomerPointDto extends CustomerPointDto {
const factory _CustomerPointDto({
@JsonKey(name: 'status') final String? status,
@JsonKey(name: 'message') final String? message,
@JsonKey(name: 'data') final CustomerPointDataDto? data,
}) = _$CustomerPointDtoImpl;
const _CustomerPointDto._() : super._();
factory _CustomerPointDto.fromJson(Map<String, dynamic> json) =
_$CustomerPointDtoImpl.fromJson;
@override
@JsonKey(name: 'status')
String? get status;
@override
@JsonKey(name: 'message')
String? get message;
@override
@JsonKey(name: 'data')
CustomerPointDataDto? get data;
/// Create a copy of CustomerPointDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CustomerPointDtoImplCopyWith<_$CustomerPointDtoImpl> get copyWith =>
throw _privateConstructorUsedError;
}
CustomerPointDataDto _$CustomerPointDataDtoFromJson(Map<String, dynamic> json) {
return _CustomerPointDataDto.fromJson(json);
}
/// @nodoc
mixin _$CustomerPointDataDto {
@JsonKey(name: 'total_points')
int? get totalPoints => throw _privateConstructorUsedError;
@JsonKey(name: 'last_updated')
String? get lastUpdated => throw _privateConstructorUsedError;
/// Serializes this CustomerPointDataDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of CustomerPointDataDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$CustomerPointDataDtoCopyWith<CustomerPointDataDto> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CustomerPointDataDtoCopyWith<$Res> {
factory $CustomerPointDataDtoCopyWith(
CustomerPointDataDto value,
$Res Function(CustomerPointDataDto) then,
) = _$CustomerPointDataDtoCopyWithImpl<$Res, CustomerPointDataDto>;
@useResult
$Res call({
@JsonKey(name: 'total_points') int? totalPoints,
@JsonKey(name: 'last_updated') String? lastUpdated,
});
}
/// @nodoc
class _$CustomerPointDataDtoCopyWithImpl<
$Res,
$Val extends CustomerPointDataDto
>
implements $CustomerPointDataDtoCopyWith<$Res> {
_$CustomerPointDataDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CustomerPointDataDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? totalPoints = freezed, Object? lastUpdated = freezed}) {
return _then(
_value.copyWith(
totalPoints: freezed == totalPoints
? _value.totalPoints
: totalPoints // ignore: cast_nullable_to_non_nullable
as int?,
lastUpdated: freezed == lastUpdated
? _value.lastUpdated
: lastUpdated // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$CustomerPointDataDtoImplCopyWith<$Res>
implements $CustomerPointDataDtoCopyWith<$Res> {
factory _$$CustomerPointDataDtoImplCopyWith(
_$CustomerPointDataDtoImpl value,
$Res Function(_$CustomerPointDataDtoImpl) then,
) = __$$CustomerPointDataDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
@JsonKey(name: 'total_points') int? totalPoints,
@JsonKey(name: 'last_updated') String? lastUpdated,
});
}
/// @nodoc
class __$$CustomerPointDataDtoImplCopyWithImpl<$Res>
extends _$CustomerPointDataDtoCopyWithImpl<$Res, _$CustomerPointDataDtoImpl>
implements _$$CustomerPointDataDtoImplCopyWith<$Res> {
__$$CustomerPointDataDtoImplCopyWithImpl(
_$CustomerPointDataDtoImpl _value,
$Res Function(_$CustomerPointDataDtoImpl) _then,
) : super(_value, _then);
/// Create a copy of CustomerPointDataDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? totalPoints = freezed, Object? lastUpdated = freezed}) {
return _then(
_$CustomerPointDataDtoImpl(
totalPoints: freezed == totalPoints
? _value.totalPoints
: totalPoints // ignore: cast_nullable_to_non_nullable
as int?,
lastUpdated: freezed == lastUpdated
? _value.lastUpdated
: lastUpdated // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$CustomerPointDataDtoImpl implements _CustomerPointDataDto {
const _$CustomerPointDataDtoImpl({
@JsonKey(name: 'total_points') this.totalPoints,
@JsonKey(name: 'last_updated') this.lastUpdated,
});
factory _$CustomerPointDataDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$CustomerPointDataDtoImplFromJson(json);
@override
@JsonKey(name: 'total_points')
final int? totalPoints;
@override
@JsonKey(name: 'last_updated')
final String? lastUpdated;
@override
String toString() {
return 'CustomerPointDataDto(totalPoints: $totalPoints, lastUpdated: $lastUpdated)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CustomerPointDataDtoImpl &&
(identical(other.totalPoints, totalPoints) ||
other.totalPoints == totalPoints) &&
(identical(other.lastUpdated, lastUpdated) ||
other.lastUpdated == lastUpdated));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, totalPoints, lastUpdated);
/// Create a copy of CustomerPointDataDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CustomerPointDataDtoImplCopyWith<_$CustomerPointDataDtoImpl>
get copyWith =>
__$$CustomerPointDataDtoImplCopyWithImpl<_$CustomerPointDataDtoImpl>(
this,
_$identity,
);
@override
Map<String, dynamic> toJson() {
return _$$CustomerPointDataDtoImplToJson(this);
}
}
abstract class _CustomerPointDataDto implements CustomerPointDataDto {
const factory _CustomerPointDataDto({
@JsonKey(name: 'total_points') final int? totalPoints,
@JsonKey(name: 'last_updated') final String? lastUpdated,
}) = _$CustomerPointDataDtoImpl;
factory _CustomerPointDataDto.fromJson(Map<String, dynamic> json) =
_$CustomerPointDataDtoImpl.fromJson;
@override
@JsonKey(name: 'total_points')
int? get totalPoints;
@override
@JsonKey(name: 'last_updated')
String? get lastUpdated;
/// Create a copy of CustomerPointDataDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CustomerPointDataDtoImplCopyWith<_$CustomerPointDataDtoImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,39 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'customer_dtos.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$CustomerPointDtoImpl _$$CustomerPointDtoImplFromJson(
Map<String, dynamic> json,
) => _$CustomerPointDtoImpl(
status: json['status'] as String?,
message: json['message'] as String?,
data: json['data'] == null
? null
: CustomerPointDataDto.fromJson(json['data'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$CustomerPointDtoImplToJson(
_$CustomerPointDtoImpl instance,
) => <String, dynamic>{
'status': instance.status,
'message': instance.message,
'data': instance.data,
};
_$CustomerPointDataDtoImpl _$$CustomerPointDataDtoImplFromJson(
Map<String, dynamic> json,
) => _$CustomerPointDataDtoImpl(
totalPoints: (json['total_points'] as num?)?.toInt(),
lastUpdated: json['last_updated'] as String?,
);
Map<String, dynamic> _$$CustomerPointDataDtoImplToJson(
_$CustomerPointDataDtoImpl instance,
) => <String, dynamic>{
'total_points': instance.totalPoints,
'last_updated': instance.lastUpdated,
};
@@ -0,0 +1,50 @@
import 'dart:developer';
import 'package:data_channel/data_channel.dart';
import 'package:injectable/injectable.dart';
import '../../../common/api/api_client.dart';
import '../../../common/api/api_failure.dart';
import '../../../common/function/app_function.dart';
import '../../../common/url/api_path.dart';
import '../../../domain/customer/customer.dart';
import '../customer_dtos.dart';
@injectable
class CustomerRemoteDataProvider {
final ApiClient _apiClient;
final String _logName = "CustomerRemoteDataProvider";
CustomerRemoteDataProvider(this._apiClient);
Future<DC<CustomerFailure, CustomerPointDto>> fetchCustomerPoint() async {
try {
final response = await _apiClient.get(
ApiPath.customerPoint,
headers: getAuthorizationHeader(),
);
if (response.data['code'] == 401) {
return DC.error(
CustomerFailure.serverError(
ApiFailure.unauthorized('Session Expired'),
),
);
}
if (response.data['status'] == false) {
return DC.error(
CustomerFailure.dynamicErrorMessage(
'Terjadi kesalahan coba lagi nanti',
),
);
}
final dto = CustomerPointDto.fromJson(response.data['data']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('fetchCustomerPoint', name: _logName, error: e, stackTrace: s);
return DC.error(CustomerFailure.serverError(e));
}
}
}
@@ -0,0 +1,34 @@
part of '../customer_dtos.dart';
@freezed
class CustomerPointDto with _$CustomerPointDto {
const factory CustomerPointDto({
@JsonKey(name: 'status') String? status,
@JsonKey(name: 'message') String? message,
@JsonKey(name: 'data') CustomerPointDataDto? data,
}) = _CustomerPointDto;
factory CustomerPointDto.fromJson(Map<String, dynamic> json) =>
_$CustomerPointDtoFromJson(json);
const CustomerPointDto._();
/// mapping ke domain
CustomerPoint toDomain() => CustomerPoint(
status: status ?? '',
message: message ?? '',
totalPoints: data?.totalPoints ?? 0,
lastUpdated: data?.lastUpdated ?? '',
);
}
@freezed
class CustomerPointDataDto with _$CustomerPointDataDto {
const factory CustomerPointDataDto({
@JsonKey(name: 'total_points') int? totalPoints,
@JsonKey(name: 'last_updated') String? lastUpdated,
}) = _CustomerPointDataDto;
factory CustomerPointDataDto.fromJson(Map<String, dynamic> json) =>
_$CustomerPointDataDtoFromJson(json);
}
@@ -0,0 +1,33 @@
import 'dart:developer';
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/customer/customer.dart';
import '../datasources/remote_data_provider.dart';
@Injectable(as: ICustomerRepository)
class CustomerRepository implements ICustomerRepository {
final CustomerRemoteDataProvider _remoteDataProvider;
final String _logName = 'CustomerRepository';
CustomerRepository(this._remoteDataProvider);
@override
Future<Either<CustomerFailure, CustomerPoint>> getPoints() async {
try {
final result = await _remoteDataProvider.fetchCustomerPoint();
if (result.hasError) {
return left(result.error!);
}
final data = result.data!.toDomain();
return right(data);
} catch (e, s) {
log('getPoints', name: _logName, error: e, stackTrace: s);
return left(const CustomerFailure.unexpectedError());
}
}
}
@@ -0,0 +1,47 @@
import 'dart:developer';
import 'package:data_channel/data_channel.dart';
import 'package:injectable/injectable.dart';
import '../../../common/api/api_client.dart';
import '../../../common/api/api_failure.dart';
import '../../../common/function/app_function.dart';
import '../../../common/url/api_path.dart';
import '../../../domain/game/game.dart';
import '../game_dtos.dart';
@injectable
class GameRemoteDataProvider {
final ApiClient _apiClient;
final String _logName = "GameRemoteDataProvider";
GameRemoteDataProvider(this._apiClient);
Future<DC<GameFailure, GameDto>> ferrisWheel() async {
try {
final response = await _apiClient.get(
ApiPath.ferrisWheel,
headers: getAuthorizationHeader(),
);
if (response.data['code'] == 401) {
return DC.error(
GameFailure.serverError(ApiFailure.unauthorized('Session Expired')),
);
}
if (response.data['status'] == false) {
return DC.error(
GameFailure.dynamicErrorMessage('Terjadi kesalahan coba lagi nanti'),
);
}
final dto = GameDto.fromJson(response.data['data']['data']['game']);
return DC.data(dto);
} on ApiFailure catch (e, s) {
log('ferrisWheel', name: _logName, error: e, stackTrace: s);
return DC.error(GameFailure.serverError(e));
}
}
}
+31
View File
@@ -0,0 +1,31 @@
part of '../game_dtos.dart';
@freezed
class GameDto with _$GameDto {
const factory GameDto({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'type') String? type,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
@JsonKey(name: 'prizes') List<GamePrizeDto>? prizes,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
}) = _GameDto;
factory GameDto.fromJson(Map<String, dynamic> json) =>
_$GameDtoFromJson(json);
const GameDto._();
Game toDomain() => Game(
id: id ?? '',
name: name ?? '',
type: type ?? '',
isActive: isActive ?? false,
metadata: metadata ?? {},
prizes: prizes?.map((e) => e.toDomain()).toList() ?? [],
createdAt: createdAt ?? '',
updatedAt: updatedAt ?? '',
);
}
@@ -0,0 +1,27 @@
part of '../game_dtos.dart';
@freezed
class GamePrizeDto with _$GamePrizeDto {
const factory GamePrizeDto({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'game_id') String? gameId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
}) = _GamePrizeDto;
factory GamePrizeDto.fromJson(Map<String, dynamic> json) =>
_$GamePrizeDtoFromJson(json);
const GamePrizeDto._();
GamePrize toDomain() => GamePrize(
id: id ?? '',
gameId: gameId ?? '',
name: name ?? '',
metadata: metadata ?? {},
createdAt: createdAt ?? '',
updatedAt: updatedAt ?? '',
);
}
+9
View File
@@ -0,0 +1,9 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/game/game.dart';
part 'game_dtos.freezed.dart';
part 'game_dtos.g.dart';
part 'dto/game_dto.dart';
part 'dto/game_prize_dto.dart';
@@ -0,0 +1,671 @@
// 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 'game_dtos.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',
);
GameDto _$GameDtoFromJson(Map<String, dynamic> json) {
return _GameDto.fromJson(json);
}
/// @nodoc
mixin _$GameDto {
@JsonKey(name: 'id')
String? get id => throw _privateConstructorUsedError;
@JsonKey(name: 'name')
String? get name => throw _privateConstructorUsedError;
@JsonKey(name: 'type')
String? get type => throw _privateConstructorUsedError;
@JsonKey(name: 'is_active')
bool? get isActive => throw _privateConstructorUsedError;
@JsonKey(name: 'metadata')
Map<String, dynamic>? get metadata => throw _privateConstructorUsedError;
@JsonKey(name: 'prizes')
List<GamePrizeDto>? get prizes => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
String? get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
String? get updatedAt => throw _privateConstructorUsedError;
/// Serializes this GameDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of GameDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GameDtoCopyWith<GameDto> get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $GameDtoCopyWith<$Res> {
factory $GameDtoCopyWith(GameDto value, $Res Function(GameDto) then) =
_$GameDtoCopyWithImpl<$Res, GameDto>;
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'type') String? type,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
@JsonKey(name: 'prizes') List<GamePrizeDto>? prizes,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class _$GameDtoCopyWithImpl<$Res, $Val extends GameDto>
implements $GameDtoCopyWith<$Res> {
_$GameDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of GameDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? name = freezed,
Object? type = freezed,
Object? isActive = freezed,
Object? metadata = freezed,
Object? prizes = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
type: freezed == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
metadata: freezed == metadata
? _value.metadata
: metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
prizes: freezed == prizes
? _value.prizes
: prizes // ignore: cast_nullable_to_non_nullable
as List<GamePrizeDto>?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$GameDtoImplCopyWith<$Res> implements $GameDtoCopyWith<$Res> {
factory _$$GameDtoImplCopyWith(
_$GameDtoImpl value,
$Res Function(_$GameDtoImpl) then,
) = __$$GameDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'type') String? type,
@JsonKey(name: 'is_active') bool? isActive,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
@JsonKey(name: 'prizes') List<GamePrizeDto>? prizes,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class __$$GameDtoImplCopyWithImpl<$Res>
extends _$GameDtoCopyWithImpl<$Res, _$GameDtoImpl>
implements _$$GameDtoImplCopyWith<$Res> {
__$$GameDtoImplCopyWithImpl(
_$GameDtoImpl _value,
$Res Function(_$GameDtoImpl) _then,
) : super(_value, _then);
/// Create a copy of GameDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? name = freezed,
Object? type = freezed,
Object? isActive = freezed,
Object? metadata = freezed,
Object? prizes = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_$GameDtoImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
type: freezed == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as String?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
metadata: freezed == metadata
? _value._metadata
: metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
prizes: freezed == prizes
? _value._prizes
: prizes // ignore: cast_nullable_to_non_nullable
as List<GamePrizeDto>?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$GameDtoImpl extends _GameDto {
const _$GameDtoImpl({
@JsonKey(name: 'id') this.id,
@JsonKey(name: 'name') this.name,
@JsonKey(name: 'type') this.type,
@JsonKey(name: 'is_active') this.isActive,
@JsonKey(name: 'metadata') final Map<String, dynamic>? metadata,
@JsonKey(name: 'prizes') final List<GamePrizeDto>? prizes,
@JsonKey(name: 'created_at') this.createdAt,
@JsonKey(name: 'updated_at') this.updatedAt,
}) : _metadata = metadata,
_prizes = prizes,
super._();
factory _$GameDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$GameDtoImplFromJson(json);
@override
@JsonKey(name: 'id')
final String? id;
@override
@JsonKey(name: 'name')
final String? name;
@override
@JsonKey(name: 'type')
final String? type;
@override
@JsonKey(name: 'is_active')
final bool? isActive;
final Map<String, dynamic>? _metadata;
@override
@JsonKey(name: 'metadata')
Map<String, dynamic>? get metadata {
final value = _metadata;
if (value == null) return null;
if (_metadata is EqualUnmodifiableMapView) return _metadata;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
final List<GamePrizeDto>? _prizes;
@override
@JsonKey(name: 'prizes')
List<GamePrizeDto>? get prizes {
final value = _prizes;
if (value == null) return null;
if (_prizes is EqualUnmodifiableListView) return _prizes;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
@override
@JsonKey(name: 'created_at')
final String? createdAt;
@override
@JsonKey(name: 'updated_at')
final String? updatedAt;
@override
String toString() {
return 'GameDto(id: $id, name: $name, type: $type, isActive: $isActive, metadata: $metadata, prizes: $prizes, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GameDtoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.type, type) || other.type == type) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
const DeepCollectionEquality().equals(other._metadata, _metadata) &&
const DeepCollectionEquality().equals(other._prizes, _prizes) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
name,
type,
isActive,
const DeepCollectionEquality().hash(_metadata),
const DeepCollectionEquality().hash(_prizes),
createdAt,
updatedAt,
);
/// Create a copy of GameDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GameDtoImplCopyWith<_$GameDtoImpl> get copyWith =>
__$$GameDtoImplCopyWithImpl<_$GameDtoImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GameDtoImplToJson(this);
}
}
abstract class _GameDto extends GameDto {
const factory _GameDto({
@JsonKey(name: 'id') final String? id,
@JsonKey(name: 'name') final String? name,
@JsonKey(name: 'type') final String? type,
@JsonKey(name: 'is_active') final bool? isActive,
@JsonKey(name: 'metadata') final Map<String, dynamic>? metadata,
@JsonKey(name: 'prizes') final List<GamePrizeDto>? prizes,
@JsonKey(name: 'created_at') final String? createdAt,
@JsonKey(name: 'updated_at') final String? updatedAt,
}) = _$GameDtoImpl;
const _GameDto._() : super._();
factory _GameDto.fromJson(Map<String, dynamic> json) = _$GameDtoImpl.fromJson;
@override
@JsonKey(name: 'id')
String? get id;
@override
@JsonKey(name: 'name')
String? get name;
@override
@JsonKey(name: 'type')
String? get type;
@override
@JsonKey(name: 'is_active')
bool? get isActive;
@override
@JsonKey(name: 'metadata')
Map<String, dynamic>? get metadata;
@override
@JsonKey(name: 'prizes')
List<GamePrizeDto>? get prizes;
@override
@JsonKey(name: 'created_at')
String? get createdAt;
@override
@JsonKey(name: 'updated_at')
String? get updatedAt;
/// Create a copy of GameDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GameDtoImplCopyWith<_$GameDtoImpl> get copyWith =>
throw _privateConstructorUsedError;
}
GamePrizeDto _$GamePrizeDtoFromJson(Map<String, dynamic> json) {
return _GamePrizeDto.fromJson(json);
}
/// @nodoc
mixin _$GamePrizeDto {
@JsonKey(name: 'id')
String? get id => throw _privateConstructorUsedError;
@JsonKey(name: 'game_id')
String? get gameId => throw _privateConstructorUsedError;
@JsonKey(name: 'name')
String? get name => throw _privateConstructorUsedError;
@JsonKey(name: 'metadata')
Map<String, dynamic>? get metadata => throw _privateConstructorUsedError;
@JsonKey(name: 'created_at')
String? get createdAt => throw _privateConstructorUsedError;
@JsonKey(name: 'updated_at')
String? get updatedAt => throw _privateConstructorUsedError;
/// Serializes this GamePrizeDto to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of GamePrizeDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$GamePrizeDtoCopyWith<GamePrizeDto> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $GamePrizeDtoCopyWith<$Res> {
factory $GamePrizeDtoCopyWith(
GamePrizeDto value,
$Res Function(GamePrizeDto) then,
) = _$GamePrizeDtoCopyWithImpl<$Res, GamePrizeDto>;
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'game_id') String? gameId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class _$GamePrizeDtoCopyWithImpl<$Res, $Val extends GamePrizeDto>
implements $GamePrizeDtoCopyWith<$Res> {
_$GamePrizeDtoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of GamePrizeDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? gameId = freezed,
Object? name = freezed,
Object? metadata = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_value.copyWith(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
gameId: freezed == gameId
? _value.gameId
: gameId // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
metadata: freezed == metadata
? _value.metadata
: metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$GamePrizeDtoImplCopyWith<$Res>
implements $GamePrizeDtoCopyWith<$Res> {
factory _$$GamePrizeDtoImplCopyWith(
_$GamePrizeDtoImpl value,
$Res Function(_$GamePrizeDtoImpl) then,
) = __$$GamePrizeDtoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
@JsonKey(name: 'id') String? id,
@JsonKey(name: 'game_id') String? gameId,
@JsonKey(name: 'name') String? name,
@JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
@JsonKey(name: 'created_at') String? createdAt,
@JsonKey(name: 'updated_at') String? updatedAt,
});
}
/// @nodoc
class __$$GamePrizeDtoImplCopyWithImpl<$Res>
extends _$GamePrizeDtoCopyWithImpl<$Res, _$GamePrizeDtoImpl>
implements _$$GamePrizeDtoImplCopyWith<$Res> {
__$$GamePrizeDtoImplCopyWithImpl(
_$GamePrizeDtoImpl _value,
$Res Function(_$GamePrizeDtoImpl) _then,
) : super(_value, _then);
/// Create a copy of GamePrizeDto
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = freezed,
Object? gameId = freezed,
Object? name = freezed,
Object? metadata = freezed,
Object? createdAt = freezed,
Object? updatedAt = freezed,
}) {
return _then(
_$GamePrizeDtoImpl(
id: freezed == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String?,
gameId: freezed == gameId
? _value.gameId
: gameId // ignore: cast_nullable_to_non_nullable
as String?,
name: freezed == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String?,
metadata: freezed == metadata
? _value._metadata
: metadata // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
createdAt: freezed == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as String?,
updatedAt: freezed == updatedAt
? _value.updatedAt
: updatedAt // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
@JsonSerializable()
class _$GamePrizeDtoImpl extends _GamePrizeDto {
const _$GamePrizeDtoImpl({
@JsonKey(name: 'id') this.id,
@JsonKey(name: 'game_id') this.gameId,
@JsonKey(name: 'name') this.name,
@JsonKey(name: 'metadata') final Map<String, dynamic>? metadata,
@JsonKey(name: 'created_at') this.createdAt,
@JsonKey(name: 'updated_at') this.updatedAt,
}) : _metadata = metadata,
super._();
factory _$GamePrizeDtoImpl.fromJson(Map<String, dynamic> json) =>
_$$GamePrizeDtoImplFromJson(json);
@override
@JsonKey(name: 'id')
final String? id;
@override
@JsonKey(name: 'game_id')
final String? gameId;
@override
@JsonKey(name: 'name')
final String? name;
final Map<String, dynamic>? _metadata;
@override
@JsonKey(name: 'metadata')
Map<String, dynamic>? get metadata {
final value = _metadata;
if (value == null) return null;
if (_metadata is EqualUnmodifiableMapView) return _metadata;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}
@override
@JsonKey(name: 'created_at')
final String? createdAt;
@override
@JsonKey(name: 'updated_at')
final String? updatedAt;
@override
String toString() {
return 'GamePrizeDto(id: $id, gameId: $gameId, name: $name, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$GamePrizeDtoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.gameId, gameId) || other.gameId == gameId) &&
(identical(other.name, name) || other.name == name) &&
const DeepCollectionEquality().equals(other._metadata, _metadata) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.updatedAt, updatedAt) ||
other.updatedAt == updatedAt));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType,
id,
gameId,
name,
const DeepCollectionEquality().hash(_metadata),
createdAt,
updatedAt,
);
/// Create a copy of GamePrizeDto
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GamePrizeDtoImplCopyWith<_$GamePrizeDtoImpl> get copyWith =>
__$$GamePrizeDtoImplCopyWithImpl<_$GamePrizeDtoImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$GamePrizeDtoImplToJson(this);
}
}
abstract class _GamePrizeDto extends GamePrizeDto {
const factory _GamePrizeDto({
@JsonKey(name: 'id') final String? id,
@JsonKey(name: 'game_id') final String? gameId,
@JsonKey(name: 'name') final String? name,
@JsonKey(name: 'metadata') final Map<String, dynamic>? metadata,
@JsonKey(name: 'created_at') final String? createdAt,
@JsonKey(name: 'updated_at') final String? updatedAt,
}) = _$GamePrizeDtoImpl;
const _GamePrizeDto._() : super._();
factory _GamePrizeDto.fromJson(Map<String, dynamic> json) =
_$GamePrizeDtoImpl.fromJson;
@override
@JsonKey(name: 'id')
String? get id;
@override
@JsonKey(name: 'game_id')
String? get gameId;
@override
@JsonKey(name: 'name')
String? get name;
@override
@JsonKey(name: 'metadata')
Map<String, dynamic>? get metadata;
@override
@JsonKey(name: 'created_at')
String? get createdAt;
@override
@JsonKey(name: 'updated_at')
String? get updatedAt;
/// Create a copy of GamePrizeDto
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GamePrizeDtoImplCopyWith<_$GamePrizeDtoImpl> get copyWith =>
throw _privateConstructorUsedError;
}
+53
View File
@@ -0,0 +1,53 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'game_dtos.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$GameDtoImpl _$$GameDtoImplFromJson(Map<String, dynamic> json) =>
_$GameDtoImpl(
id: json['id'] as String?,
name: json['name'] as String?,
type: json['type'] as String?,
isActive: json['is_active'] as bool?,
metadata: json['metadata'] as Map<String, dynamic>?,
prizes: (json['prizes'] as List<dynamic>?)
?.map((e) => GamePrizeDto.fromJson(e as Map<String, dynamic>))
.toList(),
createdAt: json['created_at'] as String?,
updatedAt: json['updated_at'] as String?,
);
Map<String, dynamic> _$$GameDtoImplToJson(_$GameDtoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'type': instance.type,
'is_active': instance.isActive,
'metadata': instance.metadata,
'prizes': instance.prizes,
'created_at': instance.createdAt,
'updated_at': instance.updatedAt,
};
_$GamePrizeDtoImpl _$$GamePrizeDtoImplFromJson(Map<String, dynamic> json) =>
_$GamePrizeDtoImpl(
id: json['id'] as String?,
gameId: json['game_id'] as String?,
name: json['name'] as String?,
metadata: json['metadata'] as Map<String, dynamic>?,
createdAt: json['created_at'] as String?,
updatedAt: json['updated_at'] as String?,
);
Map<String, dynamic> _$$GamePrizeDtoImplToJson(_$GamePrizeDtoImpl instance) =>
<String, dynamic>{
'id': instance.id,
'game_id': instance.gameId,
'name': instance.name,
'metadata': instance.metadata,
'created_at': instance.createdAt,
'updated_at': instance.updatedAt,
};
@@ -0,0 +1,34 @@
import 'dart:developer';
import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/game/game.dart';
import '../datasources/remote_data_provider.dart';
@Injectable(as: IGameRepository)
class GameRepository implements IGameRepository {
final GameRemoteDataProvider _remoteDataProvider;
final String _logName = 'GameRepository';
GameRepository(this._remoteDataProvider);
@override
Future<Either<GameFailure, Game>> ferrisWheel() async {
try {
final result = await _remoteDataProvider.ferrisWheel();
if (result.hasError) {
return left(result.error!);
}
final data = result.data!.toDomain();
return right(data);
} catch (e, s) {
log('ferrisWheel', name: _logName, error: e, stackTrace: s);
return left(const GameFailure.unexpectedError());
}
}
}
+72 -3
View File
@@ -11,10 +11,25 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:connectivity_plus/connectivity_plus.dart' as _i895;
import 'package:dio/dio.dart' as _i361;
import 'package:enaklo/application/auth/auth_bloc.dart' as _i771;
import 'package:enaklo/application/auth/check_phone_form/check_phone_form_bloc.dart'
as _i869;
import 'package:enaklo/application/auth/login_form/login_form_bloc.dart'
as _i510;
import 'package:enaklo/application/auth/logout_form/logout_form_bloc.dart'
as _i216;
import 'package:enaklo/application/auth/register_form/register_form_bloc.dart'
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/application/customer/customer_point_loader/customer_point_loader_bloc.dart'
as _i497;
import 'package:enaklo/application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.dart'
as _i1013;
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_connectivity.dart' as _i644;
@@ -22,11 +37,23 @@ import 'package:enaklo/common/di/di_dio.dart' as _i842;
import 'package:enaklo/common/di/di_shared_preferences.dart' as _i672;
import 'package:enaklo/common/network/network_client.dart' as _i109;
import 'package:enaklo/domain/auth/auth.dart' as _i995;
import 'package:enaklo/domain/customer/customer.dart' as _i898;
import 'package:enaklo/domain/game/game.dart' as _i96;
import 'package:enaklo/env.dart' as _i372;
import 'package:enaklo/infrastructure/auth/datasources/local_data_provider.dart'
as _i1003;
import 'package:enaklo/infrastructure/auth/datasources/remote_data_provider.dart'
as _i818;
import 'package:enaklo/infrastructure/auth/repositories/auth_repository.dart'
as _i879;
import 'package:enaklo/infrastructure/customer/datasources/remote_data_provider.dart'
as _i89;
import 'package:enaklo/infrastructure/customer/repositories/customer_repository.dart'
as _i118;
import 'package:enaklo/infrastructure/game/datasources/remote_data_provider.dart'
as _i143;
import 'package:enaklo/infrastructure/game/repositories/game_repository.dart'
as _i547;
import 'package:enaklo/presentation/router/app_router.dart' as _i698;
import 'package:get_it/get_it.dart' as _i174;
import 'package:injectable/injectable.dart' as _i526;
@@ -57,6 +84,9 @@ extension GetItInjectableX on _i174.GetIt {
() => _i109.NetworkClient(gh<_i895.Connectivity>()),
);
gh.factory<_i372.Env>(() => _i372.DevEnv(), registerFor: {_dev});
gh.factory<_i1003.AuthLocalDataProvider>(
() => _i1003.AuthLocalDataProvider(gh<_i460.SharedPreferences>()),
);
gh.factory<_i372.Env>(() => _i372.ProdEnv(), registerFor: {_prod});
gh.lazySingleton<_i842.ApiClient>(
() => _i842.ApiClient(gh<_i361.Dio>(), gh<_i372.Env>()),
@@ -64,14 +94,53 @@ extension GetItInjectableX on _i174.GetIt {
gh.factory<_i818.AuthRemoteDataProvider>(
() => _i818.AuthRemoteDataProvider(gh<_i842.ApiClient>()),
);
gh.factory<_i143.GameRemoteDataProvider>(
() => _i143.GameRemoteDataProvider(gh<_i842.ApiClient>()),
);
gh.factory<_i89.CustomerRemoteDataProvider>(
() => _i89.CustomerRemoteDataProvider(gh<_i842.ApiClient>()),
);
gh.factory<_i96.IGameRepository>(
() => _i547.GameRepository(gh<_i143.GameRemoteDataProvider>()),
);
gh.factory<_i1013.FerrisWheelLoaderBloc>(
() => _i1013.FerrisWheelLoaderBloc(gh<_i96.IGameRepository>()),
);
gh.factory<_i995.IAuthRepository>(
() => _i879.AuthRepository(gh<_i818.AuthRemoteDataProvider>()),
() => _i879.AuthRepository(
gh<_i818.AuthRemoteDataProvider>(),
gh<_i1003.AuthLocalDataProvider>(),
),
);
gh.factory<_i627.ResendFormBloc>(
() => _i627.ResendFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i174.SetPasswordFormBloc>(
() => _i174.SetPasswordFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i260.RegisterFormBloc>(
() => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i869.CheckPhoneFormBloc>(
() => _i869.CheckPhoneFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i260.RegisterFormBloc>(
() => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()),
gh.factory<_i771.AuthBloc>(
() => _i771.AuthBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i521.VerifyFormBloc>(
() => _i521.VerifyFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i216.LogoutFormBloc>(
() => _i216.LogoutFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i898.ICustomerRepository>(
() => _i118.CustomerRepository(gh<_i89.CustomerRemoteDataProvider>()),
);
gh.factory<_i510.LoginFormBloc>(
() => _i510.LoginFormBloc(gh<_i995.IAuthRepository>()),
);
gh.factory<_i497.CustomerPointLoaderBloc>(
() => _i497.CustomerPointLoaderBloc(gh<_i898.ICustomerRepository>()),
);
return this;
}
+2
View File
@@ -2,12 +2,14 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:injectable/injectable.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'injection.dart';
import 'presentation/app_widget.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initializeDateFormatting('id_ID', null);
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
+17 -6
View File
@@ -1,5 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../application/auth/auth_bloc.dart';
import '../application/auth/logout_form/logout_form_bloc.dart';
import '../application/customer/customer_point_loader/customer_point_loader_bloc.dart';
import '../common/theme/theme.dart';
import '../common/constant/app_constant.dart';
import '../injection.dart';
@@ -18,12 +22,19 @@ class _AppWidgetState extends State<AppWidget> {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
title: AppConstant.appName,
theme: ThemeApp.theme,
routerConfig: _appRouter.config(
navigatorObservers: () => <NavigatorObserver>[AppRouteObserver()],
return MultiBlocProvider(
providers: [
BlocProvider(create: (context) => getIt<AuthBloc>()),
BlocProvider(create: (context) => getIt<LogoutFormBloc>()),
BlocProvider(create: (context) => getIt<CustomerPointLoaderBloc>()),
],
child: MaterialApp.router(
debugShowCheckedModeBanner: false,
title: AppConstant.appName,
theme: ThemeApp.theme,
routerConfig: _appRouter.config(
navigatorObservers: () => <NavigatorObserver>[AppRouteObserver()],
),
),
);
}
@@ -11,6 +11,52 @@
import 'package:flutter/widgets.dart';
class $AssetsAudioGen {
const $AssetsAudioGen();
/// File path: assets/audio/bell_ding.mp3
String get bellDing => 'assets/audio/bell_ding.mp3';
/// File path: assets/audio/big_win.mp3
String get bigWin => 'assets/audio/big_win.mp3';
/// File path: assets/audio/button_tap.mp3
String get buttonTap => 'assets/audio/button_tap.mp3';
/// File path: assets/audio/carnaval_main_theme.mp3
String get carnavalMainTheme => 'assets/audio/carnaval_main_theme.mp3';
/// File path: assets/audio/token_sound.mp3
String get tokenSound => 'assets/audio/token_sound.mp3';
/// File path: assets/audio/wheel_spin.mp3
String get wheelSpin => 'assets/audio/wheel_spin.mp3';
/// List of all assets
List<String> get values => [
bellDing,
bigWin,
buttonTap,
carnavalMainTheme,
tokenSound,
wheelSpin,
];
}
class $AssetsIconsGen {
const $AssetsIconsGen();
/// File path: assets/icons/dine_in.png
AssetGenImage get dineIn => const AssetGenImage('assets/icons/dine_in.png');
/// File path: assets/icons/takeaway.png
AssetGenImage get takeaway =>
const AssetGenImage('assets/icons/takeaway.png');
/// List of all assets
List<AssetGenImage> get values => [dineIn, takeaway];
}
class $AssetsImagesGen {
const $AssetsImagesGen();
@@ -64,6 +110,8 @@ class $AssetsImagesGen {
class Assets {
const Assets._();
static const $AssetsAudioGen audio = $AssetsAudioGen();
static const $AssetsIconsGen icons = $AssetsIconsGen();
static const $AssetsImagesGen images = $AssetsImagesGen();
}

Some files were not shown because too many files have changed in this diff Show More