This commit is contained in:
+65
@@ -0,0 +1,65 @@
|
||||
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/analytic/analytic.dart';
|
||||
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
|
||||
|
||||
part 'profit_sharing_detail_loader_event.dart';
|
||||
part 'profit_sharing_detail_loader_state.dart';
|
||||
part 'profit_sharing_detail_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class ProfitSharingDetailLoaderBloc
|
||||
extends
|
||||
Bloc<ProfitSharingDetailLoaderEvent, ProfitSharingDetailLoaderState> {
|
||||
final IAnalyticRepository _repository;
|
||||
|
||||
ProfitSharingDetailLoaderBloc(this._repository)
|
||||
: super(ProfitSharingDetailLoaderState.initial()) {
|
||||
on<ProfitSharingDetailLoaderEvent>(_onProfitSharingDetailLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onProfitSharingDetailLoaderEvent(
|
||||
ProfitSharingDetailLoaderEvent event,
|
||||
Emitter<ProfitSharingDetailLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
expandedCategoryChanged: (e) async {
|
||||
final isSame = state.expandedCategoryId == e.categoryId;
|
||||
emit(state.copyWith(expandedCategoryId: isSame ? '' : e.categoryId));
|
||||
},
|
||||
fetched: (e) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: true,
|
||||
failureOption: none(),
|
||||
parentCategoryId: e.parentCategoryId,
|
||||
dateFrom: e.dateFrom,
|
||||
dateTo: e.dateTo,
|
||||
),
|
||||
);
|
||||
|
||||
final result = await _repository.getProfitSharingDetail(
|
||||
parentCategoryId: e.parentCategoryId,
|
||||
dateFrom: e.dateFrom,
|
||||
dateTo: e.dateTo,
|
||||
);
|
||||
|
||||
final newState = result.fold(
|
||||
(f) => state.copyWith(failureOption: optionOf(f)),
|
||||
(detail) => state.copyWith(
|
||||
detail: detail,
|
||||
// Sub kategori pertama langsung terbuka supaya produknya kelihatan.
|
||||
expandedCategoryId: detail.categories.isEmpty
|
||||
? ''
|
||||
: detail.categories.first.categoryId,
|
||||
),
|
||||
);
|
||||
|
||||
emit(newState.copyWith(isFetching: false));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+772
@@ -0,0 +1,772 @@
|
||||
// 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 'profit_sharing_detail_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 _$ProfitSharingDetailLoaderEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)
|
||||
fetched,
|
||||
required TResult Function(String categoryId) expandedCategoryChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)?
|
||||
fetched,
|
||||
TResult? Function(String categoryId)? expandedCategoryChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)?
|
||||
fetched,
|
||||
TResult Function(String categoryId)? expandedCategoryChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
required TResult Function(_ExpandedCategoryChanged value)
|
||||
expandedCategoryChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
TResult? Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
TResult Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitSharingDetailLoaderEventCopyWith<$Res> {
|
||||
factory $ProfitSharingDetailLoaderEventCopyWith(
|
||||
ProfitSharingDetailLoaderEvent value,
|
||||
$Res Function(ProfitSharingDetailLoaderEvent) then,
|
||||
) =
|
||||
_$ProfitSharingDetailLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
ProfitSharingDetailLoaderEvent
|
||||
>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitSharingDetailLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProfitSharingDetailLoaderEvent
|
||||
>
|
||||
implements $ProfitSharingDetailLoaderEventCopyWith<$Res> {
|
||||
_$ProfitSharingDetailLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// 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>;
|
||||
@useResult
|
||||
$Res call({String parentCategoryId, DateTime dateFrom, DateTime dateTo});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$ProfitSharingDetailLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? parentCategoryId = null,
|
||||
Object? dateFrom = null,
|
||||
Object? dateTo = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
parentCategoryId: null == parentCategoryId
|
||||
? _value.parentCategoryId
|
||||
: parentCategoryId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
dateFrom: null == dateFrom
|
||||
? _value.dateFrom
|
||||
: dateFrom // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
dateTo: null == dateTo
|
||||
? _value.dateTo
|
||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({
|
||||
required this.parentCategoryId,
|
||||
required this.dateFrom,
|
||||
required this.dateTo,
|
||||
});
|
||||
|
||||
@override
|
||||
final String parentCategoryId;
|
||||
@override
|
||||
final DateTime dateFrom;
|
||||
@override
|
||||
final DateTime dateTo;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingDetailLoaderEvent.fetched(parentCategoryId: $parentCategoryId, dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.parentCategoryId, parentCategoryId) ||
|
||||
other.parentCategoryId == parentCategoryId) &&
|
||||
(identical(other.dateFrom, dateFrom) ||
|
||||
other.dateFrom == dateFrom) &&
|
||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, parentCategoryId, dateFrom, dateTo);
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)
|
||||
fetched,
|
||||
required TResult Function(String categoryId) expandedCategoryChanged,
|
||||
}) {
|
||||
return fetched(parentCategoryId, dateFrom, dateTo);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)?
|
||||
fetched,
|
||||
TResult? Function(String categoryId)? expandedCategoryChanged,
|
||||
}) {
|
||||
return fetched?.call(parentCategoryId, dateFrom, dateTo);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)?
|
||||
fetched,
|
||||
TResult Function(String categoryId)? expandedCategoryChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(parentCategoryId, dateFrom, dateTo);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
required TResult Function(_ExpandedCategoryChanged value)
|
||||
expandedCategoryChanged,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
TResult? Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
TResult Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements ProfitSharingDetailLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final String parentCategoryId,
|
||||
required final DateTime dateFrom,
|
||||
required final DateTime dateTo,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
String get parentCategoryId;
|
||||
DateTime get dateFrom;
|
||||
DateTime get dateTo;
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ExpandedCategoryChangedImplCopyWith<$Res> {
|
||||
factory _$$ExpandedCategoryChangedImplCopyWith(
|
||||
_$ExpandedCategoryChangedImpl value,
|
||||
$Res Function(_$ExpandedCategoryChangedImpl) then,
|
||||
) = __$$ExpandedCategoryChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String categoryId});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ExpandedCategoryChangedImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$ProfitSharingDetailLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
_$ExpandedCategoryChangedImpl
|
||||
>
|
||||
implements _$$ExpandedCategoryChangedImplCopyWith<$Res> {
|
||||
__$$ExpandedCategoryChangedImplCopyWithImpl(
|
||||
_$ExpandedCategoryChangedImpl _value,
|
||||
$Res Function(_$ExpandedCategoryChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? categoryId = null}) {
|
||||
return _then(
|
||||
_$ExpandedCategoryChangedImpl(
|
||||
null == categoryId
|
||||
? _value.categoryId
|
||||
: categoryId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ExpandedCategoryChangedImpl implements _ExpandedCategoryChanged {
|
||||
const _$ExpandedCategoryChangedImpl(this.categoryId);
|
||||
|
||||
@override
|
||||
final String categoryId;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingDetailLoaderEvent.expandedCategoryChanged(categoryId: $categoryId)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ExpandedCategoryChangedImpl &&
|
||||
(identical(other.categoryId, categoryId) ||
|
||||
other.categoryId == categoryId));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, categoryId);
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ExpandedCategoryChangedImplCopyWith<_$ExpandedCategoryChangedImpl>
|
||||
get copyWith =>
|
||||
__$$ExpandedCategoryChangedImplCopyWithImpl<
|
||||
_$ExpandedCategoryChangedImpl
|
||||
>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)
|
||||
fetched,
|
||||
required TResult Function(String categoryId) expandedCategoryChanged,
|
||||
}) {
|
||||
return expandedCategoryChanged(categoryId);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)?
|
||||
fetched,
|
||||
TResult? Function(String categoryId)? expandedCategoryChanged,
|
||||
}) {
|
||||
return expandedCategoryChanged?.call(categoryId);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(
|
||||
String parentCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
)?
|
||||
fetched,
|
||||
TResult Function(String categoryId)? expandedCategoryChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (expandedCategoryChanged != null) {
|
||||
return expandedCategoryChanged(categoryId);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
required TResult Function(_ExpandedCategoryChanged value)
|
||||
expandedCategoryChanged,
|
||||
}) {
|
||||
return expandedCategoryChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
TResult? Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
|
||||
}) {
|
||||
return expandedCategoryChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
TResult Function(_ExpandedCategoryChanged value)? expandedCategoryChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (expandedCategoryChanged != null) {
|
||||
return expandedCategoryChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ExpandedCategoryChanged
|
||||
implements ProfitSharingDetailLoaderEvent {
|
||||
const factory _ExpandedCategoryChanged(final String categoryId) =
|
||||
_$ExpandedCategoryChangedImpl;
|
||||
|
||||
String get categoryId;
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ExpandedCategoryChangedImplCopyWith<_$ExpandedCategoryChangedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProfitSharingDetailLoaderState {
|
||||
ProfitSharingDetail get detail => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
String get parentCategoryId => throw _privateConstructorUsedError;
|
||||
String get expandedCategoryId => throw _privateConstructorUsedError;
|
||||
DateTime get dateFrom => throw _privateConstructorUsedError;
|
||||
DateTime get dateTo => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProfitSharingDetailLoaderStateCopyWith<ProfitSharingDetailLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitSharingDetailLoaderStateCopyWith<$Res> {
|
||||
factory $ProfitSharingDetailLoaderStateCopyWith(
|
||||
ProfitSharingDetailLoaderState value,
|
||||
$Res Function(ProfitSharingDetailLoaderState) then,
|
||||
) =
|
||||
_$ProfitSharingDetailLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
ProfitSharingDetailLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
ProfitSharingDetail detail,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
String parentCategoryId,
|
||||
String expandedCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
});
|
||||
|
||||
$ProfitSharingDetailCopyWith<$Res> get detail;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitSharingDetailLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProfitSharingDetailLoaderState
|
||||
>
|
||||
implements $ProfitSharingDetailLoaderStateCopyWith<$Res> {
|
||||
_$ProfitSharingDetailLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? detail = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
Object? parentCategoryId = null,
|
||||
Object? expandedCategoryId = null,
|
||||
Object? dateFrom = null,
|
||||
Object? dateTo = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
detail: null == detail
|
||||
? _value.detail
|
||||
: detail // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharingDetail,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
parentCategoryId: null == parentCategoryId
|
||||
? _value.parentCategoryId
|
||||
: parentCategoryId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
expandedCategoryId: null == expandedCategoryId
|
||||
? _value.expandedCategoryId
|
||||
: expandedCategoryId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
dateFrom: null == dateFrom
|
||||
? _value.dateFrom
|
||||
: dateFrom // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
dateTo: null == dateTo
|
||||
? _value.dateTo
|
||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ProfitSharingDetailCopyWith<$Res> get detail {
|
||||
return $ProfitSharingDetailCopyWith<$Res>(_value.detail, (value) {
|
||||
return _then(_value.copyWith(detail: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProfitSharingDetailLoaderStateImplCopyWith<$Res>
|
||||
implements $ProfitSharingDetailLoaderStateCopyWith<$Res> {
|
||||
factory _$$ProfitSharingDetailLoaderStateImplCopyWith(
|
||||
_$ProfitSharingDetailLoaderStateImpl value,
|
||||
$Res Function(_$ProfitSharingDetailLoaderStateImpl) then,
|
||||
) = __$$ProfitSharingDetailLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
ProfitSharingDetail detail,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
String parentCategoryId,
|
||||
String expandedCategoryId,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
});
|
||||
|
||||
@override
|
||||
$ProfitSharingDetailCopyWith<$Res> get detail;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProfitSharingDetailLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$ProfitSharingDetailLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$ProfitSharingDetailLoaderStateImpl
|
||||
>
|
||||
implements _$$ProfitSharingDetailLoaderStateImplCopyWith<$Res> {
|
||||
__$$ProfitSharingDetailLoaderStateImplCopyWithImpl(
|
||||
_$ProfitSharingDetailLoaderStateImpl _value,
|
||||
$Res Function(_$ProfitSharingDetailLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? detail = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
Object? parentCategoryId = null,
|
||||
Object? expandedCategoryId = null,
|
||||
Object? dateFrom = null,
|
||||
Object? dateTo = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProfitSharingDetailLoaderStateImpl(
|
||||
detail: null == detail
|
||||
? _value.detail
|
||||
: detail // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharingDetail,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
parentCategoryId: null == parentCategoryId
|
||||
? _value.parentCategoryId
|
||||
: parentCategoryId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
expandedCategoryId: null == expandedCategoryId
|
||||
? _value.expandedCategoryId
|
||||
: expandedCategoryId // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
dateFrom: null == dateFrom
|
||||
? _value.dateFrom
|
||||
: dateFrom // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
dateTo: null == dateTo
|
||||
? _value.dateTo
|
||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProfitSharingDetailLoaderStateImpl
|
||||
extends _ProfitSharingDetailLoaderState {
|
||||
const _$ProfitSharingDetailLoaderStateImpl({
|
||||
required this.detail,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
this.parentCategoryId = '',
|
||||
this.expandedCategoryId = '',
|
||||
required this.dateFrom,
|
||||
required this.dateTo,
|
||||
}) : super._();
|
||||
|
||||
@override
|
||||
final ProfitSharingDetail detail;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String parentCategoryId;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String expandedCategoryId;
|
||||
@override
|
||||
final DateTime dateFrom;
|
||||
@override
|
||||
final DateTime dateTo;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingDetailLoaderState(detail: $detail, failureOption: $failureOption, isFetching: $isFetching, parentCategoryId: $parentCategoryId, expandedCategoryId: $expandedCategoryId, dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProfitSharingDetailLoaderStateImpl &&
|
||||
(identical(other.detail, detail) || other.detail == detail) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching) &&
|
||||
(identical(other.parentCategoryId, parentCategoryId) ||
|
||||
other.parentCategoryId == parentCategoryId) &&
|
||||
(identical(other.expandedCategoryId, expandedCategoryId) ||
|
||||
other.expandedCategoryId == expandedCategoryId) &&
|
||||
(identical(other.dateFrom, dateFrom) ||
|
||||
other.dateFrom == dateFrom) &&
|
||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
detail,
|
||||
failureOption,
|
||||
isFetching,
|
||||
parentCategoryId,
|
||||
expandedCategoryId,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
);
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProfitSharingDetailLoaderStateImplCopyWith<
|
||||
_$ProfitSharingDetailLoaderStateImpl
|
||||
>
|
||||
get copyWith =>
|
||||
__$$ProfitSharingDetailLoaderStateImplCopyWithImpl<
|
||||
_$ProfitSharingDetailLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ProfitSharingDetailLoaderState
|
||||
extends ProfitSharingDetailLoaderState {
|
||||
const factory _ProfitSharingDetailLoaderState({
|
||||
required final ProfitSharingDetail detail,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
final String parentCategoryId,
|
||||
final String expandedCategoryId,
|
||||
required final DateTime dateFrom,
|
||||
required final DateTime dateTo,
|
||||
}) = _$ProfitSharingDetailLoaderStateImpl;
|
||||
const _ProfitSharingDetailLoaderState._() : super._();
|
||||
|
||||
@override
|
||||
ProfitSharingDetail get detail;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
@override
|
||||
String get parentCategoryId;
|
||||
@override
|
||||
String get expandedCategoryId;
|
||||
@override
|
||||
DateTime get dateFrom;
|
||||
@override
|
||||
DateTime get dateTo;
|
||||
|
||||
/// Create a copy of ProfitSharingDetailLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ProfitSharingDetailLoaderStateImplCopyWith<
|
||||
_$ProfitSharingDetailLoaderStateImpl
|
||||
>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
part of 'profit_sharing_detail_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitSharingDetailLoaderEvent with _$ProfitSharingDetailLoaderEvent {
|
||||
const factory ProfitSharingDetailLoaderEvent.fetched({
|
||||
required String parentCategoryId,
|
||||
required DateTime dateFrom,
|
||||
required DateTime dateTo,
|
||||
}) = _Fetched;
|
||||
|
||||
/// Buka/tutup daftar produk pada satu sub kategori.
|
||||
const factory ProfitSharingDetailLoaderEvent.expandedCategoryChanged(
|
||||
String categoryId,
|
||||
) = _ExpandedCategoryChanged;
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
part of 'profit_sharing_detail_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitSharingDetailLoaderState with _$ProfitSharingDetailLoaderState {
|
||||
const ProfitSharingDetailLoaderState._();
|
||||
|
||||
const factory ProfitSharingDetailLoaderState({
|
||||
required ProfitSharingDetail detail,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
@Default('') String parentCategoryId,
|
||||
@Default('') String expandedCategoryId,
|
||||
required DateTime dateFrom,
|
||||
required DateTime dateTo,
|
||||
}) = _ProfitSharingDetailLoaderState;
|
||||
|
||||
factory ProfitSharingDetailLoaderState.initial() {
|
||||
final now = DateTime.now();
|
||||
return ProfitSharingDetailLoaderState(
|
||||
detail: ProfitSharingDetail.empty(),
|
||||
failureOption: none(),
|
||||
dateFrom: DateTime(now.year, now.month, 1),
|
||||
dateTo: DateTime(now.year, now.month + 1, 0),
|
||||
);
|
||||
}
|
||||
|
||||
bool isExpanded(String categoryId) => expandedCategoryId == categoryId;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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/analytic/analytic.dart';
|
||||
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
|
||||
|
||||
part 'profit_sharing_loader_event.dart';
|
||||
part 'profit_sharing_loader_state.dart';
|
||||
part 'profit_sharing_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class ProfitSharingLoaderBloc
|
||||
extends Bloc<ProfitSharingLoaderEvent, ProfitSharingLoaderState> {
|
||||
final IAnalyticRepository _repository;
|
||||
|
||||
ProfitSharingLoaderBloc(this._repository)
|
||||
: super(ProfitSharingLoaderState.initial()) {
|
||||
on<ProfitSharingLoaderEvent>(_onProfitSharingLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onProfitSharingLoaderEvent(
|
||||
ProfitSharingLoaderEvent event,
|
||||
Emitter<ProfitSharingLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
rangeDateChanged: (e) async {
|
||||
emit(state.copyWith(dateFrom: e.dateFrom, dateTo: e.dateTo));
|
||||
},
|
||||
periodTypeChanged: (e) async {
|
||||
emit(state.copyWith(periodType: e.periodType));
|
||||
},
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _repository.getProfitSharing(
|
||||
dateFrom: state.dateFrom,
|
||||
dateTo: state.dateTo,
|
||||
);
|
||||
|
||||
final newState = result.fold(
|
||||
(f) => state.copyWith(failureOption: optionOf(f)),
|
||||
(profitSharing) => state.copyWith(profitSharing: profitSharing),
|
||||
);
|
||||
|
||||
emit(newState.copyWith(isFetching: false));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+807
@@ -0,0 +1,807 @@
|
||||
// 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 'profit_sharing_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 _$ProfitSharingLoaderEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime dateFrom, DateTime dateTo)
|
||||
rangeDateChanged,
|
||||
required TResult Function(ProfitSharingPeriodType periodType)
|
||||
periodTypeChanged,
|
||||
required TResult Function() fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult? Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult? Function()? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult Function()? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_RangeDateChanged value) rangeDateChanged,
|
||||
required TResult Function(_PeriodTypeChanged value) periodTypeChanged,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult? Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitSharingLoaderEventCopyWith<$Res> {
|
||||
factory $ProfitSharingLoaderEventCopyWith(
|
||||
ProfitSharingLoaderEvent value,
|
||||
$Res Function(ProfitSharingLoaderEvent) then,
|
||||
) = _$ProfitSharingLoaderEventCopyWithImpl<$Res, ProfitSharingLoaderEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitSharingLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProfitSharingLoaderEvent
|
||||
>
|
||||
implements $ProfitSharingLoaderEventCopyWith<$Res> {
|
||||
_$ProfitSharingLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$RangeDateChangedImplCopyWith<$Res> {
|
||||
factory _$$RangeDateChangedImplCopyWith(
|
||||
_$RangeDateChangedImpl value,
|
||||
$Res Function(_$RangeDateChangedImpl) then,
|
||||
) = __$$RangeDateChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({DateTime dateFrom, DateTime dateTo});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RangeDateChangedImplCopyWithImpl<$Res>
|
||||
extends _$ProfitSharingLoaderEventCopyWithImpl<$Res, _$RangeDateChangedImpl>
|
||||
implements _$$RangeDateChangedImplCopyWith<$Res> {
|
||||
__$$RangeDateChangedImplCopyWithImpl(
|
||||
_$RangeDateChangedImpl _value,
|
||||
$Res Function(_$RangeDateChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? dateFrom = null, Object? dateTo = null}) {
|
||||
return _then(
|
||||
_$RangeDateChangedImpl(
|
||||
null == dateFrom
|
||||
? _value.dateFrom
|
||||
: dateFrom // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
null == dateTo
|
||||
? _value.dateTo
|
||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$RangeDateChangedImpl implements _RangeDateChanged {
|
||||
const _$RangeDateChangedImpl(this.dateFrom, this.dateTo);
|
||||
|
||||
@override
|
||||
final DateTime dateFrom;
|
||||
@override
|
||||
final DateTime dateTo;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingLoaderEvent.rangeDateChanged(dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RangeDateChangedImpl &&
|
||||
(identical(other.dateFrom, dateFrom) ||
|
||||
other.dateFrom == dateFrom) &&
|
||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, dateFrom, dateTo);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith =>
|
||||
__$$RangeDateChangedImplCopyWithImpl<_$RangeDateChangedImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime dateFrom, DateTime dateTo)
|
||||
rangeDateChanged,
|
||||
required TResult Function(ProfitSharingPeriodType periodType)
|
||||
periodTypeChanged,
|
||||
required TResult Function() fetched,
|
||||
}) {
|
||||
return rangeDateChanged(dateFrom, dateTo);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult? Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult? Function()? fetched,
|
||||
}) {
|
||||
return rangeDateChanged?.call(dateFrom, dateTo);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult Function()? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (rangeDateChanged != null) {
|
||||
return rangeDateChanged(dateFrom, dateTo);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_RangeDateChanged value) rangeDateChanged,
|
||||
required TResult Function(_PeriodTypeChanged value) periodTypeChanged,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return rangeDateChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult? Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return rangeDateChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (rangeDateChanged != null) {
|
||||
return rangeDateChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _RangeDateChanged implements ProfitSharingLoaderEvent {
|
||||
const factory _RangeDateChanged(
|
||||
final DateTime dateFrom,
|
||||
final DateTime dateTo,
|
||||
) = _$RangeDateChangedImpl;
|
||||
|
||||
DateTime get dateFrom;
|
||||
DateTime get dateTo;
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PeriodTypeChangedImplCopyWith<$Res> {
|
||||
factory _$$PeriodTypeChangedImplCopyWith(
|
||||
_$PeriodTypeChangedImpl value,
|
||||
$Res Function(_$PeriodTypeChangedImpl) then,
|
||||
) = __$$PeriodTypeChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({ProfitSharingPeriodType periodType});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PeriodTypeChangedImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$ProfitSharingLoaderEventCopyWithImpl<$Res, _$PeriodTypeChangedImpl>
|
||||
implements _$$PeriodTypeChangedImplCopyWith<$Res> {
|
||||
__$$PeriodTypeChangedImplCopyWithImpl(
|
||||
_$PeriodTypeChangedImpl _value,
|
||||
$Res Function(_$PeriodTypeChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? periodType = null}) {
|
||||
return _then(
|
||||
_$PeriodTypeChangedImpl(
|
||||
null == periodType
|
||||
? _value.periodType
|
||||
: periodType // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharingPeriodType,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PeriodTypeChangedImpl implements _PeriodTypeChanged {
|
||||
const _$PeriodTypeChangedImpl(this.periodType);
|
||||
|
||||
@override
|
||||
final ProfitSharingPeriodType periodType;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingLoaderEvent.periodTypeChanged(periodType: $periodType)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PeriodTypeChangedImpl &&
|
||||
(identical(other.periodType, periodType) ||
|
||||
other.periodType == periodType));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, periodType);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PeriodTypeChangedImplCopyWith<_$PeriodTypeChangedImpl> get copyWith =>
|
||||
__$$PeriodTypeChangedImplCopyWithImpl<_$PeriodTypeChangedImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime dateFrom, DateTime dateTo)
|
||||
rangeDateChanged,
|
||||
required TResult Function(ProfitSharingPeriodType periodType)
|
||||
periodTypeChanged,
|
||||
required TResult Function() fetched,
|
||||
}) {
|
||||
return periodTypeChanged(periodType);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult? Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult? Function()? fetched,
|
||||
}) {
|
||||
return periodTypeChanged?.call(periodType);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult Function()? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (periodTypeChanged != null) {
|
||||
return periodTypeChanged(periodType);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_RangeDateChanged value) rangeDateChanged,
|
||||
required TResult Function(_PeriodTypeChanged value) periodTypeChanged,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return periodTypeChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult? Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return periodTypeChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (periodTypeChanged != null) {
|
||||
return periodTypeChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PeriodTypeChanged implements ProfitSharingLoaderEvent {
|
||||
const factory _PeriodTypeChanged(final ProfitSharingPeriodType periodType) =
|
||||
_$PeriodTypeChangedImpl;
|
||||
|
||||
ProfitSharingPeriodType get periodType;
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PeriodTypeChangedImplCopyWith<_$PeriodTypeChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$ProfitSharingLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingLoaderEvent.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(DateTime dateFrom, DateTime dateTo)
|
||||
rangeDateChanged,
|
||||
required TResult Function(ProfitSharingPeriodType periodType)
|
||||
periodTypeChanged,
|
||||
required TResult Function() fetched,
|
||||
}) {
|
||||
return fetched();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult? Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult? Function()? fetched,
|
||||
}) {
|
||||
return fetched?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||
TResult Function(ProfitSharingPeriodType periodType)? periodTypeChanged,
|
||||
TResult Function()? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_RangeDateChanged value) rangeDateChanged,
|
||||
required TResult Function(_PeriodTypeChanged value) periodTypeChanged,
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult? Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||
TResult Function(_PeriodTypeChanged value)? periodTypeChanged,
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements ProfitSharingLoaderEvent {
|
||||
const factory _Fetched() = _$FetchedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProfitSharingLoaderState {
|
||||
ProfitSharing get profitSharing => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
ProfitSharingPeriodType get periodType => throw _privateConstructorUsedError;
|
||||
DateTime get dateFrom => throw _privateConstructorUsedError;
|
||||
DateTime get dateTo => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProfitSharingLoaderStateCopyWith<ProfitSharingLoaderState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitSharingLoaderStateCopyWith<$Res> {
|
||||
factory $ProfitSharingLoaderStateCopyWith(
|
||||
ProfitSharingLoaderState value,
|
||||
$Res Function(ProfitSharingLoaderState) then,
|
||||
) = _$ProfitSharingLoaderStateCopyWithImpl<$Res, ProfitSharingLoaderState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
ProfitSharing profitSharing,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
ProfitSharingPeriodType periodType,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
});
|
||||
|
||||
$ProfitSharingCopyWith<$Res> get profitSharing;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitSharingLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProfitSharingLoaderState
|
||||
>
|
||||
implements $ProfitSharingLoaderStateCopyWith<$Res> {
|
||||
_$ProfitSharingLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? profitSharing = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
Object? periodType = null,
|
||||
Object? dateFrom = null,
|
||||
Object? dateTo = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
profitSharing: null == profitSharing
|
||||
? _value.profitSharing
|
||||
: profitSharing // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharing,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
periodType: null == periodType
|
||||
? _value.periodType
|
||||
: periodType // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharingPeriodType,
|
||||
dateFrom: null == dateFrom
|
||||
? _value.dateFrom
|
||||
: dateFrom // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
dateTo: null == dateTo
|
||||
? _value.dateTo
|
||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ProfitSharingCopyWith<$Res> get profitSharing {
|
||||
return $ProfitSharingCopyWith<$Res>(_value.profitSharing, (value) {
|
||||
return _then(_value.copyWith(profitSharing: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProfitSharingLoaderStateImplCopyWith<$Res>
|
||||
implements $ProfitSharingLoaderStateCopyWith<$Res> {
|
||||
factory _$$ProfitSharingLoaderStateImplCopyWith(
|
||||
_$ProfitSharingLoaderStateImpl value,
|
||||
$Res Function(_$ProfitSharingLoaderStateImpl) then,
|
||||
) = __$$ProfitSharingLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
ProfitSharing profitSharing,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
ProfitSharingPeriodType periodType,
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
});
|
||||
|
||||
@override
|
||||
$ProfitSharingCopyWith<$Res> get profitSharing;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProfitSharingLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$ProfitSharingLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$ProfitSharingLoaderStateImpl
|
||||
>
|
||||
implements _$$ProfitSharingLoaderStateImplCopyWith<$Res> {
|
||||
__$$ProfitSharingLoaderStateImplCopyWithImpl(
|
||||
_$ProfitSharingLoaderStateImpl _value,
|
||||
$Res Function(_$ProfitSharingLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? profitSharing = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
Object? periodType = null,
|
||||
Object? dateFrom = null,
|
||||
Object? dateTo = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProfitSharingLoaderStateImpl(
|
||||
profitSharing: null == profitSharing
|
||||
? _value.profitSharing
|
||||
: profitSharing // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharing,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
periodType: null == periodType
|
||||
? _value.periodType
|
||||
: periodType // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitSharingPeriodType,
|
||||
dateFrom: null == dateFrom
|
||||
? _value.dateFrom
|
||||
: dateFrom // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
dateTo: null == dateTo
|
||||
? _value.dateTo
|
||||
: dateTo // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProfitSharingLoaderStateImpl extends _ProfitSharingLoaderState {
|
||||
const _$ProfitSharingLoaderStateImpl({
|
||||
required this.profitSharing,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
this.periodType = ProfitSharingPeriodType.weekly,
|
||||
required this.dateFrom,
|
||||
required this.dateTo,
|
||||
}) : super._();
|
||||
|
||||
@override
|
||||
final ProfitSharing profitSharing;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
@override
|
||||
@JsonKey()
|
||||
final ProfitSharingPeriodType periodType;
|
||||
@override
|
||||
final DateTime dateFrom;
|
||||
@override
|
||||
final DateTime dateTo;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitSharingLoaderState(profitSharing: $profitSharing, failureOption: $failureOption, isFetching: $isFetching, periodType: $periodType, dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProfitSharingLoaderStateImpl &&
|
||||
(identical(other.profitSharing, profitSharing) ||
|
||||
other.profitSharing == profitSharing) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching) &&
|
||||
(identical(other.periodType, periodType) ||
|
||||
other.periodType == periodType) &&
|
||||
(identical(other.dateFrom, dateFrom) ||
|
||||
other.dateFrom == dateFrom) &&
|
||||
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
profitSharing,
|
||||
failureOption,
|
||||
isFetching,
|
||||
periodType,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
);
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProfitSharingLoaderStateImplCopyWith<_$ProfitSharingLoaderStateImpl>
|
||||
get copyWith =>
|
||||
__$$ProfitSharingLoaderStateImplCopyWithImpl<
|
||||
_$ProfitSharingLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ProfitSharingLoaderState extends ProfitSharingLoaderState {
|
||||
const factory _ProfitSharingLoaderState({
|
||||
required final ProfitSharing profitSharing,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
final ProfitSharingPeriodType periodType,
|
||||
required final DateTime dateFrom,
|
||||
required final DateTime dateTo,
|
||||
}) = _$ProfitSharingLoaderStateImpl;
|
||||
const _ProfitSharingLoaderState._() : super._();
|
||||
|
||||
@override
|
||||
ProfitSharing get profitSharing;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
@override
|
||||
ProfitSharingPeriodType get periodType;
|
||||
@override
|
||||
DateTime get dateFrom;
|
||||
@override
|
||||
DateTime get dateTo;
|
||||
|
||||
/// Create a copy of ProfitSharingLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ProfitSharingLoaderStateImplCopyWith<_$ProfitSharingLoaderStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
part of 'profit_sharing_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitSharingLoaderEvent with _$ProfitSharingLoaderEvent {
|
||||
const factory ProfitSharingLoaderEvent.rangeDateChanged(
|
||||
DateTime dateFrom,
|
||||
DateTime dateTo,
|
||||
) = _RangeDateChanged;
|
||||
const factory ProfitSharingLoaderEvent.periodTypeChanged(
|
||||
ProfitSharingPeriodType periodType,
|
||||
) = _PeriodTypeChanged;
|
||||
const factory ProfitSharingLoaderEvent.fetched() = _Fetched;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
part of 'profit_sharing_loader_bloc.dart';
|
||||
|
||||
/// Tampilan rincian bagi hasil: per minggu atau per bulan.
|
||||
enum ProfitSharingPeriodType { weekly, monthly }
|
||||
|
||||
@freezed
|
||||
class ProfitSharingLoaderState with _$ProfitSharingLoaderState {
|
||||
const ProfitSharingLoaderState._();
|
||||
|
||||
const factory ProfitSharingLoaderState({
|
||||
required ProfitSharing profitSharing,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
@Default(ProfitSharingPeriodType.weekly) ProfitSharingPeriodType periodType,
|
||||
required DateTime dateFrom,
|
||||
required DateTime dateTo,
|
||||
}) = _ProfitSharingLoaderState;
|
||||
|
||||
factory ProfitSharingLoaderState.initial() {
|
||||
final now = DateTime.now();
|
||||
return ProfitSharingLoaderState(
|
||||
profitSharing: ProfitSharing.empty(),
|
||||
failureOption: none(),
|
||||
dateFrom: DateTime(now.year, now.month, 1),
|
||||
dateTo: DateTime(now.year, now.month + 1, 0),
|
||||
);
|
||||
}
|
||||
|
||||
/// Baris periode sesuai tab yang dipilih, periode kosong disembunyikan.
|
||||
List<ProfitSharingPeriod> get periods {
|
||||
final budget = profitSharing.budget;
|
||||
final list = periodType == ProfitSharingPeriodType.weekly
|
||||
? budget.weekly
|
||||
: budget.monthly;
|
||||
return list.where((e) => e.hasRevenue).toList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user