feat: dashboard analytic range date

This commit is contained in:
efrilm
2025-08-18 17:35:03 +07:00
parent aac3eecf95
commit 06d777290d
5 changed files with 345 additions and 71 deletions
+108 -65
View File
@@ -9,6 +9,7 @@ import '../../../common/theme/theme.dart';
import '../../../injection.dart';
import '../../components/appbar/appbar.dart';
import '../../components/button/button.dart';
import '../../components/field/date_range_picker_field.dart';
import '../../components/spacer/spacer.dart';
import 'widgets/payment_method.dart';
import 'widgets/quick_stats.dart';
@@ -87,78 +88,120 @@ class _ReportPageState extends State<ReportPage> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColor.background,
body:
BlocBuilder<
DashboardAnalyticLoaderBloc,
DashboardAnalyticLoaderState
>(
builder: (context, state) {
return CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 120,
floating: false,
pinned: true,
backgroundColor: AppColor.primary,
centerTitle: false,
flexibleSpace: CustomAppBar(
title: 'Laporan',
isBack: false,
return BlocListener<
DashboardAnalyticLoaderBloc,
DashboardAnalyticLoaderState
>(
listenWhen: (previous, current) =>
previous.dateFrom != current.dateFrom ||
previous.dateTo != current.dateTo,
listener: (context, state) {
context.read<DashboardAnalyticLoaderBloc>().add(
DashboardAnalyticLoaderEvent.fetched(),
);
},
child: Scaffold(
backgroundColor: AppColor.background,
body:
BlocBuilder<
DashboardAnalyticLoaderBloc,
DashboardAnalyticLoaderState
>(
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
SliverPadding(
padding: EdgeInsets.all(AppValue.padding),
sliver: SliverList(
delegate: SliverChildListDelegate([
FadeTransition(
SliverToBoxAdapter(
child: SlideTransition(
position: _slideAnimation,
child: 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),
],
child: Padding(
padding: const EdgeInsets.all(16.0),
child: DateRangePickerField(
maxDate: DateTime.now(),
startDate: state.dateFrom,
endDate: state.dateTo,
onChanged: (startDate, endDate) {
context.read<DashboardAnalyticLoaderBloc>().add(
DashboardAnalyticLoaderEvent.rangeDateChanged(
startDate!,
endDate!,
),
);
},
),
),
),
]),
),
),
),
],
);
},
),
// 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),
],
),
),
),
]),
),
),
],
);
},
),
),
);
}
}