feat: integrate enakgame and voucher
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/wallet/wallet.dart';
|
||||
|
||||
part 'voucher_redemption_loader_event.dart';
|
||||
part 'voucher_redemption_loader_state.dart';
|
||||
part 'voucher_redemption_loader_bloc.freezed.dart';
|
||||
|
||||
/// "Voucher saya" (§9.3).
|
||||
@injectable
|
||||
class VoucherRedemptionLoaderBloc
|
||||
extends Bloc<VoucherRedemptionLoaderEvent, VoucherRedemptionLoaderState> {
|
||||
final IVoucherRepository _repository;
|
||||
|
||||
static const int _limit = 20;
|
||||
|
||||
VoucherRedemptionLoaderBloc(this._repository)
|
||||
: super(VoucherRedemptionLoaderState.initial()) {
|
||||
on<VoucherRedemptionLoaderEvent>(_onVoucherRedemptionLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onVoucherRedemptionLoaderEvent(
|
||||
VoucherRedemptionLoaderEvent event,
|
||||
Emitter<VoucherRedemptionLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
refreshed: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _repository.getRedemptions(page: 1, limit: _limit);
|
||||
|
||||
emit(
|
||||
result
|
||||
.fold(
|
||||
(f) => state.copyWith(failureOption: optionOf(f)),
|
||||
(page) => state.copyWith(
|
||||
items: page.items,
|
||||
page: page.page,
|
||||
totalPages: page.totalPages,
|
||||
hasLoaded: true,
|
||||
),
|
||||
)
|
||||
.copyWith(isFetching: false),
|
||||
);
|
||||
},
|
||||
loadedMore: (e) async {
|
||||
if (state.isFetching || state.isLoadingMore || !state.hasMore) return;
|
||||
emit(state.copyWith(isLoadingMore: true, failureOption: none()));
|
||||
|
||||
final result = await _repository.getRedemptions(
|
||||
page: state.page + 1,
|
||||
limit: _limit,
|
||||
);
|
||||
|
||||
emit(
|
||||
result
|
||||
.fold(
|
||||
(f) => state.copyWith(failureOption: optionOf(f)),
|
||||
(page) => state.copyWith(
|
||||
items: [...state.items, ...page.items],
|
||||
page: page.page,
|
||||
totalPages: page.totalPages,
|
||||
),
|
||||
)
|
||||
.copyWith(isLoadingMore: false),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+533
@@ -0,0 +1,533 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package
|
||||
// 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 'voucher_redemption_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$VoucherRedemptionLoaderEvent {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is VoucherRedemptionLoaderEvent);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VoucherRedemptionLoaderEvent()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class $VoucherRedemptionLoaderEventCopyWith<$Res> {
|
||||
$VoucherRedemptionLoaderEventCopyWith(VoucherRedemptionLoaderEvent _, $Res Function(VoucherRedemptionLoaderEvent) __);
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [VoucherRedemptionLoaderEvent].
|
||||
extension VoucherRedemptionLoaderEventPatterns on VoucherRedemptionLoaderEvent {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Refreshed value)? refreshed,TResult Function( _LoadedMore value)? loadedMore,required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Refreshed() when refreshed != null:
|
||||
return refreshed(_that);case _LoadedMore() when loadedMore != null:
|
||||
return loadedMore(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Refreshed value) refreshed,required TResult Function( _LoadedMore value) loadedMore,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Refreshed():
|
||||
return refreshed(_that);case _LoadedMore():
|
||||
return loadedMore(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Refreshed value)? refreshed,TResult? Function( _LoadedMore value)? loadedMore,}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _Refreshed() when refreshed != null:
|
||||
return refreshed(_that);case _LoadedMore() when loadedMore != null:
|
||||
return loadedMore(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? refreshed,TResult Function()? loadedMore,required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Refreshed() when refreshed != null:
|
||||
return refreshed();case _LoadedMore() when loadedMore != null:
|
||||
return loadedMore();case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() refreshed,required TResult Function() loadedMore,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Refreshed():
|
||||
return refreshed();case _LoadedMore():
|
||||
return loadedMore();case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? refreshed,TResult? Function()? loadedMore,}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _Refreshed() when refreshed != null:
|
||||
return refreshed();case _LoadedMore() when loadedMore != null:
|
||||
return loadedMore();case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _Refreshed implements VoucherRedemptionLoaderEvent {
|
||||
const _Refreshed();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Refreshed);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VoucherRedemptionLoaderEvent.refreshed()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _LoadedMore implements VoucherRedemptionLoaderEvent {
|
||||
const _LoadedMore();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoadedMore);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VoucherRedemptionLoaderEvent.loadedMore()';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$VoucherRedemptionLoaderState {
|
||||
|
||||
List<VoucherRedemption> get items; int get page; int get totalPages; Option<WalletFailure> get failureOption; bool get isFetching; bool get isLoadingMore; bool get hasLoaded;
|
||||
/// Create a copy of VoucherRedemptionLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$VoucherRedemptionLoaderStateCopyWith<VoucherRedemptionLoaderState> get copyWith => _$VoucherRedemptionLoaderStateCopyWithImpl<VoucherRedemptionLoaderState>(this as VoucherRedemptionLoaderState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
final _this = this as VoucherRedemptionLoaderState;
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is VoucherRedemptionLoaderState&&const DeepCollectionEquality().equals(other.items, _this.items)&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.totalPages, _this.totalPages) || other.totalPages == _this.totalPages)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)&&(identical(other.isLoadingMore, _this.isLoadingMore) || other.isLoadingMore == _this.isLoadingMore)&&(identical(other.hasLoaded, _this.hasLoaded) || other.hasLoaded == _this.hasLoaded));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
final _this = this as VoucherRedemptionLoaderState;
|
||||
return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.items),_this.page,_this.totalPages,_this.failureOption,_this.isFetching,_this.isLoadingMore,_this.hasLoaded);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final _this = this as VoucherRedemptionLoaderState;
|
||||
return 'VoucherRedemptionLoaderState(items: ${_this.items}, page: ${_this.page}, totalPages: ${_this.totalPages}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching}, isLoadingMore: ${_this.isLoadingMore}, hasLoaded: ${_this.hasLoaded})';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $VoucherRedemptionLoaderStateCopyWith<$Res> {
|
||||
factory $VoucherRedemptionLoaderStateCopyWith(VoucherRedemptionLoaderState value, $Res Function(VoucherRedemptionLoaderState) _then) = _$VoucherRedemptionLoaderStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<VoucherRedemption> items, int page, int totalPages, Option<WalletFailure> failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$VoucherRedemptionLoaderStateCopyWithImpl<$Res>
|
||||
implements $VoucherRedemptionLoaderStateCopyWith<$Res> {
|
||||
_$VoucherRedemptionLoaderStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final VoucherRedemptionLoaderState _self;
|
||||
final $Res Function(VoucherRedemptionLoaderState) _then;
|
||||
|
||||
/// Create a copy of VoucherRedemptionLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? page = null,Object? totalPages = null,Object? failureOption = null,Object? isFetching = null,Object? isLoadingMore = null,Object? hasLoaded = null,}) {
|
||||
return _then(VoucherRedemptionLoaderState(
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<VoucherRedemption>,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable
|
||||
as int,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<WalletFailure>,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [VoucherRedemptionLoaderState].
|
||||
extension VoucherRedemptionLoaderStatePatterns on VoucherRedemptionLoaderState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _VoucherRedemptionLoaderState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _VoucherRedemptionLoaderState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _VoucherRedemptionLoaderState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _VoucherRedemptionLoaderState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _VoucherRedemptionLoaderState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _VoucherRedemptionLoaderState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<VoucherRedemption> items, int page, int totalPages, Option<WalletFailure> failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _VoucherRedemptionLoaderState() when $default != null:
|
||||
return $default(_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore,_that.hasLoaded);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<VoucherRedemption> items, int page, int totalPages, Option<WalletFailure> failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _VoucherRedemptionLoaderState():
|
||||
return $default(_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore,_that.hasLoaded);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<VoucherRedemption> items, int page, int totalPages, Option<WalletFailure> failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _VoucherRedemptionLoaderState() when $default != null:
|
||||
return $default(_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore,_that.hasLoaded);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _VoucherRedemptionLoaderState extends VoucherRedemptionLoaderState {
|
||||
const _VoucherRedemptionLoaderState({required List<VoucherRedemption> items, required this.page, required this.totalPages, required this.failureOption, this.isFetching = false, this.isLoadingMore = false, this.hasLoaded = false}): _items = items,super._();
|
||||
|
||||
|
||||
final List<VoucherRedemption> _items;
|
||||
@override List<VoucherRedemption> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
@override final int page;
|
||||
@override final int totalPages;
|
||||
@override final Option<WalletFailure> failureOption;
|
||||
@override@JsonKey() final bool isFetching;
|
||||
@override@JsonKey() final bool isLoadingMore;
|
||||
@override@JsonKey() final bool hasLoaded;
|
||||
|
||||
/// Create a copy of VoucherRedemptionLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$VoucherRedemptionLoaderStateCopyWith<_VoucherRedemptionLoaderState> get copyWith => __$VoucherRedemptionLoaderStateCopyWithImpl<_VoucherRedemptionLoaderState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _VoucherRedemptionLoaderState&&const DeepCollectionEquality().equals(other.items, _items)&&(identical(other.page, page) || other.page == page)&&(identical(other.totalPages, totalPages) || other.totalPages == totalPages)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.hasLoaded, hasLoaded) || other.hasLoaded == hasLoaded));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),page,totalPages,failureOption,isFetching,isLoadingMore,hasLoaded);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'VoucherRedemptionLoaderState(items: $items, page: $page, totalPages: $totalPages, failureOption: $failureOption, isFetching: $isFetching, isLoadingMore: $isLoadingMore, hasLoaded: $hasLoaded)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$VoucherRedemptionLoaderStateCopyWith<$Res> implements $VoucherRedemptionLoaderStateCopyWith<$Res> {
|
||||
factory _$VoucherRedemptionLoaderStateCopyWith(_VoucherRedemptionLoaderState value, $Res Function(_VoucherRedemptionLoaderState) _then) = __$VoucherRedemptionLoaderStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<VoucherRedemption> items, int page, int totalPages, Option<WalletFailure> failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$VoucherRedemptionLoaderStateCopyWithImpl<$Res>
|
||||
implements _$VoucherRedemptionLoaderStateCopyWith<$Res> {
|
||||
__$VoucherRedemptionLoaderStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _VoucherRedemptionLoaderState _self;
|
||||
final $Res Function(_VoucherRedemptionLoaderState) _then;
|
||||
|
||||
/// Create a copy of VoucherRedemptionLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? page = null,Object? totalPages = null,Object? failureOption = null,Object? isFetching = null,Object? isLoadingMore = null,Object? hasLoaded = null,}) {
|
||||
return _then(_VoucherRedemptionLoaderState(
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<VoucherRedemption>,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable
|
||||
as int,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<WalletFailure>,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
part of 'voucher_redemption_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class VoucherRedemptionLoaderEvent
|
||||
with _$VoucherRedemptionLoaderEvent {
|
||||
/// Muat ulang dari halaman pertama.
|
||||
const factory VoucherRedemptionLoaderEvent.refreshed() = _Refreshed;
|
||||
|
||||
const factory VoucherRedemptionLoaderEvent.loadedMore() = _LoadedMore;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
part of 'voucher_redemption_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
abstract class VoucherRedemptionLoaderState
|
||||
with _$VoucherRedemptionLoaderState {
|
||||
const VoucherRedemptionLoaderState._();
|
||||
|
||||
const factory VoucherRedemptionLoaderState({
|
||||
required List<VoucherRedemption> items,
|
||||
required int page,
|
||||
required int totalPages,
|
||||
required Option<WalletFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
@Default(false) bool isLoadingMore,
|
||||
@Default(false) bool hasLoaded,
|
||||
}) = _VoucherRedemptionLoaderState;
|
||||
|
||||
factory VoucherRedemptionLoaderState.initial() =>
|
||||
VoucherRedemptionLoaderState(
|
||||
items: const [],
|
||||
page: 0,
|
||||
totalPages: 0,
|
||||
failureOption: none(),
|
||||
);
|
||||
|
||||
bool get hasMore => page < totalPages;
|
||||
}
|
||||
Reference in New Issue
Block a user