feat: profit sharing
Build & Deploy iOS to TestFlight / build-and-deploy (push) Canceled after 0s

This commit is contained in:
efrilm
2026-08-21 22:31:54 +07:00
parent f9bfb69254
commit 2e4c77888e
48 changed files with 12553 additions and 162 deletions
@@ -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));
},
);
}
}
@@ -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();
}
}