feat: dashboard analytic range date
This commit is contained in:
parent
aac3eecf95
commit
06d777290d
@ -24,6 +24,9 @@ class DashboardAnalyticLoaderBloc
|
|||||||
Emitter<DashboardAnalyticLoaderState> emit,
|
Emitter<DashboardAnalyticLoaderState> 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(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
@ -33,8 +36,8 @@ class DashboardAnalyticLoaderBloc
|
|||||||
);
|
);
|
||||||
|
|
||||||
final result = await _repository.getDashboard(
|
final result = await _repository.getDashboard(
|
||||||
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 _$DashboardAnalyticLoaderEvent {
|
mixin _$DashboardAnalyticLoaderEvent {
|
||||||
@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;
|
||||||
@ -74,6 +81,165 @@ class _$DashboardAnalyticLoaderEventCopyWithImpl<
|
|||||||
/// 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
|
||||||
|
_$DashboardAnalyticLoaderEventCopyWithImpl<$Res, _$RangeDateChangedImpl>
|
||||||
|
implements _$$RangeDateChangedImplCopyWith<$Res> {
|
||||||
|
__$$RangeDateChangedImplCopyWithImpl(
|
||||||
|
_$RangeDateChangedImpl _value,
|
||||||
|
$Res Function(_$RangeDateChangedImpl) _then,
|
||||||
|
) : super(_value, _then);
|
||||||
|
|
||||||
|
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||||
|
/// 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 'DashboardAnalyticLoaderEvent.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 DashboardAnalyticLoaderEvent
|
||||||
|
/// 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 DashboardAnalyticLoaderEvent {
|
||||||
|
const factory _RangeDateChanged(
|
||||||
|
final DateTime dateFrom,
|
||||||
|
final DateTime dateTo,
|
||||||
|
) = _$RangeDateChangedImpl;
|
||||||
|
|
||||||
|
DateTime get dateFrom;
|
||||||
|
DateTime get dateTo;
|
||||||
|
|
||||||
|
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||||
|
/// 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(
|
||||||
@ -116,19 +282,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(),
|
||||||
}) {
|
}) {
|
||||||
@ -141,6 +315,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);
|
||||||
@ -149,6 +324,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);
|
||||||
@ -157,6 +333,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(),
|
||||||
}) {
|
}) {
|
||||||
@ -177,6 +354,8 @@ mixin _$DashboardAnalyticLoaderState {
|
|||||||
Option<AnalyticFailure> get failureOptionDashboardAnalytic =>
|
Option<AnalyticFailure> get failureOptionDashboardAnalytic =>
|
||||||
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 DashboardAnalyticLoaderState
|
/// Create a copy of DashboardAnalyticLoaderState
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@ -200,6 +379,8 @@ abstract class $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
|||||||
DashboardAnalytic dashboardAnalytic,
|
DashboardAnalytic dashboardAnalytic,
|
||||||
Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
||||||
bool isFetching,
|
bool isFetching,
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
});
|
});
|
||||||
|
|
||||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic;
|
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic;
|
||||||
@ -226,6 +407,8 @@ class _$DashboardAnalyticLoaderStateCopyWithImpl<
|
|||||||
Object? dashboardAnalytic = null,
|
Object? dashboardAnalytic = null,
|
||||||
Object? failureOptionDashboardAnalytic = null,
|
Object? failureOptionDashboardAnalytic = null,
|
||||||
Object? isFetching = null,
|
Object? isFetching = null,
|
||||||
|
Object? dateFrom = null,
|
||||||
|
Object? dateTo = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_value.copyWith(
|
_value.copyWith(
|
||||||
@ -242,6 +425,14 @@ class _$DashboardAnalyticLoaderStateCopyWithImpl<
|
|||||||
? _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,
|
||||||
);
|
);
|
||||||
@ -271,6 +462,8 @@ abstract class _$$DashboardAnalyticLoaderStateImplCopyWith<$Res>
|
|||||||
DashboardAnalytic dashboardAnalytic,
|
DashboardAnalytic dashboardAnalytic,
|
||||||
Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
||||||
bool isFetching,
|
bool isFetching,
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -298,6 +491,8 @@ class __$$DashboardAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|||||||
Object? dashboardAnalytic = null,
|
Object? dashboardAnalytic = null,
|
||||||
Object? failureOptionDashboardAnalytic = null,
|
Object? failureOptionDashboardAnalytic = null,
|
||||||
Object? isFetching = null,
|
Object? isFetching = null,
|
||||||
|
Object? dateFrom = null,
|
||||||
|
Object? dateTo = null,
|
||||||
}) {
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_$DashboardAnalyticLoaderStateImpl(
|
_$DashboardAnalyticLoaderStateImpl(
|
||||||
@ -313,6 +508,14 @@ class __$$DashboardAnalyticLoaderStateImplCopyWithImpl<$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,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -326,6 +529,8 @@ class _$DashboardAnalyticLoaderStateImpl
|
|||||||
required this.dashboardAnalytic,
|
required this.dashboardAnalytic,
|
||||||
required this.failureOptionDashboardAnalytic,
|
required this.failureOptionDashboardAnalytic,
|
||||||
this.isFetching = false,
|
this.isFetching = false,
|
||||||
|
required this.dateFrom,
|
||||||
|
required this.dateTo,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -335,10 +540,14 @@ class _$DashboardAnalyticLoaderStateImpl
|
|||||||
@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 'DashboardAnalyticLoaderState(dashboardAnalytic: $dashboardAnalytic, failureOptionDashboardAnalytic: $failureOptionDashboardAnalytic, isFetching: $isFetching)';
|
return 'DashboardAnalyticLoaderState(dashboardAnalytic: $dashboardAnalytic, failureOptionDashboardAnalytic: $failureOptionDashboardAnalytic, isFetching: $isFetching, dateFrom: $dateFrom, dateTo: $dateTo)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -355,7 +564,10 @@ class _$DashboardAnalyticLoaderStateImpl
|
|||||||
other.failureOptionDashboardAnalytic ==
|
other.failureOptionDashboardAnalytic ==
|
||||||
failureOptionDashboardAnalytic) &&
|
failureOptionDashboardAnalytic) &&
|
||||||
(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
|
||||||
@ -364,6 +576,8 @@ class _$DashboardAnalyticLoaderStateImpl
|
|||||||
dashboardAnalytic,
|
dashboardAnalytic,
|
||||||
failureOptionDashboardAnalytic,
|
failureOptionDashboardAnalytic,
|
||||||
isFetching,
|
isFetching,
|
||||||
|
dateFrom,
|
||||||
|
dateTo,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
/// Create a copy of DashboardAnalyticLoaderState
|
||||||
@ -386,6 +600,8 @@ abstract class _DashboardAnalyticLoaderState
|
|||||||
required final DashboardAnalytic dashboardAnalytic,
|
required final DashboardAnalytic dashboardAnalytic,
|
||||||
required final Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
required final Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
||||||
final bool isFetching,
|
final bool isFetching,
|
||||||
|
required final DateTime dateFrom,
|
||||||
|
required final DateTime dateTo,
|
||||||
}) = _$DashboardAnalyticLoaderStateImpl;
|
}) = _$DashboardAnalyticLoaderStateImpl;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -394,6 +610,10 @@ abstract class _DashboardAnalyticLoaderState
|
|||||||
Option<AnalyticFailure> get failureOptionDashboardAnalytic;
|
Option<AnalyticFailure> get failureOptionDashboardAnalytic;
|
||||||
@override
|
@override
|
||||||
bool get isFetching;
|
bool get isFetching;
|
||||||
|
@override
|
||||||
|
DateTime get dateFrom;
|
||||||
|
@override
|
||||||
|
DateTime get dateTo;
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
/// Create a copy of DashboardAnalyticLoaderState
|
||||||
/// 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 'dashboard_analytic_loader_bloc.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class DashboardAnalyticLoaderEvent with _$DashboardAnalyticLoaderEvent {
|
class DashboardAnalyticLoaderEvent with _$DashboardAnalyticLoaderEvent {
|
||||||
|
const factory DashboardAnalyticLoaderEvent.rangeDateChanged(
|
||||||
|
DateTime dateFrom,
|
||||||
|
DateTime dateTo,
|
||||||
|
) = _RangeDateChanged;
|
||||||
const factory DashboardAnalyticLoaderEvent.fetched() = _Fetched;
|
const factory DashboardAnalyticLoaderEvent.fetched() = _Fetched;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,15 @@ class DashboardAnalyticLoaderState with _$DashboardAnalyticLoaderState {
|
|||||||
required DashboardAnalytic dashboardAnalytic,
|
required DashboardAnalytic dashboardAnalytic,
|
||||||
required Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
required Option<AnalyticFailure> failureOptionDashboardAnalytic,
|
||||||
@Default(false) bool isFetching,
|
@Default(false) bool isFetching,
|
||||||
|
required DateTime dateFrom,
|
||||||
|
required DateTime dateTo,
|
||||||
}) = _DashboardAnalyticLoaderState;
|
}) = _DashboardAnalyticLoaderState;
|
||||||
|
|
||||||
factory DashboardAnalyticLoaderState.initial() =>
|
factory DashboardAnalyticLoaderState.initial() =>
|
||||||
DashboardAnalyticLoaderState(
|
DashboardAnalyticLoaderState(
|
||||||
dashboardAnalytic: DashboardAnalytic.empty(),
|
dashboardAnalytic: DashboardAnalytic.empty(),
|
||||||
failureOptionDashboardAnalytic: none(),
|
failureOptionDashboardAnalytic: none(),
|
||||||
|
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
|
||||||
|
dateTo: DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import '../../../common/theme/theme.dart';
|
|||||||
import '../../../injection.dart';
|
import '../../../injection.dart';
|
||||||
import '../../components/appbar/appbar.dart';
|
import '../../components/appbar/appbar.dart';
|
||||||
import '../../components/button/button.dart';
|
import '../../components/button/button.dart';
|
||||||
|
import '../../components/field/date_range_picker_field.dart';
|
||||||
import '../../components/spacer/spacer.dart';
|
import '../../components/spacer/spacer.dart';
|
||||||
import 'widgets/payment_method.dart';
|
import 'widgets/payment_method.dart';
|
||||||
import 'widgets/quick_stats.dart';
|
import 'widgets/quick_stats.dart';
|
||||||
@ -87,78 +88,120 @@ class _ReportPageState extends State<ReportPage> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return BlocListener<
|
||||||
backgroundColor: AppColor.background,
|
DashboardAnalyticLoaderBloc,
|
||||||
body:
|
DashboardAnalyticLoaderState
|
||||||
BlocBuilder<
|
>(
|
||||||
DashboardAnalyticLoaderBloc,
|
listenWhen: (previous, current) =>
|
||||||
DashboardAnalyticLoaderState
|
previous.dateFrom != current.dateFrom ||
|
||||||
>(
|
previous.dateTo != current.dateTo,
|
||||||
builder: (context, state) {
|
listener: (context, state) {
|
||||||
return CustomScrollView(
|
context.read<DashboardAnalyticLoaderBloc>().add(
|
||||||
slivers: [
|
DashboardAnalyticLoaderEvent.fetched(),
|
||||||
SliverAppBar(
|
);
|
||||||
expandedHeight: 120,
|
},
|
||||||
floating: false,
|
child: Scaffold(
|
||||||
pinned: true,
|
backgroundColor: AppColor.background,
|
||||||
backgroundColor: AppColor.primary,
|
body:
|
||||||
centerTitle: false,
|
BlocBuilder<
|
||||||
flexibleSpace: CustomAppBar(
|
DashboardAnalyticLoaderBloc,
|
||||||
title: 'Laporan',
|
DashboardAnalyticLoaderState
|
||||||
isBack: false,
|
>(
|
||||||
|
builder: (context, state) {
|
||||||
|
return CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverAppBar(
|
||||||
|
expandedHeight: 120,
|
||||||
|
floating: false,
|
||||||
|
pinned: true,
|
||||||
|
backgroundColor: AppColor.primary,
|
||||||
|
centerTitle: false,
|
||||||
|
flexibleSpace: CustomAppBar(
|
||||||
|
title: 'Laporan',
|
||||||
|
isBack: false,
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
ActionIconButton(
|
||||||
|
onTap: () {},
|
||||||
|
icon: LineIcons.download,
|
||||||
|
),
|
||||||
|
ActionIconButton(onTap: () {}, icon: LineIcons.filter),
|
||||||
|
SpaceWidth(8),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
|
||||||
ActionIconButton(onTap: () {}, icon: LineIcons.download),
|
|
||||||
ActionIconButton(onTap: () {}, icon: LineIcons.filter),
|
|
||||||
SpaceWidth(8),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// Content
|
SliverToBoxAdapter(
|
||||||
SliverPadding(
|
child: SlideTransition(
|
||||||
padding: EdgeInsets.all(AppValue.padding),
|
position: _slideAnimation,
|
||||||
sliver: SliverList(
|
child: FadeTransition(
|
||||||
delegate: SliverChildListDelegate([
|
|
||||||
FadeTransition(
|
|
||||||
opacity: _fadeAnimation,
|
opacity: _fadeAnimation,
|
||||||
child: SlideTransition(
|
child: Padding(
|
||||||
position: _slideAnimation,
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: DateRangePickerField(
|
||||||
children: [
|
maxDate: DateTime.now(),
|
||||||
ReportRevenueSummary(
|
startDate: state.dateFrom,
|
||||||
overview: state.dashboardAnalytic.overview,
|
endDate: state.dateTo,
|
||||||
rotationAnimation: _rotationAnimation,
|
onChanged: (startDate, endDate) {
|
||||||
),
|
context.read<DashboardAnalyticLoaderBloc>().add(
|
||||||
const SpaceHeight(24),
|
DashboardAnalyticLoaderEvent.rangeDateChanged(
|
||||||
ReportQuickStats(
|
startDate!,
|
||||||
overview: state.dashboardAnalytic.overview,
|
endDate!,
|
||||||
),
|
),
|
||||||
const SpaceHeight(24),
|
);
|
||||||
ReportSales(
|
},
|
||||||
salesData:
|
|
||||||
state.dashboardAnalytic.recentSales,
|
|
||||||
),
|
|
||||||
const SpaceHeight(24),
|
|
||||||
ReportPaymentMethod(
|
|
||||||
paymentMethods:
|
|
||||||
state.dashboardAnalytic.paymentMethods,
|
|
||||||
),
|
|
||||||
const SpaceHeight(24),
|
|
||||||
ReportTopProduct(
|
|
||||||
products: state.dashboardAnalytic.topProducts,
|
|
||||||
),
|
|
||||||
const SpaceHeight(24),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
// Content
|
||||||
);
|
SliverPadding(
|
||||||
},
|
padding: EdgeInsets.all(AppValue.padding),
|
||||||
),
|
sliver: SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
FadeTransition(
|
||||||
|
opacity: _fadeAnimation,
|
||||||
|
child: SlideTransition(
|
||||||
|
position: _slideAnimation,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
ReportRevenueSummary(
|
||||||
|
overview: state.dashboardAnalytic.overview,
|
||||||
|
rotationAnimation: _rotationAnimation,
|
||||||
|
),
|
||||||
|
const SpaceHeight(24),
|
||||||
|
ReportQuickStats(
|
||||||
|
overview: state.dashboardAnalytic.overview,
|
||||||
|
),
|
||||||
|
const SpaceHeight(24),
|
||||||
|
ReportSales(
|
||||||
|
salesData:
|
||||||
|
state.dashboardAnalytic.recentSales,
|
||||||
|
),
|
||||||
|
const SpaceHeight(24),
|
||||||
|
ReportPaymentMethod(
|
||||||
|
paymentMethods:
|
||||||
|
state.dashboardAnalytic.paymentMethods,
|
||||||
|
),
|
||||||
|
const SpaceHeight(24),
|
||||||
|
ReportTopProduct(
|
||||||
|
products:
|
||||||
|
state.dashboardAnalytic.topProducts,
|
||||||
|
),
|
||||||
|
const SpaceHeight(24),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user