feat: profit loss range date
This commit is contained in:
parent
1f6e5e9a2b
commit
ac8c2c0f54
@ -24,12 +24,15 @@ class ProfitLossLoaderBloc
|
|||||||
Emitter<ProfitLossLoaderState> emit,
|
Emitter<ProfitLossLoaderState> emit,
|
||||||
) {
|
) {
|
||||||
return event.map(
|
return event.map(
|
||||||
|
rangeDateChanged: (e) async {
|
||||||
|
emit(state.copyWith(dateFrom: e.dateFrom, dateTo: e.dateTo));
|
||||||
|
},
|
||||||
fetched: (e) async {
|
fetched: (e) async {
|
||||||
emit(state.copyWith(isFetching: true, failureOptionProfitLoss: none()));
|
emit(state.copyWith(isFetching: true, failureOptionProfitLoss: none()));
|
||||||
|
|
||||||
final result = await _repository.getProfitLoss(
|
final result = await _repository.getProfitLoss(
|
||||||
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
|
dateFrom: state.dateFrom,
|
||||||
dateTo: DateTime.now(),
|
dateTo: state.dateTo,
|
||||||
);
|
);
|
||||||
|
|
||||||
var data = result.fold(
|
var data = result.fold(
|
||||||
|
|||||||
@ -19,27 +19,34 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
mixin _$ProfitLossLoaderEvent {
|
mixin _$ProfitLossLoaderEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(DateTime dateFrom, DateTime dateTo)
|
||||||
|
rangeDateChanged,
|
||||||
required TResult Function() fetched,
|
required TResult Function() fetched,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||||
TResult? Function()? fetched,
|
TResult? Function()? fetched,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||||
TResult Function()? fetched,
|
TResult Function()? fetched,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_RangeDateChanged value) rangeDateChanged,
|
||||||
required TResult Function(_Fetched value) fetched,
|
required TResult Function(_Fetched value) fetched,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||||
TResult? Function(_Fetched value)? fetched,
|
TResult? Function(_Fetched value)? fetched,
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||||
TResult Function(_Fetched value)? fetched,
|
TResult Function(_Fetched value)? fetched,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) => throw _privateConstructorUsedError;
|
}) => throw _privateConstructorUsedError;
|
||||||
@ -70,6 +77,164 @@ class _$ProfitLossLoaderEventCopyWithImpl<
|
|||||||
/// with the given fields replaced by the non-null parameter values.
|
/// 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 _$ProfitLossLoaderEventCopyWithImpl<$Res, _$RangeDateChangedImpl>
|
||||||
|
implements _$$RangeDateChangedImplCopyWith<$Res> {
|
||||||
|
__$$RangeDateChangedImplCopyWithImpl(
|
||||||
|
_$RangeDateChangedImpl _value,
|
||||||
|
$Res Function(_$RangeDateChangedImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of ProfitLossLoaderEvent
|
||||||
|
/// 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 'ProfitLossLoaderEvent.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 ProfitLossLoaderEvent
|
||||||
|
/// 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() fetched,
|
||||||
|
}) {
|
||||||
|
return rangeDateChanged(dateFrom, dateTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||||
|
TResult? Function()? fetched,
|
||||||
|
}) {
|
||||||
|
return rangeDateChanged?.call(dateFrom, dateTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||||
|
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(_Fetched value) fetched,
|
||||||
|
}) {
|
||||||
|
return rangeDateChanged(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||||
|
TResult? Function(_Fetched value)? fetched,
|
||||||
|
}) {
|
||||||
|
return rangeDateChanged?.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
@optionalTypeArgs
|
||||||
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||||
|
TResult Function(_Fetched value)? fetched,
|
||||||
|
required TResult orElse(),
|
||||||
|
}) {
|
||||||
|
if (rangeDateChanged != null) {
|
||||||
|
return rangeDateChanged(this);
|
||||||
|
}
|
||||||
|
return orElse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _RangeDateChanged implements ProfitLossLoaderEvent {
|
||||||
|
const factory _RangeDateChanged(
|
||||||
|
final DateTime dateFrom,
|
||||||
|
final DateTime dateTo,
|
||||||
|
) = _$RangeDateChangedImpl;
|
||||||
|
|
||||||
|
DateTime get dateFrom;
|
||||||
|
DateTime get dateTo;
|
||||||
|
|
||||||
|
/// Create a copy of ProfitLossLoaderEvent
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
|
_$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class _$$FetchedImplCopyWith<$Res> {
|
abstract class _$$FetchedImplCopyWith<$Res> {
|
||||||
factory _$$FetchedImplCopyWith(
|
factory _$$FetchedImplCopyWith(
|
||||||
@ -112,19 +277,27 @@ class _$FetchedImpl implements _Fetched {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({required TResult Function() fetched}) {
|
TResult when<TResult extends Object?>({
|
||||||
|
required TResult Function(DateTime dateFrom, DateTime dateTo)
|
||||||
|
rangeDateChanged,
|
||||||
|
required TResult Function() fetched,
|
||||||
|
}) {
|
||||||
return fetched();
|
return fetched();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? fetched}) {
|
TResult? whenOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||||
|
TResult? Function()? fetched,
|
||||||
|
}) {
|
||||||
return fetched?.call();
|
return fetched?.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
TResult maybeWhen<TResult extends Object?>({
|
||||||
|
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
|
||||||
TResult Function()? fetched,
|
TResult Function()? fetched,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@ -137,6 +310,7 @@ class _$FetchedImpl implements _Fetched {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult map<TResult extends Object?>({
|
TResult map<TResult extends Object?>({
|
||||||
|
required TResult Function(_RangeDateChanged value) rangeDateChanged,
|
||||||
required TResult Function(_Fetched value) fetched,
|
required TResult Function(_Fetched value) fetched,
|
||||||
}) {
|
}) {
|
||||||
return fetched(this);
|
return fetched(this);
|
||||||
@ -145,6 +319,7 @@ class _$FetchedImpl implements _Fetched {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
TResult? mapOrNull<TResult extends Object?>({
|
||||||
|
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
|
||||||
TResult? Function(_Fetched value)? fetched,
|
TResult? Function(_Fetched value)? fetched,
|
||||||
}) {
|
}) {
|
||||||
return fetched?.call(this);
|
return fetched?.call(this);
|
||||||
@ -153,6 +328,7 @@ class _$FetchedImpl implements _Fetched {
|
|||||||
@override
|
@override
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeMap<TResult extends Object?>({
|
TResult maybeMap<TResult extends Object?>({
|
||||||
|
TResult Function(_RangeDateChanged value)? rangeDateChanged,
|
||||||
TResult Function(_Fetched value)? fetched,
|
TResult Function(_Fetched value)? fetched,
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
@ -173,6 +349,8 @@ mixin _$ProfitLossLoaderState {
|
|||||||
Option<AnalyticFailure> get failureOptionProfitLoss =>
|
Option<AnalyticFailure> get failureOptionProfitLoss =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
bool get isFetching => throw _privateConstructorUsedError;
|
||||||
|
DateTime get dateFrom => throw _privateConstructorUsedError;
|
||||||
|
DateTime get dateTo => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Create a copy of ProfitLossLoaderState
|
/// Create a copy of ProfitLossLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -192,6 +370,8 @@ abstract class $ProfitLossLoaderStateCopyWith<$Res> {
|
|||||||
ProfitLossAnalytic profitLoss,
|
ProfitLossAnalytic profitLoss,
|
||||||
Option<AnalyticFailure> failureOptionProfitLoss,
|
Option<AnalyticFailure> failureOptionProfitLoss,
|
||||||
bool isFetching,
|
bool isFetching,
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
});
|
});
|
||||||
|
|
||||||
$ProfitLossAnalyticCopyWith<$Res> get profitLoss;
|
$ProfitLossAnalyticCopyWith<$Res> get profitLoss;
|
||||||
@ -218,6 +398,8 @@ class _$ProfitLossLoaderStateCopyWithImpl<
|
|||||||
Object? profitLoss = null,
|
Object? profitLoss = null,
|
||||||
Object? failureOptionProfitLoss = null,
|
Object? failureOptionProfitLoss = null,
|
||||||
Object? isFetching = null,
|
Object? isFetching = null,
|
||||||
|
Object? dateFrom = null,
|
||||||
|
Object? dateTo = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_value.copyWith(
|
_value.copyWith(
|
||||||
@ -233,6 +415,14 @@ class _$ProfitLossLoaderStateCopyWithImpl<
|
|||||||
? _value.isFetching
|
? _value.isFetching
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
|
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,
|
as $Val,
|
||||||
);
|
);
|
||||||
@ -262,6 +452,8 @@ abstract class _$$ProfitLossLoaderStateImplCopyWith<$Res>
|
|||||||
ProfitLossAnalytic profitLoss,
|
ProfitLossAnalytic profitLoss,
|
||||||
Option<AnalyticFailure> failureOptionProfitLoss,
|
Option<AnalyticFailure> failureOptionProfitLoss,
|
||||||
bool isFetching,
|
bool isFetching,
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -286,6 +478,8 @@ class __$$ProfitLossLoaderStateImplCopyWithImpl<$Res>
|
|||||||
Object? profitLoss = null,
|
Object? profitLoss = null,
|
||||||
Object? failureOptionProfitLoss = null,
|
Object? failureOptionProfitLoss = null,
|
||||||
Object? isFetching = null,
|
Object? isFetching = null,
|
||||||
|
Object? dateFrom = null,
|
||||||
|
Object? dateTo = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_$ProfitLossLoaderStateImpl(
|
_$ProfitLossLoaderStateImpl(
|
||||||
@ -301,6 +495,14 @@ class __$$ProfitLossLoaderStateImplCopyWithImpl<$Res>
|
|||||||
? _value.isFetching
|
? _value.isFetching
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||||
as bool,
|
as bool,
|
||||||
|
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,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -313,6 +515,8 @@ class _$ProfitLossLoaderStateImpl implements _ProfitLossLoaderState {
|
|||||||
required this.profitLoss,
|
required this.profitLoss,
|
||||||
required this.failureOptionProfitLoss,
|
required this.failureOptionProfitLoss,
|
||||||
this.isFetching = false,
|
this.isFetching = false,
|
||||||
|
required this.dateFrom,
|
||||||
|
required this.dateTo,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -322,10 +526,14 @@ class _$ProfitLossLoaderStateImpl implements _ProfitLossLoaderState {
|
|||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
final bool isFetching;
|
final bool isFetching;
|
||||||
|
@override
|
||||||
|
final DateTime dateFrom;
|
||||||
|
@override
|
||||||
|
final DateTime dateTo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ProfitLossLoaderState(profitLoss: $profitLoss, failureOptionProfitLoss: $failureOptionProfitLoss, isFetching: $isFetching)';
|
return 'ProfitLossLoaderState(profitLoss: $profitLoss, failureOptionProfitLoss: $failureOptionProfitLoss, isFetching: $isFetching, dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -341,12 +549,21 @@ class _$ProfitLossLoaderStateImpl implements _ProfitLossLoaderState {
|
|||||||
) ||
|
) ||
|
||||||
other.failureOptionProfitLoss == failureOptionProfitLoss) &&
|
other.failureOptionProfitLoss == failureOptionProfitLoss) &&
|
||||||
(identical(other.isFetching, isFetching) ||
|
(identical(other.isFetching, isFetching) ||
|
||||||
other.isFetching == isFetching));
|
other.isFetching == isFetching) &&
|
||||||
|
(identical(other.dateFrom, dateFrom) ||
|
||||||
|
other.dateFrom == dateFrom) &&
|
||||||
|
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode => Object.hash(
|
||||||
Object.hash(runtimeType, profitLoss, failureOptionProfitLoss, isFetching);
|
runtimeType,
|
||||||
|
profitLoss,
|
||||||
|
failureOptionProfitLoss,
|
||||||
|
isFetching,
|
||||||
|
dateFrom,
|
||||||
|
dateTo,
|
||||||
|
);
|
||||||
|
|
||||||
/// Create a copy of ProfitLossLoaderState
|
/// Create a copy of ProfitLossLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -366,6 +583,8 @@ abstract class _ProfitLossLoaderState implements ProfitLossLoaderState {
|
|||||||
required final ProfitLossAnalytic profitLoss,
|
required final ProfitLossAnalytic profitLoss,
|
||||||
required final Option<AnalyticFailure> failureOptionProfitLoss,
|
required final Option<AnalyticFailure> failureOptionProfitLoss,
|
||||||
final bool isFetching,
|
final bool isFetching,
|
||||||
|
required final DateTime dateFrom,
|
||||||
|
required final DateTime dateTo,
|
||||||
}) = _$ProfitLossLoaderStateImpl;
|
}) = _$ProfitLossLoaderStateImpl;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -374,6 +593,10 @@ abstract class _ProfitLossLoaderState implements ProfitLossLoaderState {
|
|||||||
Option<AnalyticFailure> get failureOptionProfitLoss;
|
Option<AnalyticFailure> get failureOptionProfitLoss;
|
||||||
@override
|
@override
|
||||||
bool get isFetching;
|
bool get isFetching;
|
||||||
|
@override
|
||||||
|
DateTime get dateFrom;
|
||||||
|
@override
|
||||||
|
DateTime get dateTo;
|
||||||
|
|
||||||
/// Create a copy of ProfitLossLoaderState
|
/// Create a copy of ProfitLossLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
|||||||
@ -2,5 +2,9 @@ part of 'profit_loss_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class ProfitLossLoaderEvent with _$ProfitLossLoaderEvent {
|
class ProfitLossLoaderEvent with _$ProfitLossLoaderEvent {
|
||||||
|
const factory ProfitLossLoaderEvent.rangeDateChanged(
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
|
) = _RangeDateChanged;
|
||||||
const factory ProfitLossLoaderEvent.fetched() = _Fetched;
|
const factory ProfitLossLoaderEvent.fetched() = _Fetched;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,10 +6,14 @@ class ProfitLossLoaderState with _$ProfitLossLoaderState {
|
|||||||
required ProfitLossAnalytic profitLoss,
|
required ProfitLossAnalytic profitLoss,
|
||||||
required Option<AnalyticFailure> failureOptionProfitLoss,
|
required Option<AnalyticFailure> failureOptionProfitLoss,
|
||||||
@Default(false) bool isFetching,
|
@Default(false) bool isFetching,
|
||||||
|
required DateTime dateFrom,
|
||||||
|
required DateTime dateTo,
|
||||||
}) = _ProfitLossLoaderState;
|
}) = _ProfitLossLoaderState;
|
||||||
|
|
||||||
factory ProfitLossLoaderState.initial() => ProfitLossLoaderState(
|
factory ProfitLossLoaderState.initial() => ProfitLossLoaderState(
|
||||||
profitLoss: ProfitLossAnalytic.empty(),
|
profitLoss: ProfitLossAnalytic.empty(),
|
||||||
failureOptionProfitLoss: none(),
|
failureOptionProfitLoss: none(),
|
||||||
|
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
|
||||||
|
dateTo: DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import '../../../common/theme/theme.dart';
|
|||||||
import '../../../domain/analytic/analytic.dart';
|
import '../../../domain/analytic/analytic.dart';
|
||||||
import '../../../injection.dart';
|
import '../../../injection.dart';
|
||||||
import '../../components/appbar/appbar.dart';
|
import '../../components/appbar/appbar.dart';
|
||||||
|
import '../../components/field/date_range_picker_field.dart';
|
||||||
import 'widgets/cash_flow.dart';
|
import 'widgets/cash_flow.dart';
|
||||||
import 'widgets/category.dart';
|
import 'widgets/category.dart';
|
||||||
import 'widgets/product.dart';
|
import 'widgets/product.dart';
|
||||||
@ -50,14 +51,6 @@ class _FinancePageState extends State<FinancePage>
|
|||||||
late Animation<double> _fadeAnimation;
|
late Animation<double> _fadeAnimation;
|
||||||
late Animation<double> _scaleAnimation;
|
late Animation<double> _scaleAnimation;
|
||||||
|
|
||||||
String selectedPeriod = 'Hari ini';
|
|
||||||
final List<String> periods = [
|
|
||||||
'Hari ini',
|
|
||||||
'Minggu ini',
|
|
||||||
'Bulan ini',
|
|
||||||
'Tahun ini',
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -113,136 +106,108 @@ class _FinancePageState extends State<FinancePage>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColor.background,
|
backgroundColor: AppColor.background,
|
||||||
body: BlocBuilder<ProfitLossLoaderBloc, ProfitLossLoaderState>(
|
body: BlocListener<ProfitLossLoaderBloc, ProfitLossLoaderState>(
|
||||||
builder: (context, state) {
|
listenWhen: (previous, current) =>
|
||||||
return CustomScrollView(
|
previous.dateFrom != current.dateFrom &&
|
||||||
slivers: [
|
previous.dateTo != current.dateTo,
|
||||||
// SliverAppBar with animated background
|
listener: (context, state) {
|
||||||
SliverAppBar(
|
context.read<ProfitLossLoaderBloc>().add(
|
||||||
expandedHeight: 120,
|
ProfitLossLoaderEvent.fetched(),
|
||||||
floating: false,
|
|
||||||
pinned: true,
|
|
||||||
backgroundColor: AppColor.primary,
|
|
||||||
elevation: 0,
|
|
||||||
flexibleSpace: CustomAppBar(title: 'Keuangan'),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Header dengan filter periode
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: FadeTransition(
|
|
||||||
opacity: _fadeAnimation,
|
|
||||||
child: _buildPeriodSelector(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Summary Cards
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: SlideTransition(
|
|
||||||
position: _slideAnimation,
|
|
||||||
child: _buildSummaryCards(state.profitLoss.summary),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Cash Flow Analysis
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: ScaleTransition(
|
|
||||||
scale: _scaleAnimation,
|
|
||||||
child: FinanceCashFlow(dailyData: state.profitLoss.data),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Profit Loss Detail
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: FadeTransition(
|
|
||||||
opacity: _fadeAnimation,
|
|
||||||
child: FinanceProfitLoss(data: state.profitLoss.summary),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
BlocBuilder<
|
|
||||||
CategoryAnalyticLoaderBloc,
|
|
||||||
CategoryAnalyticLoaderState
|
|
||||||
>(
|
|
||||||
builder: (context, stateCategory) {
|
|
||||||
return SliverToBoxAdapter(
|
|
||||||
child: SlideTransition(
|
|
||||||
position: _slideAnimation,
|
|
||||||
child: FinanceCategory(
|
|
||||||
categories: stateCategory.categoryAnalytic.data,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
// Product Analysis Section
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: SlideTransition(
|
|
||||||
position: _slideAnimation,
|
|
||||||
child: _buildProductAnalysis(state.profitLoss.productData),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Transaction Categories
|
|
||||||
|
|
||||||
// Bottom spacing
|
|
||||||
const SliverToBoxAdapter(child: SizedBox(height: 100)),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
child: BlocBuilder<ProfitLossLoaderBloc, ProfitLossLoaderState>(
|
||||||
);
|
builder: (context, state) {
|
||||||
}
|
return CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
// SliverAppBar with animated background
|
||||||
|
SliverAppBar(
|
||||||
|
expandedHeight: 120,
|
||||||
|
floating: false,
|
||||||
|
pinned: true,
|
||||||
|
backgroundColor: AppColor.primary,
|
||||||
|
elevation: 0,
|
||||||
|
flexibleSpace: CustomAppBar(title: 'Keuangan'),
|
||||||
|
),
|
||||||
|
|
||||||
Widget _buildPeriodSelector() {
|
// Header dengan filter periode
|
||||||
return Container(
|
SliverToBoxAdapter(
|
||||||
padding: const EdgeInsets.all(16),
|
child: FadeTransition(
|
||||||
child: Row(
|
opacity: _fadeAnimation,
|
||||||
children: [
|
child: Padding(
|
||||||
Expanded(
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Container(
|
child: DateRangePickerField(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
maxDate: DateTime.now(),
|
||||||
decoration: BoxDecoration(
|
startDate: state.dateFrom,
|
||||||
color: AppColor.white,
|
endDate: state.dateTo,
|
||||||
borderRadius: BorderRadius.circular(12),
|
onChanged: (startDate, endDate) {
|
||||||
border: Border.all(color: AppColor.border),
|
context.read<ProfitLossLoaderBloc>().add(
|
||||||
),
|
ProfitLossLoaderEvent.rangeDateChanged(
|
||||||
child: DropdownButtonHideUnderline(
|
startDate!,
|
||||||
child: DropdownButton<String>(
|
endDate!,
|
||||||
value: selectedPeriod,
|
),
|
||||||
isExpanded: true,
|
);
|
||||||
icon: const Icon(
|
},
|
||||||
LineIcons.angleDown,
|
),
|
||||||
color: AppColor.primary,
|
),
|
||||||
),
|
),
|
||||||
style: AppStyle.md,
|
),
|
||||||
items: periods.map((String period) {
|
|
||||||
return DropdownMenuItem<String>(
|
// Summary Cards
|
||||||
value: period,
|
SliverToBoxAdapter(
|
||||||
child: Text(period),
|
child: SlideTransition(
|
||||||
|
position: _slideAnimation,
|
||||||
|
child: _buildSummaryCards(state.profitLoss.summary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Cash Flow Analysis
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: ScaleTransition(
|
||||||
|
scale: _scaleAnimation,
|
||||||
|
child: FinanceCashFlow(dailyData: state.profitLoss.data),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Profit Loss Detail
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: _fadeAnimation,
|
||||||
|
child: FinanceProfitLoss(data: state.profitLoss.summary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
BlocBuilder<
|
||||||
|
CategoryAnalyticLoaderBloc,
|
||||||
|
CategoryAnalyticLoaderState
|
||||||
|
>(
|
||||||
|
builder: (context, stateCategory) {
|
||||||
|
return SliverToBoxAdapter(
|
||||||
|
child: SlideTransition(
|
||||||
|
position: _slideAnimation,
|
||||||
|
child: FinanceCategory(
|
||||||
|
categories: stateCategory.categoryAnalytic.data,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
|
||||||
onChanged: (String? newValue) {
|
|
||||||
setState(() {
|
|
||||||
selectedPeriod = newValue!;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
// Product Analysis Section
|
||||||
),
|
SliverToBoxAdapter(
|
||||||
const SizedBox(width: 12),
|
child: SlideTransition(
|
||||||
Container(
|
position: _slideAnimation,
|
||||||
decoration: BoxDecoration(
|
child: _buildProductAnalysis(state.profitLoss.productData),
|
||||||
color: AppColor.primary,
|
),
|
||||||
borderRadius: BorderRadius.circular(12),
|
),
|
||||||
),
|
|
||||||
child: IconButton(
|
// Transaction Categories
|
||||||
onPressed: () {},
|
|
||||||
icon: const Icon(LineIcons.calendar, color: AppColor.white),
|
// Bottom spacing
|
||||||
),
|
const SliverToBoxAdapter(child: SizedBox(height: 100)),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user