You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

512 lines
20 KiB

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../../utils/font_weight.dart';
import '../../date_select/monthly_report_page.dart';
import '../home_view/donut_auto_label_chart.dart';
import '../home_view/my_line_chart.dart';
import 'package:charts_flutter/flutter.dart' as charts;
class TradeSummary extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _TradeSummary();
}
}
class _TradeSummary extends State<TradeSummary> {
final RefreshController _refreshController = RefreshController();
final ScrollController scrollController = ScrollController();
int operateSelect = 0;
int expensesSelect = 0;
int dateIndex = 0;
List<LineChartSample2Data> lineChartSample2DataAmount =
[LineChartSample2Data(0,40,"2023-03-09"),
LineChartSample2Data(1,10,"2023-03-10"),
LineChartSample2Data(2,50,"2023-03-11"),
LineChartSample2Data(3,35,"2023-03-12"),
LineChartSample2Data(4,20,"2023-03-13"),
LineChartSample2Data(5,55,"2023-03-14"),
LineChartSample2Data(6,100,"2023-03-15")];
List<LineChartSample2Data> lineChartSample2DataNum =
[LineChartSample2Data(0,20,"2023-03-09"),
LineChartSample2Data(1,30,"2023-03-10"),
LineChartSample2Data(2,50,"2023-03-11"),
LineChartSample2Data(3,60,"2023-03-12"),
LineChartSample2Data(4,5,"2023-03-13"),
LineChartSample2Data(5,55,"2023-03-14"),
LineChartSample2Data(6,95,"2023-03-15")];
@override
void dispose() {
super.dispose();
_refreshController.dispose();
}
@override
void initState() {
super.initState();
}
_onRefresh() async {
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
Container(
color: Color(0xFFD8D8D8),
width: double.infinity,
height: 1.h,
),
Expanded(child: SmartRefresher(
controller: _refreshController,
enablePullDown: true,
enablePullUp: false,
header: MyHeader(),
physics: BouncingScrollPhysics(),
scrollController: scrollController,
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: () {
setState(() {
_onRefresh();
});
},
child: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: BoxDecoration(
color: Color(0xFFF6F6F6),
borderRadius: BorderRadius.circular(2),
border: Border.all(color: Color(0xFFCFD0D1),
width: 1.w),
),
margin: EdgeInsets.only(
top: 16.h, right: 20.w, left: 20.w, bottom: 12.h),
child: Row(
children: [
Expanded(child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
dateIndex = 0;
});
},
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: dateIndex == 0 ? Color(0xFF30415B):Colors.transparent,
),
padding: EdgeInsets.symmetric(vertical: 9.h),
child: Text(
"日报",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: dateIndex == 0 ? Colors.white:Color(0xFF30415B),
),
),
),
)),
Expanded(child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
dateIndex = 1;
});},
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: dateIndex == 1 ? Color(0xFF30415B):Colors.transparent,
),
padding: EdgeInsets.symmetric(vertical: 9.h),
child: Text(
"周报",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: dateIndex == 1 ? Colors.white:Color(0xFF30415B),
),
),
),)),
Expanded(child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
dateIndex = 2;
});
},
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: dateIndex == 2 ? Color(0xFF30415B):Colors.transparent,
),
padding: EdgeInsets.symmetric(vertical: 9.h),
child: Text(
"月报",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: dateIndex == 2 ? Colors.white:Color(0xFF30415B),
),
),
),)),
Expanded(child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
dateIndex = 3;
});
},
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: dateIndex == 3 ? Color(0xFF30415B):Colors.transparent,
),
padding: EdgeInsets.symmetric(vertical: 9.h),
child: Text(
"自定义",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: dateIndex == 3 ? Colors.white:Color(0xFF30415B),
),
),
),)),
],
),
),
Align(alignment: Alignment.center,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
if(dateIndex == 0){
Navigator.of(context).pushNamed('/router/day_report_page');
}
else if(dateIndex == 1){
Navigator.of(context).pushNamed('/router/week_report_page');
}
else if(dateIndex == 2){
Navigator.of(context).pushNamed('/router/monthly_report_page');
}
else if(dateIndex == 3){
Navigator.of(context).pushNamed('/router/monthly_report_page');
}
},
child: Container(
width: 154.w,
alignment: Alignment.center,
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Color(0xFFF6F6F6),
borderRadius: BorderRadius.circular(2),
),
margin: EdgeInsets.only(bottom:16.h),
child: Row(
children: [
Padding(padding: EdgeInsets.only(right: 20.w),
child: Text(
"2023年06月01日(今日)",
style: TextStyle(
fontSize: 10.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
),
),),
Image.asset(
"assets/image/bs_calendar_logo.webp",
width:15,
height:15,
),
],
),
),
),),
Padding(padding:EdgeInsets.only(left:16.w,bottom:15.h),
child:Text(
"经营分析",
style: TextStyle(
fontSize: 18.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
)),
operateAnalysis(),
Container(
color: Color(0xFFF9FAF8),
height: 16.h,
width: double.infinity,
),
expensesAnalysis(),
],
)),
),)
],
),
);
}
///经营分析
Widget operateAnalysis(){
return Column(
children: [
Padding(padding: EdgeInsets.only(left:21.w,bottom: 1.h),
child: Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
operateSelect = 0;
});
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(padding:EdgeInsets.only(bottom: 10.h),
child:Text(
"营业额",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: operateSelect == 0 ? Colors.black:Color(0xFF969696),
),
)),
if(operateSelect == 0)
Container(
height: 2.h,
width: 44.w,
decoration: BoxDecoration(
color: Color(0xFF30415B),
borderRadius: BorderRadius.circular(2),
),
),
],
),
),
SizedBox(width:47.w,),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
operateSelect = 1;
});},
child:Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(padding:EdgeInsets.only(bottom: 10.h),
child:Text(
"交易笔数",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: operateSelect == 1 ? Colors.black:Color(0xFF969696),
),
)),
if(operateSelect == 1)
Container(
height: 2.h,
width: 44.w,
decoration: BoxDecoration(
color: Color(0xFF30415B),
borderRadius: BorderRadius.circular(2),
),
),
],
),
),
],
),),
Container(
width: double.infinity,
height: 1.h,
color: Color(0xFFD8D8D8),
margin: EdgeInsets.only(bottom:30.h),
),
if(operateSelect== 0)
Padding(padding: EdgeInsets.symmetric(horizontal: 20.w),
child:LineChartSample2(lineChartSample2DataAmount,"金额"),),
if(operateSelect == 1)
Padding(padding: EdgeInsets.symmetric(horizontal: 20.w),
child:LineChartSample2(lineChartSample2DataNum,"交易笔数"),),
SizedBox(height:16.h,),
],
);
}
///收退款分析
Widget expensesAnalysis(){
return Container(
padding: EdgeInsets.only(top:12.h,bottom: 33.h),
child: Column(
children: [
Padding(padding:EdgeInsets.only(left:16.w,bottom: 15.h),
child:Row(
children: [
Container(
width: 4.w,
height: 16.h,
color: Color(0xFF30415B),
margin: EdgeInsets.only(right:12.w),
),
Text(
"收退款分析",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
color:Color(0xFF0D0D0D),
),
)
],
)),
Padding(padding: EdgeInsets.only(left:21.w,bottom: 1.h),
child: Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
expensesSelect = 0;
});
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(padding:EdgeInsets.only(bottom: 10.h),
child:Text(
"交易金额",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: expensesSelect == 0 ? Colors.black:Color(0xFF969696),
),
)),
if(expensesSelect == 0)
Container(
height: 2.h,
width: 44.w,
decoration: BoxDecoration(
color: Color(0xFF30415B),
borderRadius: BorderRadius.circular(2),
),
),
],
),
),
SizedBox(width:37.w,),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
setState((){
expensesSelect = 1;
});},
child:Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(padding:EdgeInsets.only(bottom: 10.h),
child:Text(
"交易笔数",
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: expensesSelect == 1 ? Colors.black:Color(0xFF969696),
),
)),
if(expensesSelect == 1)
Container(
height: 2.h,
width: 44.w,
decoration: BoxDecoration(
color: Color(0xFF30415B),
borderRadius: BorderRadius.circular(2),
),
),
],
),
),
],
),),
if(expensesSelect == 0)
Container(
height:150.h,
child: DonutAutoLabelChart([
new charts.Series<LinearSales, int>(
id: 'Sales',
colorFn: (LinearSales sales, __) =>
sales.color,
domainFn: (LinearSales sales, _) =>
sales.year,
measureFn: (LinearSales sales, _) =>
sales.sales,
data: [
new LinearSales(0, 78100, charts.Color.fromHex(code: "#313CA9")),
new LinearSales(1, 135458, charts.Color.fromHex(code: "#30415B"))
],
// Set a label accessor to control the text of the arc label.
labelAccessorFn: (LinearSales row, _) =>
'${(row.sales / 100)}',
)
]),
),
if(expensesSelect == 1)
Container(
height:150.h,
child: DonutAutoLabelChart([
new charts.Series<LinearSales, int>(
id: 'Sales',
colorFn: (LinearSales sales, __) =>
sales.color,
domainFn: (LinearSales sales, _) =>
sales.year,
measureFn: (LinearSales sales, _) =>
sales.sales,
data: [
new LinearSales(0, 66, charts.Color.fromHex(code: "#313CA9")),
new LinearSales(1, 998, charts.Color.fromHex(code: "#30415B")),
new LinearSales(2, 155, charts.Color.fromHex(code: "#30415B")),
],
// Set a label accessor to control the text of the arc label.
labelAccessorFn: (LinearSales row, _) =>
'${(row.sales)}',
),
]),
),
],
),
);
}
showAlertDialog() {
showCupertinoModalPopup(
context: context,
builder: (context) {
return MaterialApp(
title: 'CalendarDatePicker2 Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
localizationsDelegates: GlobalMaterialLocalizations.delegates,
home: MonthlyReportPage(),
);},);
}
}