From aef50dd53beafa06904d2d734468c7ff57285cbf Mon Sep 17 00:00:00 2001 From: machuanyu <840649825@qq.com> Date: Mon, 27 May 2024 09:01:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/job/work_student.dart | 4 +- .../annotate_class/widget/annotate_item.dart | 3 +- .../children/read_over/read_over_logic.dart | 22 +- .../children/read_over/read_over_state.dart | 2 + .../children/read_over/read_over_view.dart | 234 +++++++++++------- .../read_over/widget/task_list_item.dart | 7 +- .../student_history_work_view.dart | 2 +- .../widget/job_condition_filter.dart | 71 +++++- lib/page/home_page/home_logic.dart | 8 +- lib/page/home_page/home_state.dart | 4 +- lib/page/home_page/home_view.dart | 193 ++++++++++++++- 11 files changed, 431 insertions(+), 119 deletions(-) diff --git a/lib/common/job/work_student.dart b/lib/common/job/work_student.dart index 1e329bf..2037bae 100644 --- a/lib/common/job/work_student.dart +++ b/lib/common/job/work_student.dart @@ -52,10 +52,10 @@ class Items extends Object { int? questionCount; @JsonKey(name: 'annotateCount') - int annotateCount; + int? annotateCount; @JsonKey(name: 'annotateRate') - double annotateRate; + double? annotateRate; @JsonKey(name: 'classes') List? classes; diff --git a/lib/page/home_page/children/annotate_class/widget/annotate_item.dart b/lib/page/home_page/children/annotate_class/widget/annotate_item.dart index 4a1f6be..9a6cafd 100644 --- a/lib/page/home_page/children/annotate_class/widget/annotate_item.dart +++ b/lib/page/home_page/children/annotate_class/widget/annotate_item.dart @@ -99,8 +99,7 @@ class _AnnotateItemState extends State { child: ItemBtn(title: "数据快查",font: widget.font - 2.sp,clickFunction: (){ Get.toNamed(Routes.quickDataCheckPage,arguments: {'homeworkId':widget.state.homeworkId.value,'classId':widget.item.classId,'grade':widget.state.grade,'className':widget.item.className }); - // Get.toNamed(Routes.jobReportPage,arguments: {'title':widget.name,'homeworkId':widget.state.homeworkId.value,'classId':widget.item.classId,'grade':widget.state.grade,'className':widget.item.className}); - },), + },), ), const Expanded(flex: 1,child: Text(''),), Expanded( diff --git a/lib/page/home_page/children/read_over/read_over_logic.dart b/lib/page/home_page/children/read_over/read_over_logic.dart index 65789c8..5f15c1e 100644 --- a/lib/page/home_page/children/read_over/read_over_logic.dart +++ b/lib/page/home_page/children/read_over/read_over_logic.dart @@ -12,10 +12,20 @@ import 'read_over_state.dart'; class ReadOverLogic extends GetxController with RequestToolMixin, GetTickerProviderStateMixin{ final ReadOverState state = ReadOverState(); late TabController tabController; + late TabController tabController2; /* 待阅卷 */ late final EasyRefreshController refreshController1; late final EasyRefreshController refreshController2; + WorkStudentParams params = WorkStudentParams( + assessType: 0, + pageSize: 10, + ); + WorkStudentParams params2 = WorkStudentParams( + assessType: 0, + pageSize: 10, + ); + @override void onInit() { super.onInit(); @@ -25,25 +35,24 @@ class ReadOverLogic extends GetxController with RequestToolMixin, GetTickerProvi length: 2, vsync: this, ); + tabController2 = TabController(length: 4, vsync: this); getList(); } //待批阅列表 void getList() async { - WorkStudentParams params = WorkStudentParams( - assessType: 0, - ); WorkStudent data = WorkStudent([], 0); if(state.tabIndex.value == 0){ + params.pageNumber = state.page; data = await getClient().getUnAnnotateList(params); }else{ - data = await getClient().getAnnotatedList(params); + params2.pageNumber = state.page; + data = await getClient().getAnnotatedList(params2); } state.workList.value = data.items; refreshController1.finishRefresh(); refreshController2.finishRefresh(); - print('state.workList.length='); - print(state.workList.length); + print('state.workList.length=${state.workList.length}'); } /// 刷新方法 Future onMyRefresh(EasyRefreshController controller, int tab) async { @@ -132,6 +141,7 @@ class ReadOverLogic extends GetxController with RequestToolMixin, GetTickerProvi void dispose() { super.dispose(); tabController.dispose(); + tabController2.dispose(); refreshController1.dispose(); refreshController2.dispose(); } diff --git a/lib/page/home_page/children/read_over/read_over_state.dart b/lib/page/home_page/children/read_over/read_over_state.dart index 1bf60aa..1ca5173 100644 --- a/lib/page/home_page/children/read_over/read_over_state.dart +++ b/lib/page/home_page/children/read_over/read_over_state.dart @@ -10,4 +10,6 @@ class ReadOverState { late RxList workList = RxList(); late RxInt tabIndex = 0.obs; late bool completedToRefresh = true; + late RxString customTimeStr = '自定义'.obs; + late int page = 1; } diff --git a/lib/page/home_page/children/read_over/read_over_view.dart b/lib/page/home_page/children/read_over/read_over_view.dart index 0fe0ec4..43fefb4 100644 --- a/lib/page/home_page/children/read_over/read_over_view.dart +++ b/lib/page/home_page/children/read_over/read_over_view.dart @@ -10,6 +10,9 @@ import 'package:school_asignment_app/common/utils/utils.dart'; import 'package:school_asignment_app/page/global_widget/MyEmptyWidget.dart'; import 'package:school_asignment_app/page/global_widget/my_text.dart'; import 'package:school_asignment_app/page/home_page/children/read_over/widget/task_list_item.dart'; +import 'package:school_asignment_app/page/home_page/children/student_work_detail/widget/job_condition_filter.dart'; +import 'package:school_asignment_app/routes/app_pages.dart'; +import 'package:syncfusion_flutter_datepicker/datepicker.dart'; import 'read_over_logic.dart'; @@ -22,7 +25,9 @@ class ReadOverPage extends StatefulWidget { class _ReadOverPageState extends State { final logic = Get.find(); - final state = Get.find().state; + final state = Get + .find() + .state; @override Widget build(BuildContext context) { @@ -43,7 +48,10 @@ class _ReadOverPageState extends State { children: [ Container( color: Colors.white, - margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top), + margin: EdgeInsets.only(top: MediaQuery + .of(context) + .padding + .top), padding: EdgeInsets.only(bottom: 9.h, top: 4.h), child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -106,14 +114,23 @@ class _ReadOverPageState extends State { width: 140.w, alignment: Alignment.center, decoration: BoxDecoration( - color: state.tabIndex.value == 0 ? const Color.fromRGBO(255, 255, 255, 1) : null, - borderRadius: BorderRadius.all(Radius.circular(8.r)), + color: state.tabIndex.value == 0 + ? const Color.fromRGBO( + 255, 255, 255, 1) + : null, + borderRadius: BorderRadius.all( + Radius.circular(8.r)), ), child: quickText( '待批阅', size: 14.sp, - color: state.tabIndex.value == 0 ? Theme.of(context).primaryColor : const Color.fromRGBO(80, 94, 110, 1), - fontWeight: state.tabIndex.value == 0 ? FontWeight.bold : null, + color: state.tabIndex.value == 0 ? Theme + .of(context) + .primaryColor : const Color.fromRGBO( + 80, 94, 110, 1), + fontWeight: state.tabIndex.value == 0 + ? FontWeight.bold + : null, ), ); }), @@ -126,14 +143,23 @@ class _ReadOverPageState extends State { width: 140.w, alignment: Alignment.center, decoration: BoxDecoration( - color: state.tabIndex.value == 1 ? const Color.fromRGBO(255, 255, 255, 1) : null, - borderRadius: BorderRadius.all(Radius.circular(8.r)), + color: state.tabIndex.value == 1 + ? const Color.fromRGBO( + 255, 255, 255, 1) + : null, + borderRadius: BorderRadius.all( + Radius.circular(8.r)), ), child: quickText( '已批阅', size: 14.sp, - color: state.tabIndex.value == 1 ? Theme.of(context).primaryColor : const Color.fromRGBO(80, 94, 110, 1), - fontWeight: state.tabIndex.value == 1 ? FontWeight.bold : null, + color: state.tabIndex.value == 1 ? Theme + .of(context) + .primaryColor : const Color.fromRGBO( + 80, 94, 110, 1), + fontWeight: state.tabIndex.value == 1 + ? FontWeight.bold + : null, ), ); }), @@ -151,61 +177,88 @@ class _ReadOverPageState extends State { context, RouterManager.jobStudentGroupPath, transition: getTransition());*/ }, - child: Icon(const IconData(0xe63e, fontFamily: "AlibabaIcon"), color: const Color.fromRGBO(44, 48, 63, 1), size: 24.sp), + child: Icon( + const IconData(0xe63e, fontFamily: "AlibabaIcon"), + color: const Color.fromRGBO(44, 48, 63, 1), + size: 24.sp), ), ), ], ), ), - /* if (state.tabIndex.value == 1) - $CompletedJobConditionFilter( - controller: _tabController2, - jobType: params2.markingType ?? 1, - customTime: _tabController2.index != 3 || - (params2.startTime == null && params2.endTime == null) - ? null - : PickerDateRange( - params2.startTime == null ? null : DateTime.parse( - params2.startTime!), - params2.endTime == null ? null : DateTime.parse(params2 - .endTime!), - ), - onJobTypeTap: (int jobTypeVal) { - params2.markingType = jobTypeVal; - _refreshController2.callRefresh(); - }, - onTimeFilter: (String? startTime, String? endTime) { - if (startTime == null && endTime == null && - _tabController2.index == 3) { - _tabController2.animateTo(0); - } - params2.endTime = endTime; - params2.startTime = startTime; - _refreshController2.callRefresh(); - }, - ),*/ + Obx(() { + return state.tabIndex.value == 1? + JobConditionFilter( + customTimeStr: state.customTimeStr.value, + controller: logic.tabController2, + hasAll:true, + jobType: 1, + customTime: logic.tabController2.index != 3 || + (logic.params2.startDate == null && logic.params2.endDate == null) + ? null + : PickerDateRange( + logic.params2.startDate == null ? null : DateTime.parse( + logic.params2.startDate!), + logic.params2.endDate == null ? null : DateTime.parse(logic.params2.endDate!), + ), + onTimeFilter: (String? startTime, String? endTime) { + if (startTime == null && endTime == null && + logic.tabController2.index == 3) { + logic.tabController2.animateTo(0); + } + logic.params2.endDate = endTime; + logic.params2.startDate = startTime; + state.page = 1; + logic.getList(); + // logic.refreshController2.callRefresh(); + }, + refreshTime: (value) { + if (value != null && value.startDate != null) { + state.customTimeStr.value = + value.startDate?.toString().substring(0, 10) ?? ''; + + if (value.endDate != null) { + if (!Utils.isPad() && + value.startDate!.year == value.endDate!.year) { + state.customTimeStr.value = + '${value.startDate.toString().substring(5, 10)}~${value + .endDate.toString().substring(5, 10)}'; + } else { + state.customTimeStr.value = + '${state.customTimeStr.value}~${value.endDate + ?.toString() + .substring( + 0, 10)}'; + } + } + } + } + ):Container(); + }), Expanded( - child: IndexedStack( - index: state.tabIndex.value, - children: [ - $easyRefresh( - controller: logic.refreshController1, - tab: 1, - type: state.active, - data: state.workList, - onLoad: logic.onMyLoad, - onRefresh: logic.onMyRefresh, - logic: logic), - $easyRefresh( - controller: logic.refreshController2, - tab: 2, - type: state.active, - data: state.workList, - onLoad: logic.onMyLoad, - onRefresh: logic.onMyRefresh, - logic: logic), - ], - )), + child: Obx(() { + return IndexedStack( + index: state.tabIndex.value, + children: [ + $easyRefresh( + controller: logic.refreshController1, + tab: 1, + type: state.active, + data: state.workList, + onLoad: logic.onMyLoad, + onRefresh: logic.onMyRefresh, + logic: logic), + $easyRefresh( + controller: logic.refreshController2, + tab: 2, + type: state.active, + data: state.workList, + onLoad: logic.onMyLoad, + onRefresh: logic.onMyRefresh, + logic: logic), + ], + ); + })), ], ); }, @@ -228,8 +281,10 @@ class _ReadOverPageState extends State { @swidget Widget $easyRefresh({ required EasyRefreshController controller, - required Future Function(EasyRefreshController controller, int tab) onRefresh, - required Future Function(EasyRefreshController controller, int tab) onLoad, + required Future< + void> Function(EasyRefreshController controller, int tab) onRefresh, + required Future< + void> Function(EasyRefreshController controller, int tab) onLoad, required List data, required int tab, required int type, @@ -249,7 +304,8 @@ Widget $easyRefresh({ footer: TaurusFooter(), child: completed && isPadFlag ? GridView( - padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), + padding: EdgeInsets.only( + top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, //横轴三个子widget mainAxisSpacing: 10.h, @@ -259,11 +315,13 @@ Widget $easyRefresh({ children: List.generate(data.length, (index) { Items item = data[index]; String subjectName = EnumUtils.formatSubject(item.subject); - return $reviewedItem(jobTaskItem: item, type: type, subjectName: subjectName); + return $reviewedItem( + jobTaskItem: item, type: type, subjectName: subjectName); }), ) : ListView.builder( - padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), + padding: EdgeInsets.only( + top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), itemBuilder: (context, index) { Items item = data[index]; return TaskListItem( @@ -271,11 +329,6 @@ Widget $easyRefresh({ jobTaskItem: item, type: type, ); - /*HomeworkTasksViewItem( - completed: completed, - jobTaskItem: data[index], - call: () => controller.callRefresh(), - );*/ }, itemCount: data.length, ), @@ -286,7 +339,8 @@ Widget $easyRefresh({ } @swidget -Widget $reviewedItem({required Items jobTaskItem, required int type, required String subjectName}) { +Widget $reviewedItem( + {required Items jobTaskItem, required int type, required String subjectName}) { EdgeInsets padEdg = EdgeInsets.symmetric(horizontal: 10.w); return InkWell( @@ -294,6 +348,7 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St /* String url = '${RouterManager.jobListParticipateInClassPath}?&jobId=${jobTaskItem.id}&genderName=${Uri.encodeComponent(jobTaskItem.genderName)}&jobName=${Uri.encodeComponent(jobTaskItem.title)}&completed=${true}'; RouterManager.router.navigateTo(context, url, transition: getTransition());*/ + Get.toNamed(Routes.annotateClassPage,arguments: {'id':jobTaskItem.id,'name':jobTaskItem.name,'grade':jobTaskItem.grade}); }, child: Container( padding: EdgeInsets.only(top: 10.h), @@ -324,7 +379,9 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St alignment: Alignment.center, padding: EdgeInsets.only(left: 2.w), decoration: BoxDecoration( - color: type == 1 ? const Color.fromRGBO(104, 136, 253, 1) : const Color.fromRGBO(255, 175, 56, 1), + color: type == 1 + ? const Color.fromRGBO(104, 136, 253, 1) + : const Color.fromRGBO(255, 175, 56, 1), borderRadius: BorderRadius.only( topLeft: Radius.circular(14.r), topRight: Radius.circular(3.r), @@ -333,10 +390,13 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St ), ), margin: EdgeInsets.only(right: 4.w), - child: quickText(type == 1 ? '作业' : '考试', color: Colors.white, size: 10.sp), + child: quickText(type == 1 ? '作业' : '考试', color: Colors.white, + size: 10.sp), ), Expanded( - child: quickText(jobTaskItem.name, size: 14.sp, color: const Color.fromRGBO(70, 70, 70, 1), maxLines: 2), + child: quickText(jobTaskItem.name, size: 14.sp, + color: const Color.fromRGBO(70, 70, 70, 1), + maxLines: 2), ) ], ), @@ -347,12 +407,16 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St child: Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - quickText(DateTime.parse(jobTaskItem.publishTime).toString().substring(0,10), + quickText( + DateTime.parse(jobTaskItem.publishTime).toString().substring( + 0, 10), color: const Color.fromRGBO(97, 97, 97, 1), size: 10.sp, fontWeight: FontWeight.w500, ), - quickText(' / ', color: const Color.fromRGBO(76, 199, 147, 1), size: 10.sp, fontWeight: FontWeight.w500), + quickText(' / ', color: const Color.fromRGBO(76, 199, 147, 1), + size: 10.sp, + fontWeight: FontWeight.w500), quickText( '参与班级:', color: const Color.fromRGBO(76, 199, 147, 1), @@ -363,7 +427,9 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St color: const Color.fromRGBO(76, 199, 147, 1), size: 10.sp, ), - quickText(' / ', color: const Color.fromRGBO(116, 145, 253, 1), size: 10.sp, fontWeight: FontWeight.w500), + quickText(' / ', color: const Color.fromRGBO(116, 145, 253, 1), + size: 10.sp, + fontWeight: FontWeight.w500), quickText( '科目:$subjectName', color: const Color.fromRGBO(116, 145, 253, 1), @@ -382,17 +448,15 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St ),*/ GestureDetector( onTap: () { - /* RouterManager.router.navigateTo( - context, - RouterManager.jobReportPagePath + - '?title=${Uri.encodeComponent(jobTaskItem.title)}&id=${jobTaskItem.id}', - transition: getTransition(), - );*/ + Get.toNamed(Routes.jobReportPage,arguments: {'title':jobTaskItem.name,'homeworkId':jobTaskItem.id,'grade':jobTaskItem.grade}); + }, child: Container( padding: EdgeInsets.symmetric(vertical: 6.h), decoration: BoxDecoration( - borderRadius: BorderRadius.only(bottomLeft: Radius.circular(6.r), bottomRight: Radius.circular(6.r)), + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(6.r), + bottomRight: Radius.circular(6.r)), color: Colors.white, boxShadow: const [ BoxShadow( @@ -407,7 +471,9 @@ Widget $reviewedItem({required Items jobTaskItem, required int type, required St Expanded( child: Container( alignment: Alignment.center, - child: quickText('查看报告', color: const Color.fromRGBO(118, 118, 118, 1), size: 11.sp), + child: quickText( + '查看报告', color: const Color.fromRGBO(118, 118, 118, 1), + size: 11.sp), ), ), ]), diff --git a/lib/page/home_page/children/read_over/widget/task_list_item.dart b/lib/page/home_page/children/read_over/widget/task_list_item.dart index 84cd9f5..abba774 100644 --- a/lib/page/home_page/children/read_over/widget/task_list_item.dart +++ b/lib/page/home_page/children/read_over/widget/task_list_item.dart @@ -154,11 +154,6 @@ class _TaskListItemState extends State { : InkWell( onTap: () { - /*String url = - '${RouterManager.jobListParticipateInClassPath}?&jobId=${jobTaskItem.id}&genderName=${Uri.encodeComponent(jobTaskItem.genderName)}&jobName=${Uri.encodeComponent(jobTaskItem.title)}'; - RouterManager.router.navigateTo(context, url, transition: getTransition()).then((value) { - if (value != null && value == true) call(); - });*/ Get.toNamed(Routes.annotateClassPage,arguments: {'id':widget.jobTaskItem.id,'name':widget.jobTaskItem.name,'grade':widget.jobTaskItem.grade}); }, child: Stack( @@ -264,7 +259,7 @@ class _TaskListItemState extends State { radius: 40.r, lineWidth: 10.r, animation: true, - percent: widget.jobTaskItem.annotateRate / 100, + percent: widget.jobTaskItem.annotateRate==null?0:widget.jobTaskItem.annotateRate! / 100, center: Text.rich(TextSpan(children: [ TextSpan( text: Utils.getDoubleRemoveZero(widget.jobTaskItem.annotateRate, '0'), diff --git a/lib/page/home_page/children/student_history_work/student_history_work_view.dart b/lib/page/home_page/children/student_history_work/student_history_work_view.dart index 7d7d370..0e8b497 100644 --- a/lib/page/home_page/children/student_history_work/student_history_work_view.dart +++ b/lib/page/home_page/children/student_history_work/student_history_work_view.dart @@ -25,7 +25,7 @@ class _StudentHistoryWorkPageState extends State { appBar: AppBar( backgroundColor: Colors.white, title: Text( - '我的学生分组', + '我的班级 ', style: TextStyle(fontSize: 14.sp, color: const Color(0xFF333333)), ), centerTitle: true, diff --git a/lib/page/home_page/children/student_work_detail/widget/job_condition_filter.dart b/lib/page/home_page/children/student_work_detail/widget/job_condition_filter.dart index 3c19165..4f90466 100644 --- a/lib/page/home_page/children/student_work_detail/widget/job_condition_filter.dart +++ b/lib/page/home_page/children/student_work_detail/widget/job_condition_filter.dart @@ -9,16 +9,19 @@ class JobConditionFilter extends StatefulWidget { final TabController controller; final int jobType; final PickerDateRange? customTime; -final Function refreshTime; +final Function? refreshTime; final String customTimeStr; +final bool? hasAll; final Function(String? startTime, String? endTime) onTimeFilter; const JobConditionFilter({Key? key, required this.controller, required this.jobType, this.customTime, - required this.refreshTime, + this.refreshTime, required this.customTimeStr, - required this.onTimeFilter}) : super(key: key); + required this.onTimeFilter, + this.hasAll = false, + }) : super(key: key); @override State createState() => _JobConditionFilterState(); @@ -68,18 +71,66 @@ class _JobConditionFilterState extends State { child: PersonalDetailTopBar( controller: widget.controller, customTimeStr: widget.customTimeStr, + hasAll: widget.hasAll, onTap: (int val) async { - switch (val) { - /*case 0: // 全部 + if(val == 0 && widget.hasAll == true){ + widget.onTimeFilter(null, null); + }else if(val == 1 || (val == 0 && widget.hasAll == false)){ + widget.onTimeFilter( + Utils.getWeekStartDate().toString().substring(0, 10), + Utils.getWeekEndDate().toString().substring(0, 10), + ); + }else if(val == 2 || (val == 1 && widget.hasAll == false)){ + widget.onTimeFilter( + getMonthStartDate().toString().substring(0, 10), + getMonthEndDate().toString().substring(0, 10), + ); + }else{ + var dialogData = await showDialog( + context: context, + builder: (BuildContext context1) { + return Center( + child: Container( + color: Colors.white, + width: Utils.isPad() ? ScreenUtil().screenWidth / 2 : ScreenUtil().screenWidth / 1.3, + height: ScreenUtil().screenHeight / 2, + child: SfDateRangePicker( + showActionButtons: true, + confirmText: '确定', + cancelText: '取消', + onSubmit: (p0) { + print(p0); + Get.back(result: p0); + // Navigator.of(context1).pop(p0); + widget.refreshTime!(p0); + }, + onCancel: () { + Get.back(); + // Navigator.of(context1).pop(); + }, + selectionMode: DateRangePickerSelectionMode.range, + initialSelectedRange: customTimeState, + ), + ), + ); + }); + widget.onTimeFilter( + dialogData?.startDate?.toString().substring(0, 10), + dialogData?.endDate?.toString().substring(0, 10), + ); + customTimeState = dialogData!; + } + /* switch (val) { + case 0: // 全部 widget.onTimeFilter(null, null); - break;*/ - case 0: // 近一周 + break; + case 1: // 近一周 widget.onTimeFilter( Utils.getWeekStartDate().toString().substring(0, 10), Utils.getWeekEndDate().toString().substring(0, 10), ); break; - case 1: // 近一个月 + case 2: // 近一个月 widget.onTimeFilter( getMonthStartDate().toString().substring(0, 10), getMonthEndDate().toString().substring(0, 10), @@ -102,7 +153,7 @@ class _JobConditionFilterState extends State { print(p0); Get.back(result: p0); // Navigator.of(context1).pop(p0); - widget.refreshTime(p0); + widget.refreshTime!(p0); }, onCancel: () { Get.back(); @@ -119,7 +170,7 @@ class _JobConditionFilterState extends State { dialogData?.endDate?.toString().substring(0, 10), ); customTimeState = dialogData!; - } + }*/ }, ), ); diff --git a/lib/page/home_page/home_logic.dart b/lib/page/home_page/home_logic.dart index ffe6873..26fc330 100644 --- a/lib/page/home_page/home_logic.dart +++ b/lib/page/home_page/home_logic.dart @@ -1,3 +1,4 @@ +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:get/get.dart'; import 'package:school_asignment_app/common/job/work_student.dart'; import 'package:school_asignment_app/common/job/work_student_params.dart'; @@ -8,9 +9,12 @@ import 'home_state.dart'; class HomeLogic extends GetxController with RequestToolMixin, GetTickerProviderStateMixin { final HomeState state = HomeState(); + late final EasyRefreshController refreshController; + @override void onInit() { super.onInit(); + refreshController = EasyRefreshController(); getList(); } void getList() async { @@ -19,10 +23,12 @@ class HomeLogic extends GetxController with RequestToolMixin, GetTickerProviderS ); WorkStudent data = await getClient().getUnAnnotateList(params); UserStore.to.readOver.value = data.items.length; - + state.workList.value = data.items; + refreshController.finishRefresh(); } @override void dispose() { super.dispose(); + refreshController.dispose(); } } diff --git a/lib/page/home_page/home_state.dart b/lib/page/home_page/home_state.dart index 38018a6..9b50314 100644 --- a/lib/page/home_page/home_state.dart +++ b/lib/page/home_page/home_state.dart @@ -1,6 +1,7 @@ import 'package:get/get.dart'; import 'package:school_asignment_app/common/job/user_info.dart'; import 'package:school_asignment_app/common/store/user_store.dart'; +import 'package:school_asignment_app/common/job/work_student.dart'; class HomeState { HomeState() { @@ -9,5 +10,6 @@ class HomeState { late Rx userInfo; late RxInt readOver = UserStore.to.readOver; - + late RxList workList = RxList(); + late int type = 1; } diff --git a/lib/page/home_page/home_view.dart b/lib/page/home_page/home_view.dart index 172810c..d2996de 100644 --- a/lib/page/home_page/home_view.dart +++ b/lib/page/home_page/home_view.dart @@ -1,10 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; import 'package:get/get.dart'; import 'package:badges/badges.dart' as badges; +import 'package:percent_indicator/percent_indicator.dart'; +import 'package:school_asignment_app/common/job/work_student.dart'; +import 'package:school_asignment_app/common/utils/enum_untils.dart'; import 'package:school_asignment_app/common/utils/utils.dart'; +import 'package:school_asignment_app/page/global_widget/MyEmptyWidget.dart'; import 'package:school_asignment_app/page/global_widget/my_text.dart'; import 'package:school_asignment_app/routes/app_pages.dart'; @@ -38,7 +43,7 @@ class _HomePageState extends State statusBarIconBrightness: Brightness.dark, statusBarBrightness: Brightness.light, ), - child: ListView( + child: Column( children: [ Container( height: 200.h, @@ -88,8 +93,8 @@ class _HomePageState extends State ) ], 0), - spaceWidth, - $TermRow( + + /* $TermRow( context, [ EntranceModel( @@ -97,7 +102,183 @@ class _HomePageState extends State image: 'assets/images/job_home_marking_set.png', navigationUrl: '') ], - 0), + 0),*/ + Expanded(child: Obx(() { + return EasyRefresh( + firstRefresh: false, + taskIndependence: true, + controller: logic.refreshController, + header: MaterialHeader(), + footer: TaurusFooter(), + child: ListView.builder( + padding: EdgeInsets.only( + top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), + itemBuilder: (context, index) { + Items item = state.workList[index]; + return InkWell( + onTap: () { + Get.toNamed(Routes.annotateClassPage, arguments: { + 'id': item.id, + 'name': item.name, + 'grade': item.grade + }); + }, + child: Container( + margin: EdgeInsets.only(bottom: 16.h), + child: Column( + children: [ + SizedBox(height: 30.h), + Container( + padding: EdgeInsets.symmetric( + vertical: 16.h, horizontal: 10.w), + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.r), + color: const Color.fromRGBO(255, 255, 255, 1), + boxShadow: const [ + BoxShadow( + color: Color.fromRGBO(210, 216, 241, 1), + offset: Offset.zero, //阴影y轴偏移量 + blurRadius: 5.8, //阴影模糊程度 + spreadRadius: 0, //阴影扩散程度 + ) + ], + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: Utils.isPad() ? 32.w : 38.w, + height: 18.h, + alignment: Alignment.center, + padding: EdgeInsets.only( + left: Utils.isPad() ? 2.w : 3.w), + decoration: BoxDecoration( + color: state.type == 1 + ? const Color.fromRGBO( + 104, 136, 253, 1) + : const Color.fromRGBO( + 255, 175, 56, 1), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(14.r), + topRight: Radius.circular(3.r), + bottomLeft: Radius.circular(4.r), + bottomRight: Radius.circular(4.r), + ), + ), + margin: EdgeInsets.only(right: 4.w), + child: quickText( + state.type == 1 ? '作业' : '考试', + color: Colors.white, + size: 10.sp), + ), + Expanded( + child: quickText( + item.name, + maxLines: 2, + size: Utils.isPad() ? 14.sp : 16.sp, + color: + const Color.fromRGBO(70, 70, 70, 1), + fontWeight: FontWeight.bold, + ), + ) + ], + ), + SizedBox(height: 10.h), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + quickText( + EnumUtils.formatSubject(item.subject), + color: + const Color.fromRGBO(97, 97, 97, 1), + size: 12.sp, + ), + quickText(' / ', + color: const Color.fromRGBO( + 130, 130, 130, 1), + size: 11.sp, + fontWeight: FontWeight.w500), + Container( + child: Row( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + quickText('题量:', + color: const Color.fromRGBO( + 130, 130, 130, 1), + size: 11.sp), + quickText( + '10', + color: const Color.fromRGBO( + 97, 97, 97, 1), + size: 13.sp, + ), + ], + ), + ), + quickText(' / ', + color: const Color.fromRGBO( + 130, 130, 130, 1), + size: 11.sp, + fontWeight: FontWeight.w500), + quickText( + DateTime.parse(item.publishTime) + .toString() + .substring(0, 10), + color: + const Color.fromRGBO(97, 97, 97, 1), + size: 12.sp), + ], + ), + SizedBox(height: 10.h), + Row( + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(10.r), + ), + child: LinearPercentIndicator( + padding: EdgeInsets.zero, + animation: true, + lineHeight: 8.h, + animationDuration: 2500, + percent: item.annotateRate == null?0:item.annotateRate! / 100, + progressColor: + const Color(0xFF6888FD), + backgroundColor: + const Color(0xFFE8E8E8), + barRadius: Radius.circular(10.r), + ), + ), + ), + SizedBox( + width: 10.r, + ), + quickText( + '${item.annotateRate!.toStringAsFixed(0)}%', + size: 10.sp, + color: const Color(0xFF464646)), + ], + ), + // FavoriteButton(jobTaskItem.id, jobTaskItem.title), + ], + ), + ), + ], + ), + ), + ); + }, + itemCount: state.workList.length, + ), + ); + })), ], ), ); @@ -181,8 +362,8 @@ Widget $TermItem(BuildContext context, EntranceModel e, int data, borderRadius: BorderRadius.all(Radius.circular(8.r)), child: InkWell( onTap: () { - Get.toNamed(e.navigationUrl,arguments: {'page':e.page??''}); - }, + Get.toNamed(e.navigationUrl, arguments: {'page': e.page ?? ''}); + }, // splashColor: splashColor, borderRadius: BorderRadius.all(Radius.circular(8.r)),