修复部分代码

This commit is contained in:
DESKTOP-I3JPKHK\wy 2025-09-23 16:16:59 +08:00
parent c6409b095c
commit 10025b49ee
5 changed files with 435 additions and 385 deletions

View File

@ -8,6 +8,7 @@ import 'package:making_school_asignment_app/common/job/annotated_class.dart';
import 'package:making_school_asignment_app/common/utils/utils.dart'; import 'package:making_school_asignment_app/common/utils/utils.dart';
import 'package:making_school_asignment_app/page/global_widget/ReturnToHomepage.dart'; import 'package:making_school_asignment_app/page/global_widget/ReturnToHomepage.dart';
import 'package:making_school_asignment_app/page/home_page/children/annotate_class/widget/annotate_item.dart'; import 'package:making_school_asignment_app/page/home_page/children/annotate_class/widget/annotate_item.dart';
import 'annotate_class_logic.dart'; import 'annotate_class_logic.dart';
import 'widget/completed_annotate_item.dart'; import 'widget/completed_annotate_item.dart';
@ -27,23 +28,21 @@ class _AnnotateClassPageState extends State<AnnotateClassPage> {
String homeworkId = state.homeworkId.value; String homeworkId = state.homeworkId.value;
return AnnotatedRegion( return AnnotatedRegion(
value: const SystemUiOverlayStyle( value: const SystemUiOverlayStyle(
systemNavigationBarColor:Colors.transparent, systemNavigationBarColor: Colors.transparent,
systemNavigationBarDividerColor: null, systemNavigationBarDividerColor: null,
statusBarColor: Colors.transparent, statusBarColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.light, systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light, statusBarBrightness: Brightness.light,
), ),
child: OrientationBuilder( child: OrientationBuilder(builder: (BuildContext context, Orientation orientation) {
builder: (BuildContext context, Orientation orientation) {
return Scaffold( return Scaffold(
backgroundColor: const Color.fromRGBO(245, 245, 245, 1), backgroundColor: const Color.fromRGBO(245, 245, 245, 1),
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.white, backgroundColor: Colors.white,
elevation: 0.3,
title: Obx(() { title: Obx(() {
return Text(state.name.value, return Text(state.name.value, style: TextStyle(fontSize: 14.sp, color: const Color(0xFF333333)));
style:
TextStyle(fontSize: 14.sp, color: const Color(0xFF333333)));
}), }),
centerTitle: true, centerTitle: true,
leading: IconButton( leading: IconButton(
@ -71,8 +70,7 @@ class _AnnotateClassPageState extends State<AnnotateClassPage> {
child: state.completed.value child: state.completed.value
? Utils.isPad() ? Utils.isPad()
? GridView( ? GridView(
gridDelegate: gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, //widget crossAxisCount: 2, //widget
mainAxisSpacing: 10.h, mainAxisSpacing: 10.h,
crossAxisSpacing: 6.w, crossAxisSpacing: 6.w,

View File

@ -94,7 +94,7 @@ class _AnnotateItemState extends State<AnnotateItem> {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return ShowStudentList( return ShowStudentList(
title: '${widget.item.className ?? ''} ${submitted ? '已提交' : '未提交'}作业学生', title: '${widget.item.className} ${submitted ? '已提交' : '未提交'}作业学生',
studentList: students, studentList: students,
homeworkId: widget.homeworkId, homeworkId: widget.homeworkId,
subject: widget.logic.state.subject, subject: widget.logic.state.subject,
@ -133,7 +133,7 @@ class _AnnotateItemState extends State<AnnotateItem> {
}, },
child: Text( child: Text(
'已交:${widget.item.commitStudentCount}', '已交:${widget.item.commitStudentCount}',
style: TextStyle(fontSize: widget.font - 2.sp, color: const Color(0xFF4CC793)), style: TextStyle(fontSize: widget.font - 2.sp, color: Theme.of(context).primaryColor),
), ),
), ),
SizedBox( SizedBox(
@ -256,12 +256,7 @@ class _AnnotateItemState extends State<AnnotateItem> {
linearGradient: LinearGradient( linearGradient: LinearGradient(
tileMode: TileMode.mirror, tileMode: TileMode.mirror,
stops: const [0.0, 1.0], stops: const [0.0, 1.0],
colors: widget.item.annotateRate / 100 != 1 colors: [Theme.of(context).primaryColor.withOpacity(0.1), Theme.of(context).primaryColor],
? [Theme.of(context).primaryColor.withOpacity(0.1), Theme.of(context).primaryColor]
: [
const Color.fromRGBO(144, 224, 190, 1).withOpacity(0.1),
const Color.fromRGBO(144, 224, 190, 1),
],
), ),
// linearStrokeCap: LinearStrokeCap.butt, // linearStrokeCap: LinearStrokeCap.butt,
// progressColor: Theme.of(context).primaryColor, // progressColor: Theme.of(context).primaryColor,
@ -271,21 +266,21 @@ class _AnnotateItemState extends State<AnnotateItem> {
), ),
ProgressBar( ProgressBar(
title: '客观题正确率:', title: '客观题正确率:',
color: const Color(0xFFADDCA5), color: Theme.of(context).primaryColor,
percent: widget.item.kgtCorrectRate / 100, percent: widget.item.kgtCorrectRate / 100,
marginEdg: EdgeInsets.zero, marginEdg: EdgeInsets.zero,
padingEdg: EdgeInsets.only(top: 8.h, left: 14.r, right: 14.r), padingEdg: EdgeInsets.only(top: 8.h, left: 14.r, right: 14.r),
fontSize: widget.font - 2.sp), fontSize: widget.font - 2.sp),
ProgressBar( ProgressBar(
title: '主观题正确率:', title: '主观题正确率:',
color: const Color(0xFFADDCA5), color: Theme.of(context).primaryColor,
percent: widget.item.zgtCorrectRate / 100, percent: widget.item.zgtCorrectRate / 100,
padingEdg: EdgeInsets.symmetric(horizontal: 10.r), padingEdg: EdgeInsets.symmetric(horizontal: 10.r),
marginEdg: EdgeInsets.only(top: 8.h), marginEdg: EdgeInsets.only(top: 8.h),
fontSize: widget.font - 2.sp), fontSize: widget.font - 2.sp),
ProgressBar( ProgressBar(
title: '总正确率:', title: '总正确率:',
color: const Color(0xFFADDCA5), color: Theme.of(context).primaryColor,
percent: widget.item.correctRate / 100, percent: widget.item.correctRate / 100,
padingEdg: EdgeInsets.symmetric(horizontal: 10.r), padingEdg: EdgeInsets.symmetric(horizontal: 10.r),
marginEdg: EdgeInsets.only(top: 8.h), marginEdg: EdgeInsets.only(top: 8.h),

View File

@ -29,9 +29,14 @@ class _FavStudentPageState extends State<FavStudentPage> {
return AlertDialog( return AlertDialog(
insetPadding: EdgeInsets.all(25.r), insetPadding: EdgeInsets.all(25.r),
content: FavoriteStudentDialog( content: FavoriteStudentDialog(
item: item, group: groups, deleteFav: logic.getDelete, confirmDialog: confirmDialog), item: item,
group: groups,
deleteFav: logic.getDelete,
confirmDialog: confirmDialog,
),
contentPadding: const EdgeInsets.all(0), contentPadding: const EdgeInsets.all(0),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15.r)))); shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15.r))),
);
}, },
); );
} }

View File

@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_rx/get_rx.dart';
import 'package:making_school_asignment_app/common/config/request_config.dart'; import 'package:making_school_asignment_app/common/config/request_config.dart';
import 'package:making_school_asignment_app/common/job/annotated_class.dart'; import 'package:making_school_asignment_app/common/job/annotated_class.dart';
import 'package:making_school_asignment_app/page/global_widget/MyEmptyWidget.dart'; import 'package:making_school_asignment_app/page/global_widget/MyEmptyWidget.dart';
@ -15,12 +13,8 @@ class FavoriteStudentDialog extends StatefulWidget {
final Function deleteFav; final Function deleteFav;
final Future<bool> Function() confirmDialog; final Future<bool> Function() confirmDialog;
const FavoriteStudentDialog({Key? key, const FavoriteStudentDialog(
required this.item, {super.key, required this.item, required this.group, required this.deleteFav, required this.confirmDialog});
required this.group,
required this.deleteFav,
required this.confirmDialog})
: super(key: key);
@override @override
State<FavoriteStudentDialog> createState() => _FavoriteStudentDialogState(); State<FavoriteStudentDialog> createState() => _FavoriteStudentDialogState();
@ -30,7 +24,7 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
RxInt defaultIndex = 0.obs; RxInt defaultIndex = 0.obs;
RxList<HomeworkFavs> imageList = RxList(); RxList<HomeworkFavs> imageList = RxList();
late PageController pageController; late PageController pageController;
late Rx<HomeworkFavs> currentStudent = Rx(HomeworkFavs('','','',-1,-1,'','',-1,'',-1,'-1','','')); late Rx<HomeworkFavs> currentStudent = Rx(HomeworkFavs('', '', '', -1, -1, '', '', -1, '', -1, '-1', '', ''));
@override @override
void initState() { void initState() {
@ -43,8 +37,7 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
} }
} }
imageList.value = list; imageList.value = list;
defaultIndex.value = defaultIndex.value = list.indexWhere((element) => element.id == widget.item.id);
list.indexWhere((element) => element.id == widget.item.id);
pageController = PageController(initialPage: defaultIndex.value); pageController = PageController(initialPage: defaultIndex.value);
} }
@ -58,14 +51,8 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
width: MediaQuery width: MediaQuery.of(context).size.width,
.of(context) height: MediaQuery.of(context).size.height,
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
padding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 14.r), padding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 14.r),
child: Column( child: Column(
children: [ children: [
@ -74,16 +61,17 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
children: [ children: [
Obx(() { Obx(() {
return Text( return Text(
'${currentStudent.value.className} ${currentStudent.value '${currentStudent.value.className} ${currentStudent.value.studentName}',
.studentName}',
style: TextStyle(fontSize: 12.sp, color: Theme.of(context).primaryColor), style: TextStyle(fontSize: 12.sp, color: Theme.of(context).primaryColor),
); );
}), }),
Expanded(child: Container()), Expanded(child: Container()),
Text( Obx(() {
return Text(
'${currentStudent.value.questionNo}', '${currentStudent.value.questionNo}',
style: TextStyle(fontSize: 12.sp, color: Color(0xFF868686)), style: TextStyle(fontSize: 12.sp, color: const Color(0xFF868686)),
), );
}),
InkWell( InkWell(
onTap: () async { onTap: () async {
bool confim = await widget.confirmDialog(); bool confim = await widget.confirmDialog();
@ -94,8 +82,7 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
if (defaultIndex.value < imageList.length) { if (defaultIndex.value < imageList.length) {
currentStudent.value = imageList[defaultIndex.value]; currentStudent.value = imageList[defaultIndex.value];
} else { } else {
currentStudent.value = currentStudent.value = imageList[defaultIndex.value - 1];
imageList[defaultIndex.value - 1];
defaultIndex = defaultIndex - 1; defaultIndex = defaultIndex - 1;
} }
} else { } else {
@ -133,10 +120,7 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
? Expanded( ? Expanded(
child: Container( child: Container(
color: Colors.white, color: Colors.white,
width: MediaQuery width: MediaQuery.of(context).size.width,
.of(context)
.size
.width,
child: PhotoViewGallery.builder( child: PhotoViewGallery.builder(
scrollPhysics: const BouncingScrollPhysics(), scrollPhysics: const BouncingScrollPhysics(),
builder: (BuildContext context, int index) { builder: (BuildContext context, int index) {
@ -157,16 +141,13 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
), ),
) )
: Padding( : Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(top: MediaQuery.of(context).size.height / 2 - 200.r),
top: MediaQuery
.of(context)
.size
.height / 2 - 200.r),
child: const MyEmptyWidget(), child: const MyEmptyWidget(),
); );
}), }),
Obx(() { Obx(() {
return imageList.isNotEmpty?Padding( return imageList.isNotEmpty
? Padding(
padding: EdgeInsets.symmetric(vertical: 15.r), padding: EdgeInsets.symmetric(vertical: 15.r),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -179,27 +160,18 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
} }
}, },
child: Container( child: Container(
width: width: (MediaQuery.of(context).size.width - 78.r) / 2 - 10.r,
(MediaQuery
.of(context)
.size
.width - 78.r) / 2 - 10.r,
height: 28.r, height: 28.r,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.r)), borderRadius: BorderRadius.all(Radius.circular(6.r)),
border: Border.all( border: Border.all(width: 1.r, color: const Color(0xFFCACACA), style: BorderStyle.solid),
width: 1.r,
color: Color(0xFFCACACA),
style: BorderStyle.solid),
), ),
child: Center( child: Center(
child: Text( child: Text(
'上一页', '上一页',
style: TextStyle( style: TextStyle(
fontSize: 10.r, fontSize: 10.r,
color: defaultIndex == 0 color: defaultIndex == 0 ? const Color(0xFFCACACA) : const Color(0xFF505E6E)),
? Color(0xFFCACACA)
: Color(0xFF505E6E)),
)), )),
), ),
), ),
@ -211,18 +183,11 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
} }
}, },
child: Container( child: Container(
width: width: (MediaQuery.of(context).size.width - 78.r) / 2 - 10.r,
(MediaQuery
.of(context)
.size
.width - 78.r) / 2 - 10.r,
height: 28.r, height: 28.r,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.r)), borderRadius: BorderRadius.all(Radius.circular(6.r)),
border: Border.all( border: Border.all(width: 1.r, color: const Color(0xFFCACACA), style: BorderStyle.solid),
width: 1.r,
color: Color(0xFFCACACA),
style: BorderStyle.solid),
), ),
child: Center( child: Center(
child: Text( child: Text(
@ -230,14 +195,15 @@ class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
style: TextStyle( style: TextStyle(
fontSize: 10.r, fontSize: 10.r,
color: defaultIndex == imageList.length - 1 color: defaultIndex == imageList.length - 1
? Color(0xFFCACACA) ? const Color(0xFFCACACA)
: Color(0xFF505E6E)), : const Color(0xFF505E6E)),
)), )),
), ),
), ),
], ],
), ),
):Container(); )
: Container();
}) })
], ],
), ),

