fix report
This commit is contained in:
parent
07932d688f
commit
13941d4881
@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../../../application/analytic/payment_method_analytic_loader/payment_method_analytic_loader_bloc.dart';
|
import '../../../../../../application/analytic/payment_method_analytic_loader/payment_method_analytic_loader_bloc.dart';
|
||||||
import '../../../../../../common/data/report_menu.dart';
|
import '../../../../../../common/data/report_menu.dart';
|
||||||
import '../../../../../../common/extension/extension.dart';
|
import '../../../../../../common/extension/extension.dart';
|
||||||
import '../../../../../../common/theme/theme.dart';
|
import '../../../../../../common/theme/theme.dart';
|
||||||
import '../../../../../../domain/analytic/analytic.dart';
|
import '../../../../../../domain/analytic/analytic.dart';
|
||||||
|
import '../../../../../components/error/analytic_error_state_widget.dart';
|
||||||
import '../../../../../components/loader/loader_with_text.dart';
|
import '../../../../../components/loader/loader_with_text.dart';
|
||||||
import '../../../../../components/spaces/space.dart';
|
import '../../../../../components/spaces/space.dart';
|
||||||
import '../../../../../components/widgets/report/report_header.dart';
|
import '../../../../../components/widgets/report/report_header.dart';
|
||||||
@ -29,44 +31,69 @@ class ReportPaymentMethodSection extends StatelessWidget {
|
|||||||
return const Center(child: LoaderWithText());
|
return const Center(child: LoaderWithText());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView(
|
return state.failureOption.fold(
|
||||||
padding: EdgeInsets.all(16),
|
() => RefreshIndicator(
|
||||||
children: [
|
onRefresh: () {
|
||||||
ReportHeader(menu: menu, endDate: endDate, startDate: startDate),
|
context.read<PaymentMethodAnalyticLoaderBloc>().add(
|
||||||
_buildSummary(),
|
PaymentMethodAnalyticLoaderEvent.fetched(
|
||||||
Container(
|
startDate: startDate,
|
||||||
padding: const EdgeInsets.all(12),
|
endDate: endDate,
|
||||||
margin: EdgeInsets.only(top: 16),
|
),
|
||||||
decoration: BoxDecoration(
|
);
|
||||||
color: AppColor.white,
|
return Future.value();
|
||||||
borderRadius: BorderRadius.circular(14),
|
},
|
||||||
),
|
child: ListView(
|
||||||
child: Column(
|
padding: EdgeInsets.all(16),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
children: [
|
ReportHeader(menu: menu, endDate: endDate, startDate: startDate),
|
||||||
Text(
|
_buildSummary(),
|
||||||
'Rincian Metode Pembayaran',
|
Container(
|
||||||
style: AppStyle.lg.copyWith(
|
padding: const EdgeInsets.all(12),
|
||||||
fontWeight: FontWeight.w600,
|
margin: EdgeInsets.only(top: 16),
|
||||||
color: AppColor.textPrimary,
|
decoration: BoxDecoration(
|
||||||
),
|
color: AppColor.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
),
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Rincian Metode Pembayaran',
|
||||||
|
style: AppStyle.lg.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColor.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
SpaceHeight(16),
|
SpaceHeight(16),
|
||||||
|
|
||||||
...List.generate(state.paymentMethodAnalytic.data.length, (
|
...List.generate(state.paymentMethodAnalytic.data.length, (
|
||||||
index,
|
index,
|
||||||
) {
|
) {
|
||||||
final item = state.paymentMethodAnalytic.data[index];
|
final item = state.paymentMethodAnalytic.data[index];
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
child: _buildPaymentCard(item),
|
child: _buildPaymentCard(item),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
|
(f) => AnalyticErrorStateWidget(
|
||||||
|
failure: f,
|
||||||
|
menu: menu,
|
||||||
|
onRefresh: () {
|
||||||
|
context.read<PaymentMethodAnalyticLoaderBloc>().add(
|
||||||
|
PaymentMethodAnalyticLoaderEvent.fetched(
|
||||||
|
startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../../../application/analytic/product_analytic_loader/product_analytic_loader_bloc.dart';
|
import '../../../../../../application/analytic/product_analytic_loader/product_analytic_loader_bloc.dart';
|
||||||
import '../../../../../../common/data/report_menu.dart';
|
import '../../../../../../common/data/report_menu.dart';
|
||||||
import '../../../../../../common/extension/extension.dart';
|
import '../../../../../../common/extension/extension.dart';
|
||||||
import '../../../../../../common/theme/theme.dart';
|
import '../../../../../../common/theme/theme.dart';
|
||||||
import '../../../../../../domain/analytic/analytic.dart';
|
import '../../../../../../domain/analytic/analytic.dart';
|
||||||
|
import '../../../../../components/error/analytic_error_state_widget.dart';
|
||||||
import '../../../../../components/loader/loader_with_text.dart';
|
import '../../../../../components/loader/loader_with_text.dart';
|
||||||
import '../../../../../components/spaces/space.dart';
|
import '../../../../../components/spaces/space.dart';
|
||||||
import '../../../../../components/widgets/report/report_header.dart';
|
import '../../../../../components/widgets/report/report_header.dart';
|
||||||
@ -29,114 +31,142 @@ class ReportProductSection extends StatelessWidget {
|
|||||||
return const Center(child: LoaderWithText());
|
return const Center(child: LoaderWithText());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Column(
|
return state.failureOption.fold(
|
||||||
children: [
|
() => Column(
|
||||||
Expanded(
|
children: [
|
||||||
child: SingleChildScrollView(
|
Expanded(
|
||||||
padding: EdgeInsets.all(16),
|
child: RefreshIndicator(
|
||||||
child: Column(
|
onRefresh: () {
|
||||||
children: [
|
context.read<ProductAnalyticLoaderBloc>().add(
|
||||||
ReportHeader(
|
ProductAnalyticLoaderEvent.fetched(
|
||||||
menu: menu,
|
startDate: startDate,
|
||||||
endDate: endDate,
|
endDate: endDate,
|
||||||
startDate: startDate,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: 90,
|
|
||||||
margin: EdgeInsets.only(top: 16),
|
|
||||||
child: ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.productAnalytic.categories.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final category = state.productAnalytic.categories[index];
|
|
||||||
return Container(
|
|
||||||
width: 200,
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right:
|
|
||||||
index ==
|
|
||||||
state.productAnalytic.categories.length - 1
|
|
||||||
? 0
|
|
||||||
: 12,
|
|
||||||
),
|
|
||||||
child: ReportSummaryCard(
|
|
||||||
color: AppColor.primary,
|
|
||||||
icon: Icons.category_outlined,
|
|
||||||
title: category.categoryName,
|
|
||||||
value: category.totalRevenue.currencyFormatRpV2,
|
|
||||||
subtitle: "${category.productCount} Item",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
Container(
|
return Future.value();
|
||||||
margin: EdgeInsets.only(top: 16),
|
},
|
||||||
padding: const EdgeInsets.all(12),
|
child: SingleChildScrollView(
|
||||||
decoration: BoxDecoration(
|
padding: EdgeInsets.all(16),
|
||||||
color: AppColor.white,
|
child: Column(
|
||||||
borderRadius: BorderRadius.circular(16),
|
children: [
|
||||||
),
|
ReportHeader(
|
||||||
child: Column(
|
menu: menu,
|
||||||
children: [
|
endDate: endDate,
|
||||||
Row(
|
startDate: startDate,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
),
|
||||||
children: [
|
Container(
|
||||||
Text(
|
height: 90,
|
||||||
'Produk Berkinerja Terbaik',
|
margin: EdgeInsets.only(top: 16),
|
||||||
style: AppStyle.lg.copyWith(
|
child: ListView.builder(
|
||||||
fontWeight: FontWeight.w600,
|
scrollDirection: Axis.horizontal,
|
||||||
color: AppColor.textPrimary,
|
itemCount: state.productAnalytic.categories.length,
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 8,
|
|
||||||
vertical: 4,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColor.primary.withOpacity(0.1),
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
border: Border.all(
|
|
||||||
color: AppColor.primary,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
'Berdasarkan Pendapatan',
|
|
||||||
style: AppStyle.xs.copyWith(
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: AppColor.primary,
|
|
||||||
fontSize: 10,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SpaceHeight(12),
|
|
||||||
ListView.builder(
|
|
||||||
itemCount: state.productAnalytic.data.length,
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final product = state.productAnalytic.data[index];
|
final category =
|
||||||
return _buildProductItem(
|
state.productAnalytic.categories[index];
|
||||||
rank: index + 1,
|
return Container(
|
||||||
product: product,
|
width: 200,
|
||||||
isTopPerformer:
|
padding: EdgeInsets.only(
|
||||||
product == state.productAnalytic.bestProduct,
|
right:
|
||||||
categoryColor: AppColor.primary,
|
index ==
|
||||||
|
state.productAnalytic.categories.length -
|
||||||
|
1
|
||||||
|
? 0
|
||||||
|
: 12,
|
||||||
|
),
|
||||||
|
child: ReportSummaryCard(
|
||||||
|
color: AppColor.primary,
|
||||||
|
icon: Icons.category_outlined,
|
||||||
|
title: category.categoryName,
|
||||||
|
value: category.totalRevenue.currencyFormatRpV2,
|
||||||
|
subtitle: "${category.productCount} Item",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
Container(
|
||||||
|
margin: EdgeInsets.only(top: 16),
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.white,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Produk Berkinerja Terbaik',
|
||||||
|
style: AppStyle.lg.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: AppColor.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.primary.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
border: Border.all(
|
||||||
|
color: AppColor.primary,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Berdasarkan Pendapatan',
|
||||||
|
style: AppStyle.xs.copyWith(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppColor.primary,
|
||||||
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SpaceHeight(12),
|
||||||
|
ListView.builder(
|
||||||
|
itemCount: state.productAnalytic.data.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final product = state.productAnalytic.data[index];
|
||||||
|
return _buildProductItem(
|
||||||
|
rank: index + 1,
|
||||||
|
product: product,
|
||||||
|
isTopPerformer:
|
||||||
|
product ==
|
||||||
|
state.productAnalytic.bestProduct,
|
||||||
|
categoryColor: AppColor.primary,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
_buildBottomSummary(),
|
||||||
_buildBottomSummary(),
|
],
|
||||||
],
|
),
|
||||||
|
(f) => AnalyticErrorStateWidget(
|
||||||
|
failure: f,
|
||||||
|
menu: menu,
|
||||||
|
onRefresh: () {
|
||||||
|
context.read<ProductAnalyticLoaderBloc>().add(
|
||||||
|
ProductAnalyticLoaderEvent.fetched(
|
||||||
|
startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../../../application/analytic/sales_analytic_loader/sales_analytic_loader_bloc.dart';
|
import '../../../../../../application/analytic/sales_analytic_loader/sales_analytic_loader_bloc.dart';
|
||||||
import '../../../../../../common/data/report_menu.dart';
|
import '../../../../../../common/data/report_menu.dart';
|
||||||
import '../../../../../../common/extension/extension.dart';
|
import '../../../../../../common/extension/extension.dart';
|
||||||
import '../../../../../../common/theme/theme.dart';
|
import '../../../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../../components/error/analytic_error_state_widget.dart';
|
||||||
import '../../../../../components/loader/loader_with_text.dart';
|
import '../../../../../components/loader/loader_with_text.dart';
|
||||||
import '../../../../../components/spaces/space.dart';
|
import '../../../../../components/spaces/space.dart';
|
||||||
import '../../../../../components/widgets/report/report_header.dart';
|
import '../../../../../components/widgets/report/report_header.dart';
|
||||||
@ -28,50 +30,78 @@ class ReportSalesSection extends StatelessWidget {
|
|||||||
return const Center(child: LoaderWithText());
|
return const Center(child: LoaderWithText());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ListView(
|
return state.failureOption.fold(
|
||||||
padding: EdgeInsets.all(16),
|
() => RefreshIndicator(
|
||||||
children: [
|
onRefresh: () {
|
||||||
ReportHeader(menu: menu, endDate: endDate, startDate: startDate),
|
context.read<SalesAnalyticLoaderBloc>().add(
|
||||||
_buildSummary(),
|
SalesAnalyticLoaderEvent.fetched(
|
||||||
Container(
|
startDate: startDate,
|
||||||
margin: EdgeInsets.only(top: 16),
|
endDate: endDate,
|
||||||
padding: const EdgeInsets.all(16),
|
),
|
||||||
decoration: BoxDecoration(
|
);
|
||||||
color: AppColor.white,
|
|
||||||
borderRadius: BorderRadius.circular(14),
|
return Future.value();
|
||||||
),
|
},
|
||||||
child: Column(
|
child: ListView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: EdgeInsets.all(16),
|
||||||
children: [
|
children: [
|
||||||
Text(
|
ReportHeader(menu: menu, endDate: endDate, startDate: startDate),
|
||||||
'Kinerja Harian',
|
_buildSummary(),
|
||||||
style: AppStyle.lg.copyWith(
|
Container(
|
||||||
fontWeight: FontWeight.w600,
|
margin: EdgeInsets.only(top: 16),
|
||||||
color: AppColor.textPrimary,
|
padding: const EdgeInsets.all(16),
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
),
|
),
|
||||||
SpaceHeight(12),
|
child: Column(
|
||||||
ListView.builder(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
itemCount: state.salesAnalytic.sortedDailyData.length,
|
children: [
|
||||||
shrinkWrap: true,
|
Text(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
'Kinerja Harian',
|
||||||
itemBuilder: (context, index) {
|
style: AppStyle.lg.copyWith(
|
||||||
final dayData = state.salesAnalytic.sortedDailyData[index];
|
fontWeight: FontWeight.w600,
|
||||||
return _buildDailyPerformanceItem(
|
color: AppColor.textPrimary,
|
||||||
date: dayData.date.toSimpleMonthDate(),
|
),
|
||||||
sales: dayData.sales.currencyFormatRpV2,
|
),
|
||||||
orders: dayData.orders,
|
SpaceHeight(12),
|
||||||
items: dayData.items,
|
ListView.builder(
|
||||||
isHighest: dayData == state.salesAnalytic.highestRevenueDay,
|
itemCount: state.salesAnalytic.sortedDailyData.length,
|
||||||
);
|
shrinkWrap: true,
|
||||||
},
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final dayData =
|
||||||
|
state.salesAnalytic.sortedDailyData[index];
|
||||||
|
return _buildDailyPerformanceItem(
|
||||||
|
date: dayData.date.toSimpleMonthDate(),
|
||||||
|
sales: dayData.sales.currencyFormatRpV2,
|
||||||
|
orders: dayData.orders,
|
||||||
|
items: dayData.items,
|
||||||
|
isHighest:
|
||||||
|
dayData == state.salesAnalytic.highestRevenueDay,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
SpaceHeight(16),
|
||||||
|
_buildSummaryFooter(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
SpaceHeight(16),
|
),
|
||||||
_buildSummaryFooter(),
|
(f) => AnalyticErrorStateWidget(
|
||||||
],
|
failure: f,
|
||||||
|
menu: menu,
|
||||||
|
onRefresh: () {
|
||||||
|
context.read<SalesAnalyticLoaderBloc>().add(
|
||||||
|
SalesAnalyticLoaderEvent.fetched(
|
||||||
|
startDate: startDate,
|
||||||
|
endDate: endDate,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user