添加作业首页

This commit is contained in:
1147192855@qq.com 2024-04-11 15:53:04 +08:00
parent 5a43ccffcf
commit ee41ad7d1b
4 changed files with 151 additions and 95 deletions

View File

@ -0,0 +1,12 @@
import 'package:json_annotation/json_annotation.dart';
part 'job_home_refresh_bus.g.dart';
@JsonSerializable()
class JobHomeRefreshBus extends Object {
JobHomeRefreshBus();
factory JobHomeRefreshBus.fromJson(Map<String, dynamic> srcJson) => _$JobHomeRefreshBusFromJson(srcJson);
Map<String, dynamic> toJson() => _$JobHomeRefreshBusToJson(this);
}

View File

@ -7,6 +7,8 @@
* @Description:
*/
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
@ -16,7 +18,9 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:marking_app/common/config/request_config.dart';
import 'package:marking_app/common/model/event_bus/job_home_refresh_bus.dart';
import 'package:marking_app/common/model/job/job_task_item.dart';
import 'package:marking_app/pages/common/event_bus_mixin.dart';
import 'package:marking_app/pages/homework_correction/components/new_version_of_homework/homework_tasks_view_item.dart';
import 'package:marking_app/provider/review_provider.dart';
import 'package:marking_app/routes/RouterManager.dart';
@ -40,14 +44,7 @@ class HomeworkCorrection extends StatefulHookConsumerWidget {
}
class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
with
CommonMixin,
TickerProviderStateMixin,
RefreshDataHandle<JobTaskItem, MarkingListParams>,
AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
with CommonMixin, EventBusMixin, TickerProviderStateMixin, RefreshDataHandle<JobTaskItem, MarkingListParams> {
/* Tab控制器 */
late TabController _tabController;
late TabController _tabController2;
@ -127,6 +124,7 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
_tabController.dispose();
_refreshController1.dispose();
_refreshController2.dispose();
eventCancel();
super.dispose();
}
@ -152,8 +150,6 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
@override
Widget build(BuildContext context) {
super.build(context); //super.build(null)
return AnnotatedRegion(
value: const SystemUiOverlayStyle(
systemNavigationBarColor: Color(0xFF000000),
@ -176,7 +172,19 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(flex: 1, child: SizedBox()),
Expanded(
flex: 1,
child: Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 10.w),
child: InkWell(
onTap: () => easyThrottle('BACK_JOB_HOME', () => Navigator.of(context).pop()),
child: Icon(
Icons.arrow_back_ios_sharp,
size: 16.sp,
),
),
)),
Expanded(
flex: 4,
child: Container(
@ -226,9 +234,7 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
child: quickText(
'待批阅',
size: 14.sp,
color: _tabIndex == 0
? Theme.of(context).primaryColor
: const Color.fromRGBO(80, 94, 110, 1),
color: _tabIndex == 0 ? Theme.of(context).primaryColor : const Color.fromRGBO(80, 94, 110, 1),
fontWeight: _tabIndex == 0 ? FontWeight.bold : null,
),
),
@ -246,9 +252,7 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
child: quickText(
'已批阅',
size: 14.sp,
color: _tabIndex == 1
? Theme.of(context).primaryColor
: const Color.fromRGBO(80, 94, 110, 1),
color: _tabIndex == 1 ? Theme.of(context).primaryColor : const Color.fromRGBO(80, 94, 110, 1),
fontWeight: _tabIndex == 1 ? FontWeight.bold : null,
),
),
@ -261,11 +265,9 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
flex: 1,
child: InkWell(
onTap: () {
RouterManager.router
.navigateTo(context, RouterManager.jobStudentGroupPath, transition: getTransition());
RouterManager.router.navigateTo(context, RouterManager.jobStudentGroupPath, transition: getTransition());
},
child: Icon(IconData(0xe63e, fontFamily: "AlibabaIcon"),
color: Color.fromRGBO(44, 48, 63, 1), size: 24.sp),
child: Icon(IconData(0xe63e, fontFamily: "AlibabaIcon"), color: Color.fromRGBO(44, 48, 63, 1), size: 24.sp),
),
),
],
@ -305,6 +307,9 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
data: markingDatas1,
onLoad: onMyLoad,
onRefresh: onMyRefresh,
eventFire: () {
eventFire(model: JobHomeRefreshBus());
},
),
$EasyRefresh(
controller: _refreshController2,
@ -313,6 +318,9 @@ class _HomeworkCorrectionState extends ConsumerState<HomeworkCorrection>
data: markingDatas2,
onLoad: onMyLoad,
onRefresh: onMyRefresh,
eventFire: () {
eventFire(model: JobHomeRefreshBus());
},
),
],
),
@ -334,6 +342,7 @@ Widget $easyRefresh({
required EasyRefreshController controller,
required Future<void> Function(EasyRefreshController controller, MarkingListParams params, int tab) onRefresh,
required Future<void> Function(EasyRefreshController controller, MarkingListParams params, int tab) onLoad,
required Function eventFire,
required MarkingListParams params,
required List<JobTaskItem> data,
required int tab,
@ -366,7 +375,10 @@ Widget $easyRefresh({
return HomeworkTasksViewItem(
completed: completed,
jobTaskItem: data[index],
call: () => controller.callRefresh(),
call: () {
controller.callRefresh();
eventFire();
},
);
},
itemCount: data.length,
@ -414,9 +426,7 @@ Widget $reviewedItem(BuildContext context, {required JobTaskItem jobTaskItem}) {
alignment: Alignment.center,
padding: EdgeInsets.only(left: 2.w),
decoration: BoxDecoration(
color: jobTaskItem.markingTypeEnum.name == '作业'
? const Color.fromRGBO(104, 136, 253, 1)
: const Color.fromRGBO(255, 175, 56, 1),
color: jobTaskItem.markingTypeEnum.name == '作业' ? 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),
@ -477,8 +487,7 @@ Widget $reviewedItem(BuildContext context, {required JobTaskItem jobTaskItem}) {
onTap: () => easyThrottle('go_to_homework_report', () {
RouterManager.router.navigateTo(
context,
RouterManager.jobReportPagePath +
'?title=${Uri.encodeComponent(jobTaskItem.title)}&id=${jobTaskItem.id}',
RouterManager.jobReportPagePath + '?title=${Uri.encodeComponent(jobTaskItem.title)}&id=${jobTaskItem.id}',
transition: getTransition(),
);
}),
@ -521,8 +530,7 @@ Widget $theTabBar({required TabController controller, ValueChanged<int>? onTap,
if (customTime.endDate != null) {
// print(customTime.startDate!.year == customTime.endDate!.year);
if (!isPad() && customTime.startDate!.year == customTime.endDate!.year) {
customTimeStr =
customTime.startDate.toString().substring(5, 10) + '~${customTime.endDate.toString().substring(5, 10)}';
customTimeStr = customTime.startDate.toString().substring(5, 10) + '~${customTime.endDate.toString().substring(5, 10)}';
} else {
customTimeStr += '~${customTime.endDate?.toString().substring(0, 10)}';
}

View File

@ -2,10 +2,15 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:marking_app/common/mixin/common.dart';
import 'package:marking_app/common/model/event_bus/job_home_refresh_bus.dart';
import 'package:marking_app/common/model/marking/marking_list_params.dart';
import 'package:marking_app/pages/common/event_bus_mixin.dart';
import 'package:marking_app/routes/RouterManager.dart';
import 'package:marking_app/utils/index.dart';
import 'package:marking_app/utils/my_text.dart';
import 'package:badges/badges.dart' as badges;
import '../../utils/my_future_builder.dart';
class JobHome extends StatefulWidget {
@ -15,16 +20,16 @@ class JobHome extends StatefulWidget {
State<JobHome> createState() => _JobHomeState();
}
class _JobHomeState extends State<JobHome> with CommonMixin, AutomaticKeepAliveClientMixin {
class _JobHomeState extends State<JobHome> with CommonMixin, EventBusMixin, AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
late Future _future;
late Future<int> _future;
List<EntranceModel> entrances = [
EntranceModel(
title: '作业批阅',
image: '',
navigationUrl: '',
navigationUrl: RouterManager.jobMainListPagePath,
),
EntranceModel(
title: '学生历史作业',
@ -56,19 +61,32 @@ class _JobHomeState extends State<JobHome> with CommonMixin, AutomaticKeepAliveC
@override
void initState() {
_future = getData();
eventOn(callback: (JobHomeRefreshBus item) {
_future = getData();
toUpState(setState, () {}, mounted);
});
super.initState();
}
Future getData() async {
var _client = await getClient();
var _result = await _client.getJobsByPage(MarkingListParams(
isFinish: false,
page: 1,
limit: 1,
pageType: 0,
));
if (_result == null) return 0;
return _result.data?.total ?? 0;
@override
void dispose() {
eventCancel();
super.dispose();
}
Future<int> getData() async {
try {
var _client = await getClient();
var _result = await _client.getJobsByPage(MarkingListParams(
isFinish: false,
page: 1,
limit: 1,
pageType: 0,
));
return _result.data?.total ?? 0;
} catch (e) {
return 0;
}
}
@override
@ -97,7 +115,7 @@ class _JobHomeState extends State<JobHome> with CommonMixin, AutomaticKeepAliveC
_future = getData();
toUpState(setState, () {}, mounted);
},
child: MyFutureBuilder.buildFutureBuilderOfSingleInstance(context, _future, (data) {
child: MyFutureBuilder.buildFutureBuilderOfSingleInstance<int>(context, _future, (data) {
if (data == null)
return Center(
child: Container(
@ -112,22 +130,50 @@ class _JobHomeState extends State<JobHome> with CommonMixin, AutomaticKeepAliveC
);
return Container(
padding: EdgeInsets.symmetric(vertical: 40.h, horizontal: 20.w),
child: GridView(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 10.r,
crossAxisSpacing: 10.r,
childAspectRatio: 556 / 112,
mainAxisSpacing: 24.r,
crossAxisSpacing: 24.r,
childAspectRatio: 556 / 200,
),
children: entrances.map((e) {
return Container(
alignment: Alignment.center,
child: Row(
children: [
quickText(e.title),
],
),
);
bool isJob = e.title == '作业批阅';
return InkWell(
onTap: () => easyThrottle('GO_TO_JOB_HOME_NAVIGATION', () {
RouterManager.router.navigateTo(context, e.navigationUrl, transition: getTransition());
}),
child: badges.Badge(
showBadge: isJob && data > 0,
ignorePointer: false,
badgeContent: quickText(data, color: Colors.white),
badgeAnimation: badges.BadgeAnimation.rotation(
animationDuration: Duration(seconds: 1),
colorChangeAnimationDuration: Duration(seconds: 1),
loopAnimation: false,
curve: Curves.fastOutSlowIn,
colorChangeAnimationCurve: Curves.easeInCubic,
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.r)),
border: Border.all(
width: 0.5.w,
color: Color.fromARGB(255, 219, 226, 250),
),
),
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Image(image: e.image),
quickText(e.title, size: 12.sp),
],
),
),
));
}).toList(),
),
);

View File

@ -7,13 +7,12 @@
* @Description:
*/
import 'dart:convert';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:marking_app/common/model/enum/marking_list_type.dart';
import 'package:marking_app/pages/common/startUpPage.dart';
import 'package:marking_app/pages/homework_correction/do_papers_job_exam.dart';
import 'package:marking_app/pages/homework_correction/index.dart';
import 'package:marking_app/pages/homework_correction/job_personal_detail.dart';
import 'package:marking_app/pages/homework_correction/job_priority_review_set.dart';
import 'package:marking_app/pages/homework_correction/job_report.dart';
@ -64,6 +63,8 @@ class RouterManager {
static const String jobListParticipateInClassPath = '/job/list/participateInClass';
// ==>
static const String jobFavoritePagePath = '/job/favorite/index';
// ==>
static const String jobMainListPagePath = '/job/mainList/index';
static const String reportClassTeacherPath = 'report/details/reportClassTeacher';
static const String reportSubjectTeacherPath = 'report/details/reportSubjectTeacher';
@ -100,18 +101,14 @@ class RouterManager {
}
//
static final _startUpPageHandler =
Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const StartUpPage());
static final _startUpPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const StartUpPage());
//
static final _mainPageHandler =
Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const TheMainPage());
static final _mainPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const TheMainPage());
//
static final _loginPageHandler =
Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const TheLogin());
static final _loginPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const TheLogin());
//
static final _progressPageHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> params) =>
Progress(int.parse(params['examSubjectId']![0]), params['name']![0]));
handlerFunc: (BuildContext? context, Map<String, List<String>> params) => Progress(int.parse(params['examSubjectId']![0]), params['name']![0]));
//
static final _reviewPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
int markingUserId = int.parse(params['markingUserId']![0]);
@ -130,11 +127,8 @@ class RouterManager {
//
static final _reviewAbnormalPageHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> params) => ProgressAbnormal(
int.parse(params['examSubjectId']![0]),
params['markingId']![0],
params['name']![0],
params['questionNum']![0]));
handlerFunc: (BuildContext? context, Map<String, List<String>> params) =>
ProgressAbnormal(int.parse(params['examSubjectId']![0]), params['markingId']![0], params['name']![0], params['questionNum']![0]));
//
static final _markingDoPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
try {
@ -176,8 +170,7 @@ class RouterManager {
}
});
//
static final _markingHomeworkDoPageHandler =
Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
static final _markingHomeworkDoPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
try {
int taskId = int.parse(params['taskId']![0]);
int jobId = int.parse(params['jobId']![0]);
@ -221,8 +214,7 @@ class RouterManager {
handlerFunc: (BuildContext? context, Map<String, List<String>> params) => const OhterPage(),
);
static final _reportClassTeacherPageHandler =
Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
static final _reportClassTeacherPageHandler = Handler(handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
int examId = int.parse(params['examId']![0]);
return ReportClassTeacher(examId: examId);
@ -292,7 +284,7 @@ class RouterManager {
if (params['gradeId'] != null && params['gradeId']?[0] != null && params['gradeId']![0] != 'null') {
gradeId = int.parse(params['gradeId']![0]);
}
return QuickDataCheckPage(jobId: jobId, className: className,gradeName:gradeName,schoolId:schoolId,gradeId:gradeId);
return QuickDataCheckPage(jobId: jobId, className: className, gradeName: gradeName, schoolId: schoolId, gradeId: gradeId);
},
);
@ -310,7 +302,7 @@ class RouterManager {
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
String groupId = params['groupId']![0];
String title = params['title']![0];
return JobPriorityReviewSet(groupId: groupId,title:title);
return JobPriorityReviewSet(groupId: groupId, title: title);
},
);
@ -334,7 +326,7 @@ class RouterManager {
if (params['gradeId'] != null && params['gradeId']?[0] != null && params['gradeId']![0] != 'null') {
gradeId = int.parse(params['gradeId']![0]);
}
return JobFavorite(jobId: jobId, gradeId: gradeId, schoolId: schoolId, className: className,jobName:jobName);
return JobFavorite(jobId: jobId, gradeId: gradeId, schoolId: schoolId, className: className, jobName: jobName);
},
);
@ -343,14 +335,19 @@ class RouterManager {
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
String studentName = params['studentName']![0];
int studentId = int.parse(params['studentId']![0]);
return JobPersonalDetail(studentId: studentId,studentName:studentName);
return JobPersonalDetail(studentId: studentId, studentName: studentName);
},
);
//
static final _jobMainListPathHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> params) => HomeworkCorrection(),
);
//
static final _reportCardDialogPathHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
/* String studentName = params['studentName']![0];
/* String studentName = params['studentName']![0];
int studentId = int.parse(params['studentId']![0]);
return ReportCardDialog(studentId: studentId,studentName:studentName);*/
},
@ -358,7 +355,7 @@ class RouterManager {
//
static final _reportHistoryPathHandler = Handler(
handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
/* String studentName = params['studentName']![0];
/* String studentName = params['studentName']![0];
int studentId = int.parse(params['studentId']![0]);*/
return ReportHistory();
},
@ -380,35 +377,28 @@ class RouterManager {
router.define(markingReviewPath, handler: _reviewPageHandler, transitionType: TransitionType.material);
router.define(markingJobReviewPath, handler: _reviewJobPageHandler, transitionType: TransitionType.material);
router.define(markingDoPath, handler: _markingDoPageHandler, transitionType: TransitionType.material);
router.define(markingHomeworkDoPath,
handler: _markingHomeworkDoPageHandler, transitionType: TransitionType.material);
router.define(markingReviewAbnormalPath,
handler: _reviewAbnormalPageHandler, transitionType: TransitionType.material);
router.define(markingHomeworkDoPath, handler: _markingHomeworkDoPageHandler, transitionType: TransitionType.material);
router.define(markingReviewAbnormalPath, handler: _reviewAbnormalPageHandler, transitionType: TransitionType.material);
router.define(agreementPath, handler: _agreementPageHandler, transitionType: TransitionType.material);
router.define(ohterMainPagePath, handler: _ohterMainPageHandler, transitionType: TransitionType.material);
router.define(reportClassTeacherPath,
handler: _reportClassTeacherPageHandler, transitionType: TransitionType.material);
router.define(reportSubjectTeacherPath,
handler: _reportSubjectTeacherPageHandler, transitionType: TransitionType.material);
router.define(reportPersonalSubjectPath,
handler: _reportPersonalSubjectPageHandler, transitionType: TransitionType.material);
router.define(reportClassTeacherPath, handler: _reportClassTeacherPageHandler, transitionType: TransitionType.material);
router.define(reportSubjectTeacherPath, handler: _reportSubjectTeacherPageHandler, transitionType: TransitionType.material);
router.define(reportPersonalSubjectPath, handler: _reportPersonalSubjectPageHandler, transitionType: TransitionType.material);
router.define(userMinePath, handler: _userMinePageHandler, transitionType: TransitionType.material);
router.define(reportDetailPath, handler: _reportDetailPath, transitionType: TransitionType.material);
router.define(jobReportPagePath, handler: _jobReportPageHandler, transitionType: TransitionType.material);
router.define(jobExamPagePath, handler: _jobExamPageHandler, transitionType: TransitionType.material);
router.define(jobListParticipateInClassPath,
handler: _jobListParticipateInClassHandler, transitionType: TransitionType.material);
router.define(jobListParticipateInClassPath, handler: _jobListParticipateInClassHandler, transitionType: TransitionType.material);
router.define(quickDataCheckPath, handler: _quickDataCheckPageHandler, transitionType: TransitionType.material);
router.define(quickCheckPersonalPath,
handler: _quickCheckPersonalPageHandler, transitionType: TransitionType.material);
router.define(jobPriorityReviewSetPath,
handler: _jobPriorityReviewSetPageHandler, transitionType: TransitionType.material);
router.define(quickCheckPersonalPath, handler: _quickCheckPersonalPageHandler, transitionType: TransitionType.material);
router.define(jobPriorityReviewSetPath, handler: _jobPriorityReviewSetPageHandler, transitionType: TransitionType.material);
router.define(jobStudentGroupPath, handler: _jobStudentGroupPageHandler, transitionType: TransitionType.material);
router.define(jobFavoritePagePath, handler: _jobFavoritePagePathHandler, transitionType: TransitionType.material);
router.define(jobPersonalDetailPath, handler: _jobPersonalDetailPathHandler, transitionType: TransitionType.material);
router.define(reportCardDialogPath, handler: _reportCardDialogPathHandler, transitionType: TransitionType.material);
router.define(reportHistoryPath, handler: _reportHistoryPathHandler, transitionType: TransitionType.material);
router.define(jobMainListPagePath, handler: _jobMainListPathHandler, transitionType: TransitionType.material);
// getTransition()