View File

@ -15,8 +15,42 @@ import 'original_manuscript_handwriting/answer_handwriting_view.dart';
part 'dropdown_switch_students_type.g.dart'; part 'dropdown_switch_students_type.g.dart';
/// //
class _Constants {
static const double containerHeight = 30.0;
static const double borderRadius = 4.0;
static const double iconSize = 12.0;
static const double textSize = 14.0;
static const double smallTextSize = 12.0;
static const double tinyTextSize = 4.0;
//
static const Color shadowColor = Color.fromRGBO(46, 91, 255, 0.2);
static const Color backgroundColor = Color.fromRGBO(244, 244, 244, 1);
static const Color textColor = Color.fromRGBO(79, 79, 79, 1);
static const Color iconColor = Color.fromRGBO(104, 103, 103, 1);
static const Color priorityIconDisabledColor = Color.fromRGBO(164, 164, 164, 1);
//
static const double paddingSmall = 2.0;
static const double paddingMedium = 8.0;
static const double paddingLarge = 12.0;
static const double paddingXL = 13.0;
//
static const double shadowBlurRadius = 14.0;
static const double shadowSpreadRadius = 0.5;
static const Offset shadowOffset = Offset(2.0, 2.0);
}
///
/// ///
///
/// -
/// -
/// -
/// -
/// -
class DropdownSwitchStudentsType extends StatelessWidget { class DropdownSwitchStudentsType extends StatelessWidget {
const DropdownSwitchStudentsType({super.key}); const DropdownSwitchStudentsType({super.key});
@ -24,19 +58,20 @@ class DropdownSwitchStudentsType extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final logic = Get.find<HomeworkReviewLogic>(); final logic = Get.find<HomeworkReviewLogic>();
final sateData = logic.state.data; final stateData = logic.state.data;
return Container( return Container(
height: 30.h, height: _Constants.containerHeight.h,
padding: EdgeInsets.only(bottom: 2.r, left: 12.r, right: 12.r), padding: EdgeInsets.only(
bottom: _Constants.paddingSmall.r, left: _Constants.paddingLarge.r, right: _Constants.paddingLarge.r),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: const Color.fromRGBO(46, 91, 255, 0.2), color: _Constants.shadowColor,
offset: Offset(2.w, 2.h), //y轴偏移量 offset: Offset(_Constants.shadowOffset.dx.w, _Constants.shadowOffset.dy.h),
blurRadius: 14, // blurRadius: _Constants.shadowBlurRadius,
spreadRadius: 0.5, // spreadRadius: _Constants.shadowSpreadRadius,
) )
], ],
), ),
@ -44,149 +79,14 @@ class DropdownSwitchStudentsType extends StatelessWidget {
children: [ children: [
Expanded( Expanded(
flex: 2, flex: 2,
child: Container( child: _buildPageDropdown(logic, stateData),
padding: EdgeInsets.only(left: 10.w),
decoration: BoxDecoration(
color: const Color.fromRGBO(244, 244, 244, 1),
borderRadius: BorderRadius.circular(4.r),
), ),
child: Obx(() { SizedBox(width: _Constants.paddingMedium.w),
return DropdownButton(
isExpanded: true,
underline: Container(),
padding: EdgeInsets.only(right: 4.w),
icon: const Icon(Icons.keyboard_arrow_down_rounded),
value: sateData.value?.templateId,
hint: const Text('请选择作业页码'), //
items: sateData.value?.templateIdKeys?.map((e) {
return DropdownMenuItem(
value: e,
child: quickText('${sateData.value!.templateIdKeyMap![e]}',
color: const Color.fromRGBO(79, 79, 79, 1), size: 14.sp),
);
}).toList(),
onChanged: (value) {
if (logic.state.param.value.templateId == value) return;
var templateIds = logic.state.data.value?.templateIds;
if (value != null && templateIds != null) {
final templateIdKeyMap = logic.state.data.value?.templateIdKeyMap;
var answeredAlready = templateIds[value.toString()];
if (answeredAlready != null && !answeredAlready) {
final currentStudentId = sateData.value?.studentId;
final students = sateData.value?.students ?? [];
//
PaperStudents? currentStudent;
if (currentStudentId != null) {
try {
currentStudent = students.firstWhere((e) => e.id == currentStudentId);
} catch (e) {
currentStudent = null;
}
}
final studentName = currentStudent?.name ?? '当前学生';
final questionNumber = templateIdKeyMap?[value] ?? '当前选择页';
ToastUtils.showInfo("$studentName第$questionNumber页,未作答 无需批阅");
return;
}
}
logic.state.param.value.templateId = value;
logic.state.param.value = DoPaperDetailsParam.fromJson(logic.state.param.value.toJson());
// _useSwitchStudentAndType.currentTab.value = _useSwitchStudentAndType.tabs.value.firstWhere((element) => element.pageIndex == value);
},
);
}),
),
),
SizedBox(width: 8.w),
Expanded( Expanded(
flex: 3, flex: 3,
child: Stack( child: _buildStudentDropdown(context, logic, stateData),
children: [
Container(
padding: EdgeInsets.only(left: 13.w),
decoration: BoxDecoration(
color: const Color.fromRGBO(244, 244, 244, 1),
borderRadius: BorderRadius.circular(4.r),
), ),
child: Obx(() { SizedBox(width: _Constants.paddingMedium.w),
return DropdownButton(
padding: EdgeInsets.only(right: 4.w),
icon: const Icon(Icons.keyboard_arrow_down_rounded),
value: sateData.value?.studentId,
underline: Container(),
isExpanded: true,
items: sateData.value?.students.map((e) {
return DropdownMenuItem(
value: e.id,
child: Stack(
alignment: const FractionalOffset(0, 0.62),
children: [
Container(
padding: sateData.value?.studentId != e.id && e.isPriority
? EdgeInsets.only(left: 14.w)
: null,
child: quickText(
e.name,
size: 14.sp,
color: const Color.fromRGBO(79, 79, 79, 1),
),
),
if (e.isPriority && sateData.value?.studentId != e.id)
Stack(
alignment: const FractionalOffset(0.52, 0.24),
children: [
Icon(
const IconData(0xe63d, fontFamily: "AlibabaIcon"),
size: 12.sp,
color: e.isPriority
? Theme.of(context).primaryColor
: const Color.fromRGBO(164, 164, 164, 1),
),
quickText('优先', size: 4.sp, color: Colors.white),
],
),
],
),
);
}).toList(),
hint: const Text('请选择学生'), //
onChanged: (value) {
if (logic.state.param.value.studentId == value) return;
logic.state.param.value.studentId = value;
logic.state.param.value = DoPaperDetailsParam.fromJson(logic.state.param.value.toJson());
},
);
}),
),
Positioned(
left: 2.w,
child: Stack(
alignment: const FractionalOffset(0.52, 0.24),
children: [
Obx(() {
return Icon(
const IconData(0xe63d, fontFamily: "AlibabaIcon"),
size: 12.sp,
color: sateData.value?.priority ?? false
? Theme.of(context).primaryColor
: const Color.fromRGBO(164, 164, 164, 1),
);
}),
quickText('优先', size: 4.sp, color: Colors.white),
],
),
),
],
),
),
// const Expanded(flex: 1, child: SizedBox()),
SizedBox(width: 8.w),
const Expanded( const Expanded(
flex: 5, flex: 5,
child: Row( child: Row(
@ -203,137 +103,323 @@ class DropdownSwitchStudentsType extends StatelessWidget {
), ),
); );
} }
///
Widget _buildPageDropdown(HomeworkReviewLogic logic, Rx<DoPaperDetailsResult?> stateData) {
return Container(
padding: EdgeInsets.only(left: 10.w),
decoration: BoxDecoration(
color: _Constants.backgroundColor,
borderRadius: BorderRadius.circular(_Constants.borderRadius.r),
),
child: Obx(() {
final data = stateData.value;
return DropdownButton(
isExpanded: true,
underline: Container(),
padding: EdgeInsets.only(right: 4.w),
icon: const Icon(Icons.keyboard_arrow_down_rounded),
value: data?.templateId,
hint: const Text('请选择作业页码'),
items: data?.templateIdKeys?.map((e) {
return DropdownMenuItem(
value: e,
child: quickText(
'${data.templateIdKeyMap![e]}',
color: _Constants.textColor,
size: _Constants.textSize.sp,
),
);
}).toList(),
onChanged: (value) => _handlePageChange(logic, value),
);
}),
);
}
///
Widget _buildStudentDropdown(BuildContext context, HomeworkReviewLogic logic, Rx<DoPaperDetailsResult?> stateData) {
return Container(
padding: EdgeInsets.only(left: _Constants.paddingXL.w),
decoration: BoxDecoration(
color: _Constants.backgroundColor,
borderRadius: BorderRadius.circular(_Constants.borderRadius.r),
),
child: Obx(() {
final data = stateData.value;
return DropdownButton(
padding: EdgeInsets.only(right: 4.w),
icon: const Icon(Icons.keyboard_arrow_down_rounded),
value: data?.studentId,
underline: Container(),
isExpanded: true,
items: data?.students.map((student) {
return DropdownMenuItem(
value: student.id,
child: _buildStudentItem(context, student),
);
}).toList(),
hint: const Text('请选择学生'),
onChanged: (value) => _handleStudentChange(logic, value),
);
}),
);
}
///
Widget _buildStudentItem(BuildContext context, PaperStudents student) {
return Stack(
alignment: const FractionalOffset(0, 0.5),
children: [
Container(
padding: EdgeInsets.only(left: 16.w),
child: quickText(
student.name,
size: _Constants.textSize.sp,
color: _Constants.textColor,
),
),
Stack(
alignment: const FractionalOffset(0.52, 0.26),
children: [
Icon(
const IconData(0xe63d, fontFamily: "AlibabaIcon"),
size: _Constants.iconSize.sp,
color: student.isPriority ? Theme.of(context).primaryColor : _Constants.priorityIconDisabledColor,
),
quickText('优先', size: _Constants.tinyTextSize.sp, color: Colors.white),
],
),
],
);
}
///
void _handlePageChange(HomeworkReviewLogic logic, dynamic value) {
if (logic.state.param.value.templateId == value) return;
final templateIds = logic.state.data.value?.templateIds;
if (value == null || templateIds == null) return;
final templateIdKeyMap = logic.state.data.value?.templateIdKeyMap;
final answeredAlready = templateIds[value.toString()];
if (answeredAlready != null && !answeredAlready) {
_showUnansweredPageToast(logic.state.data.value, value, templateIdKeyMap);
return;
}
logic.state.param.value.templateId = value;
logic.state.param.value = DoPaperDetailsParam.fromJson(logic.state.param.value.toJson());
}
///
void _handleStudentChange(HomeworkReviewLogic logic, dynamic value) {
if (logic.state.param.value.studentId == value) return;
logic.state.param.value.studentId = value;
logic.state.param.value = DoPaperDetailsParam.fromJson(logic.state.param.value.toJson());
}
///
void _showUnansweredPageToast(DoPaperDetailsResult? data, dynamic value, Map<dynamic, dynamic>? templateIdKeyMap) {
final currentStudentId = data?.studentId;
final students = data?.students ?? [];
//
PaperStudents? currentStudent;
if (currentStudentId != null) {
try {
currentStudent = students.firstWhere((e) => e.id == currentStudentId);
} catch (e) {
currentStudent = null;
}
}
final studentName = currentStudent?.name ?? '当前学生';
final questionNumber = templateIdKeyMap?[value] ?? '当前选择页';
ToastUtils.showInfo("$studentName第$questionNumber页,未作答 无需批阅");
}
} }
@swidget @swidget
Widget $studentHandwriting(BuildContext context) { Widget $studentHandwriting(BuildContext context) {
final logic = Get.find<HomeworkReviewLogic>(); final logic = Get.find<HomeworkReviewLogic>();
final sateData = Get.find<HomeworkReviewLogic>().state.data; final stateData = logic.state.data;
return InkWell( return InkWell(
onTap: () => easyThrottle( onTap: () => easyThrottle(
'SHOW_ANSWER_HANDWRITING', 'SHOW_ANSWER_HANDWRITING',
() async { () async {
var homeworkId = logic.state.param.value.homeworkId; final data = stateData.value;
var studentId = sateData.value?.studentId; final studentId = data?.studentId;
if (studentId == null) return; if (studentId == null) return;
var templateIdKeyMap = sateData.value?.templateIdKeyMap;
final homeworkId = logic.state.param.value.homeworkId;
final templateId = data?.templateId;
final templateIdKeyMap = data?.templateIdKeyMap;
int? pageNum; int? pageNum;
var templateId = sateData.value?.templateId;
if (templateIdKeyMap != null && templateId != null) { if (templateIdKeyMap != null && templateId != null) {
pageNum = templateIdKeyMap[templateId]; pageNum = templateIdKeyMap[templateId];
} }
await showAnswerHandwriting(context,
homeworkId: homeworkId, studentId: studentId, templateId: templateId, pageNum: pageNum); await showAnswerHandwriting(
context,
homeworkId: homeworkId,
studentId: studentId,
templateId: templateId,
pageNum: pageNum,
);
ToastUtils.dismiss(); ToastUtils.dismiss();
}, },
), ),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Icon(Icons.edit_outlined, size: 12.sp, color: Theme.of(context).primaryColor.withOpacity(0.8)), Icon(
Icons.edit_outlined,
size: _Constants.iconSize.sp,
color: Theme.of(context).primaryColor.withOpacity(0.8),
),
SizedBox(width: 1.w), SizedBox(width: 1.w),
quickText( quickText(
'学生笔迹', '学生笔迹',
size: 12.sp, size: _Constants.smallTextSize.sp,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
color: Theme.of(context).primaryColor.withOpacity(0.9), color: Theme.of(context).primaryColor.withOpacity(0.9),
), ),
], ],
)); ),
);
} }
@swidget @swidget
Widget $continueToReview(BuildContext context, {bool isFloatingAction = false}) { Widget $continueToReview(BuildContext context, {bool isFloatingAction = false}) {
final logic = Get.find<HomeworkReviewLogic>(); final logic = Get.find<HomeworkReviewLogic>();
final sateData = Get.find<HomeworkReviewLogic>().state.data; final stateData = logic.state.data;
return Obx(() { return Obx(() {
var data = sateData.value; final data = stateData.value;
var param = logic.state.param.value;
int? submitCount = data?.submitCount; // //
int? annotatedCount = data?.annotatedCount; // if (!_shouldShowContinueReview(data)) {
// || (submitCount == annotatedCount || (param.templateId == null && param.studentId == null)) return const SizedBox();
// if (data == null || (data.needAnnotate ? true : data.totalUnAnnotateCount <= 0) ) return const SizedBox(); }
if (data == null ||
(data.needAnnotate void onPressed() => easyThrottle(
? (data.continuePage == null ? true : data.continuePage!.templateId == data.templateId)
: data.totalUnAnnotateCount <= 0)) return const SizedBox();
callFun() => easyThrottle(
'DO_PAPERS_JOB_CONTINUE_TO_REVIEW', 'DO_PAPERS_JOB_CONTINUE_TO_REVIEW',
() { () {
var param = logic.state.param.value; final param = logic.state.param.value;
param.templateId = null; param.templateId = null;
param.studentId = null; param.studentId = null;
logic.state.param.value = DoPaperDetailsParam.fromJson(param.toJson()); logic.state.param.value = DoPaperDetailsParam.fromJson(param.toJson());
}, },
); );
if (isFloatingAction) { if (isFloatingAction) {
return FloatingActionButton( return FloatingActionButton(
elevation: 8, elevation: 8,
tooltip: "继续批阅", tooltip: "继续批阅",
backgroundColor: Colors.white, backgroundColor: Colors.white,
onPressed: callFun, onPressed: onPressed,
child: Icon(Icons.flip_camera_android_outlined, size: 20.sp, color: Theme.of(context).primaryColor), child: Icon(
Icons.flip_camera_android_outlined,
size: 20.sp,
color: Theme.of(context).primaryColor,
),
); );
} }
return SizedBox(
child: InkWell( return InkWell(
onTap: callFun, onTap: onPressed,
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Icon(Icons.flip_camera_android_outlined, size: 12.sp, color: Theme.of(context).primaryColor.withOpacity(0.8)), Icon(
Icons.flip_camera_android_outlined,
size: _Constants.iconSize.sp,
color: Theme.of(context).primaryColor.withOpacity(0.8),
),
SizedBox(width: 1.w), SizedBox(width: 1.w),
quickText( quickText(
'继续批阅', '继续批阅',
size: 12.sp, size: _Constants.smallTextSize.sp,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
color: Theme.of(context).primaryColor.withOpacity(0.9), color: Theme.of(context).primaryColor.withOpacity(0.9),
), ),
SizedBox(width: 2.w), SizedBox(width: 2.w),
], ],
), ),
)); );
}); });
} }
// ///
bool _shouldShowContinueReview(DoPaperDetailsResult? data) {
if (data == null) return false;
if (data.needAnnotate) {
return data.continuePage == null || data.continuePage!.templateId != data.templateId;
} else {
return data.totalUnAnnotateCount > 0;
}
}
///
@swidget @swidget
Widget $historyHomework(BuildContext context) { Widget $historyHomework(BuildContext context) {
final sateData = Get.find<HomeworkReviewLogic>().state.data; final logic = Get.find<HomeworkReviewLogic>();
return SizedBox( final stateData = logic.state.data;
child: InkWell(
onTap: () => easyThrottle('DO_PAPERS_JOB_HISTORICAL_HOMEWORK', () { return InkWell(
int? studentId = sateData.value?.studentId; onTap: () => easyThrottle(
if (kDebugMode) print(studentId); 'DO_PAPERS_JOB_HISTORICAL_HOMEWORK',
if (studentId == null || (sateData.value?.students.isEmpty ?? true)) return; () => _navigateToStudentHistory(logic, stateData.value),
PaperStudents? currentStudent; ),
try {
currentStudent = sateData.value!.students.firstWhere((e) => e.id == studentId);
} catch (e) {
return;
}
var theState = Get.find<HomeworkReviewLogic>().state;
Get.toNamed(Routes.studentWorkDetailPage, arguments: {
'studentId': studentId,
'studentName': currentStudent.name,
'subject': theState.param.value.subject
});
}),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Icon(Icons.location_history, size: 12.sp, color: const Color.fromRGBO(104, 103, 103, 1)), Icon(
Icons.location_history,
size: _Constants.iconSize.sp,
color: _Constants.iconColor,
),
SizedBox(width: 1.w), SizedBox(width: 1.w),
quickText( quickText(
'历史作业', '历史作业',
size: 12.sp, size: _Constants.smallTextSize.sp,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
color: Theme.of(context).primaryColor.withOpacity(0.8), color: Theme.of(context).primaryColor.withOpacity(0.8),
), ),
], ],
), ),
),
); );
} }
///
void _navigateToStudentHistory(HomeworkReviewLogic logic, DoPaperDetailsResult? data) {
final studentId = data?.studentId;
final students = data?.students ?? [];
if (kDebugMode) print('Student ID: $studentId');
if (studentId == null || students.isEmpty) return;
PaperStudents? currentStudent;
try {
currentStudent = students.firstWhere((e) => e.id == studentId);
} catch (e) {
if (kDebugMode) print('Student not found: $e');
return;
}
Get.toNamed(Routes.studentWorkDetailPage, arguments: {
'studentId': studentId,
'studentName': currentStudent.name,
'subject': logic.state.param.value.subject,
});
}