import 'package:achievement_view/achievement_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart';
import 'package:marking_app/common/mixin/common.dart';
import 'package:marking_app/common/model/common/base_structure_result.dart';
import 'package:marking_app/common/model/job/job_concerned_with_student.dart';
import 'package:marking_app/common/model/job/job_concerned_with_student_params.dart';
import 'package:marking_app/common/model/job/job_favorite_model.dart';
import 'package:marking_app/common/model/job/job_task_item.dart';
import 'package:marking_app/components/ReturnToHomepage.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:marking_app/utils/request/rest_client.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';

part 'job_list_participate_in_class.g.dart';

class JobListParticipateInClass extends StatefulWidget {
  final int jobId;
  final String jobName;
  final String genderName;
  final bool completed;
  const JobListParticipateInClass(
      {required this.jobId, required this.jobName, required this.genderName, this.completed = false, super.key});

  @override
  State<JobListParticipateInClass> createState() => _JobListParticipateInClassState();
}

class _JobListParticipateInClassState extends State<JobListParticipateInClass> with CommonMixin {
  late Future<List<MarkingTasks>?> _future;
  Map<String, int> favoriteMap = {};
  bool isRefresh = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getListOfJobFavoritesData();
    _future = getData();

    // Future.delayed(Duration.zero, () {
    //   print(ScreenUtil().scaleWidth);
    //   print(MediaQuery.of(context).devicePixelRatio);
    // });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  Future<void> getListOfJobFavoritesData() async {
    RestClient _client = await getClient();
    BaseStructureResult<List<JobFavoriteModel>> result = await _client.getListOfJobFavoriteNumber(widget.jobId);
    if (result.success) {
      if (result.data?.isEmpty ?? true) {
        favoriteMap = {};
      }
      result.data?.forEach((e) {
        favoriteMap['${e.schoolId}+${e.gradeId}+${e.className}'] = e.count;
      });
      toUpState(setState, () {}, mounted);
    } else {}
  }

  Future<List<MarkingTasks>?> getData() async {
    RestClient _client = await getClient();
    BaseStructureResult<List<MarkingTasks>> _result = await _client.getJobListParticipateInClass(widget.jobId);
    return _result.data;
  }

  // 一键批阅
  void oneClickReview(int taskId) async {
    var continueFlag = await showDialog<bool>(
      context: context,
      builder: (BuildContext context1) {
        return Center(
            child: Container(
          padding: EdgeInsets.symmetric(vertical: 25.h, horizontal: 18.w),
          decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadiusDirectional.circular(12.r)),
          height: 150.h,
          width: 280.w,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Expanded(
                      child: quickText('一键批阅后，默认学生答题结果全部正确，是否进行此操作？',
                          maxLines: 3, size: 14.sp, color: Color.fromRGBO(80, 94, 110, 1)))
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  InkWell(
                    onTap: () {
                      Navigator.of(context1).pop(false);
                    },
                    child: Container(
                      padding: EdgeInsetsDirectional.symmetric(horizontal: 36.w, vertical: 7.h),
                      decoration: BoxDecoration(
                          color: Color.fromRGBO(244, 244, 244, 1), borderRadius: BorderRadius.circular(20.r)),
                      child: quickText('取消', size: 14.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                    ),
                  ),
                  InkWell(
                    onTap: () {
                      Navigator.of(context1).pop(true);
                    },
                    child: Container(
                      padding: EdgeInsetsDirectional.symmetric(horizontal: 36.w, vertical: 7.h),
                      decoration: BoxDecoration(
                          color: Theme.of(context).primaryColor, borderRadius: BorderRadius.circular(20.r)),
                      child: quickText('确认', size: 14.sp, color: Color.fromRGBO(255, 255, 255, 1)),
                    ),
                  ),
                ],
              )
            ],
          ),
        ));
      },
    );
    if (continueFlag == null || !continueFlag) return;
    try {
      ToastUtils.showLoading();
      RestClient _client = await getClient();
      BaseStructureResult<bool> res = await _client.toJobOneClickReview(taskId);
      if (res.success) {
        isRefresh = true;
        _future = getData();
        toUpState(setState, () {}, mounted);
        return;
      }
      ToastUtils.showError(res.message ?? '操作失败');
    } catch (e) {
    } finally {
      ToastUtils.dismiss();
    }
  }

  /// 前往批阅
  void goToReview(MarkingTasks task) {
    if (task.totalCount <= 0) {
      return ToastUtils.showInfo('没有找到可以批阅的任务');
    }

    if (!task.canMarking) {
      return AchievementView(
        elevation: 0.5,
        duration: Duration(seconds: 1),
        title: "提示",
        subTitle: "此账号无法批阅该任务",
        color: Theme.of(context).primaryColor,
      ).show(context);
    }
    print('进入页面................');
    if (task.isFinish) {
      return AchievementView(
        elevation: 0.5,
        duration: Duration(seconds: 1),
        title: "提示",
        subTitle: "此批阅任务已完成",
        color: Theme.of(context).primaryColor,
      ).show(context);
    }

    String url =
        '${RouterManager.markingHomeworkDoPath}?taskId=${task.id}&jobId=${widget.jobId}&taskName=${Uri.encodeComponent(widget.jobName)}&className=${Uri.encodeComponent(widget.genderName + task.className)}';
    RouterManager.router.navigateTo(context, url, transition: getTransition()).then((value) {
      if (value == true) {
        isRefresh = true;
        getListOfJobFavoritesData().then((value) {
          _future = getData();
          toUpState(setState, () {}, mounted);
        });
      }
    });
  }

  // 结束批阅请求方法
  Future<bool> endReviewInitialRequest(List<MarkingTasks> markingTasks) async {
    try {
      ToastUtils.showLoading();
      RestClient client = await getClient();
      BaseStructureResult res = await client.toEndReviewJob(markingTasks.map((e) => e.id).toList());
      if (!res.success) ToastUtils.showError('结束失败，请重试');
      return res.success;
    } catch (e) {
      ToastUtils.showError('结束失败，请重试');
      return false;
    }
  }

  /// 结束批阅
  void endReview(MarkingTasks task) async {
    /// 结束批阅逻辑
    if (!task.canMarking) return ToastUtils.showInfo('此任务非该账号任务');
    if (task.isFinish) return ToastUtils.showInfo('此任务已经结束');

    // 未完成批阅任务提示
    if (task.finishCount < task.totalCount) {
      var continueFlag = await showDialog<bool>(
        context: context,
        builder: (BuildContext context1) {
          return AlertDialog(
            title: Text('未完成批阅提示'),
            content: Text('当前批阅任务未完成，请确认需要结束此任务?'),
            actions: <Widget>[
              TextButton(
                child: Text('否'),
                onPressed: () {
                  // 在这里处理删除操作
                  Navigator.of(context1).pop(false);
                },
              ),
              TextButton(
                child: Text('是'),
                onPressed: () {
                  Navigator.of(context1).pop(true);
                },
              ),
            ],
          );
        },
      );
      if (continueFlag == null || !continueFlag) {
        return;
      }
    }

    showDialog(
      context: context,
      builder: (BuildContext context1) {
        return AlertDialog(
          title: Text('提示'),
          content: Text('确认完成当前${task.className}批阅任务?'),
          actions: <Widget>[
            TextButton(
              child: Text('否'),
              onPressed: () {
                // 在这里处理删除操作
                Navigator.of(context1).pop();
              },
            ),
            TextButton(
              child: Text('确定'),
              onPressed: () async {
                try {
                  bool result = await endReviewInitialRequest([task]);
                  if (result) {
                    isRefresh = true;
                    _future = getData();
                    toUpState(setState, () {}, mounted);
                  }
                } catch (e) {
                } finally {
                  ToastUtils.dismiss();
                  Navigator.of(context1).pop();
                }
              },
            ),
          ],
        );
      },
    );
  }

  // 收藏夹
  void bookmarks(MarkingTasks task) {
    RouterManager.router
        .navigateTo(
      context,
      RouterManager.jobFavoritePagePath +
          '?className=${Uri.encodeComponent(task.className)}&jobId=${widget.jobId}&schoolId=${task.dpcSchoolId}&gradeId=${task.dpcGradeId}&jobName=${Uri.encodeComponent(widget.jobName)}',
      transition: getTransition(),
    )
        .then((value) async {
      isRefresh = true;
      getListOfJobFavoritesData().then((value) {
        _future = getData();
        toUpState(setState, () {}, mounted);
      });
    });
  }

  // 数据快查
  void quickDataCheck(MarkingTasks task) {
    RouterManager.router.navigateTo(
      context,
      RouterManager.quickDataCheckPath +
          '?gradeName=${Uri.encodeComponent(widget.genderName)}&className=${Uri.encodeComponent(task.className)}&jobId=${widget.jobId}',
      transition: getTransition(),
    );
  }

  // 查看作业报告
  void jobViewReport(MarkingTasks task) {
    RouterManager.router.navigateTo(
      context,
      RouterManager.jobReportPagePath +
          '?title=${Uri.encodeComponent(widget.jobName)}&id=${widget.jobId}&schoolId=${task.dpcSchoolId}&gradeId=${task.dpcGradeId}&className=${Uri.encodeComponent(task.className)}',
      transition: getTransition(),
    );
  }

  /// 查看学生名单
  /// @name showStudentList
  /// @param {List<int>}  taskId      子任务ID集合
  /// @param {bool}       className   班级名称（不传此参数为主任务；传此参数为子任务）
  /// @param {bool}       submitted   是否已提交(默认未提交)
  void showStudentList(List<int> taskIds, [String? className, bool submitted = false]) async {
    ToastUtils.showLoading();
    List<JobConcernedWithStudent> students = [];
    try {
      RestClient _client = await getClient();
      BaseStructureResult<List<JobConcernedWithStudent>> _result =
          await _client.getJobWithStudents(JobConcernedWithStudentParams(taskIds, isCommit: submitted));
      if (!_result.success) {
        return ToastUtils.showError(_result.message ?? '获取学生列表失败');
      }
      if (_result.data?.isEmpty ?? true) {
        return ToastUtils.showError('获取到的学生列表为空');
      }
      students = _result.data!..sort((e, e1) => e.studentName.compareTo(e1.studentName));
    } catch (e) {
      return ToastUtils.showError('获取学生列表失败');
    } finally {
      ToastUtils.dismiss();
    }

    showModalBottomSheet(
      context: context,
      elevation: 10,
      backgroundColor: Colors.white,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(20.r),
          topRight: Radius.circular(20.r),
        ),
      ),
      builder: (BuildContext context) {
        return Padding(
          padding: EdgeInsets.symmetric(horizontal: 2.w),
          child: Column(
            children: [
              Container(
                margin: EdgeInsets.only(top: 14.h, bottom: 10.h),
                child: quickText(
                  '${className ?? ''} ${submitted ? '已提交' : '未提交'}作业学生',
                  size: isPad() ? 15.sp : 15.sp,
                  fontWeight: FontWeight.bold,
                  color: Color.fromRGBO(60, 60, 60, 1),
                ),
              ),
              Expanded(
                child: ListView(
                  padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 4.w),
                  children: [
                    Wrap(
                      spacing: 6.0, // 主轴(水平)方向间距
                      runSpacing: 4.0, // 纵轴（垂直）方向间距
                      alignment: WrapAlignment.spaceAround, //沿主轴方向居中
                      children: students.map((e) {
                        return Chip(
                          backgroundColor: Color.fromRGBO(239, 242, 255, 1),
                          labelPadding: EdgeInsets.symmetric(vertical: 1.5.h, horizontal: 5.w),
                          // avatar: CircleAvatar(
                          //   backgroundColor: Colors.white,
                          //   child: quickText(e.studentName.substring(0, 1),
                          //       size: 12.sp, color: Theme.of(context).primaryColor),
                          // ),
                          label: quickText(e.studentName, color: Color.fromRGBO(80, 94, 110, 1), size: 12.sp),
                        );
                      }).toList(),
                    ),
                  ],
                ),
              )
            ],
          ),
        );
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async {
        Navigator.of(context).pop(isRefresh);
        return false;
      },
      child: Scaffold(
        backgroundColor: const Color.fromRGBO(245, 245, 245, 1),
        appBar: AppBar(
          leading: IconButton(
              icon: Icon(Icons.arrow_back_ios, color: Color.fromRGBO(51, 51, 51, 1)),
              onPressed: () => Navigator.of(context).pop(isRefresh)),
          title: Container(
            child: quickText(widget.jobName,
                size: 14.sp, color: Color.fromRGBO(51, 51, 51, 1), fontWeight: FontWeight.w500),
            alignment: Alignment.center,
          ),
          backgroundColor: Colors.white,
          actions: [
            ReturnToHomepage(),
          ],
        ),
        body: RefreshIndicator(
          onRefresh: () async {
            getListOfJobFavoritesData().then((value) {
              _future = getData();
              toUpState(setState, () {}, mounted);
            });
          },
          child: MyFutureBuilder.buildFutureBuilderOfSingleInstance<List<MarkingTasks>?>(context, _future, (value) {
            if (value == null) return Container();
            value.forEach((e) {
              e.collectNumber = favoriteMap['${e.dpcSchoolId}+${e.dpcGradeId}+${e.className}'] ?? 0;
            });
            bool thePadTerminal = isPad();
            if (widget.completed) {
              // 已完成
              if (thePadTerminal)
                return TabletEndCompleted(
                  data: value,
                  genderName: widget.genderName,
                  bookmarks: bookmarks,
                  jobViewReport: jobViewReport,
                  quickDataCheck: quickDataCheck,
                  showStudentList: showStudentList,
                );

              // 已完成手机端
              return MobileEndCompleted(
                data: value,
                genderName: widget.genderName,
                bookmarks: bookmarks,
                jobViewReport: jobViewReport,
                quickDataCheck: quickDataCheck,
                showStudentList: showStudentList,
              );
            }

            // 未完成页面
            if (thePadTerminal)
              return TabletEnd(
                data: value,
                genderName: widget.genderName,
                bookmarks: bookmarks,
                endReview: endReview,
                goToReview: goToReview,
                jobViewReport: jobViewReport,
                quickDataCheck: quickDataCheck,
                oneClickReview: oneClickReview,
                showStudentList: showStudentList,
              );

            return MobileEnd(
              data: value,
              genderName: widget.genderName,
              bookmarks: bookmarks,
              endReview: endReview,
              goToReview: goToReview,
              jobViewReport: jobViewReport,
              quickDataCheck: quickDataCheck,
              oneClickReview: oneClickReview,
              showStudentList: showStudentList,
            );
          }),
        ),
      ),
    );
  }
}

/// 平板电脑端（未完成）
class TabletEnd extends StatelessWidget {
  final String genderName;
  final List<MarkingTasks> data;

  final EndReview endReview; // 结束批阅
  final Bookmarks bookmarks; // 收藏夹
  final GoToReview goToReview; // 前往批阅
  final JobViewReport jobViewReport;
  final OneClickReview oneClickReview; // 一键批阅
  final QuickDataCheck quickDataCheck; // 数据快查
  final ShowStudentList showStudentList;
  const TabletEnd({
    required this.genderName,
    required this.data,

    /// 方法
    required this.endReview,
    required this.bookmarks,
    required this.goToReview,
    required this.jobViewReport,
    required this.oneClickReview,
    required this.quickDataCheck,
    required this.showStudentList,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: ScreenUtil().screenWidth,
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.h),
      child: MasonryGridView.count(
        crossAxisCount: 2, //几列
        mainAxisSpacing: 4.w, // 间距
        crossAxisSpacing: 4.h, // 纵向间距？
        itemCount: data.length,
        itemBuilder: (context, index) {
          var e = data[index];
          return $ItemDataViewOfPad(
            task: e,
            bookmarks: bookmarks,
            endReview: endReview,
            genderName: genderName,
            goToReview: goToReview,
            jobViewReport: jobViewReport,
            quickDataCheck: quickDataCheck,
            oneClickReview: oneClickReview,
            showStudentList: showStudentList,
          );
        },
      ),
      //  Wrap(
      //   spacing: 8.0.w, // 子元素之间的间距
      //   runSpacing: 10.h, // 主轴方向上不同行之间的间距
      //   children: [...data, ...data]
      //       .map((e) => $ItemDataViewOfPad(
      //             task: e,
      //             bookmarks: bookmarks,
      //             endReview: endReview,
      //             genderName: genderName,
      //             goToReview: goToReview,
      //             jobViewReport: jobViewReport,
      //             quickDataCheck: quickDataCheck,
      //             oneClickReview: oneClickReview,
      //             showStudentList: showStudentList,
      //           ))
      //       .toList(),
      // ),
    );
  }
}

/// 平板展示（已完成）
class TabletEndCompleted extends StatelessWidget {
  final String genderName;
  final List<MarkingTasks> data;

  final Bookmarks bookmarks; // 收藏夹
  final JobViewReport jobViewReport;
  final QuickDataCheck quickDataCheck; // 数据快查
  final ShowStudentList showStudentList; // 学生列表查询
  const TabletEndCompleted({
    required this.genderName,
    required this.data,

    /// 方法
    required this.bookmarks,
    required this.jobViewReport,
    required this.quickDataCheck,
    required this.showStudentList,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    var padingEdg = EdgeInsets.only(left: 10.w, right: 10.w);
    return Container(
      width: ScreenUtil().screenWidth,
      padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 16.h),
      child: GridView(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2, //横轴三个子widget
            mainAxisSpacing: 10.h,
            crossAxisSpacing: 6.w,
            childAspectRatio: 1.48 //宽高比为1时，子widget
            ),
        children: data.map((taskItem) {
          return Container(
            decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(6.r)),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 6.h),
                  alignment: Alignment.centerLeft,
                  decoration: BoxDecoration(
                    border: Border(bottom: BorderSide(color: Color.fromRGBO(238, 238, 238, 1), width: 0.5.r)),
                  ),
                  child: quickText(taskItem.className, color: Color.fromRGBO(104, 136, 253, 1), size: 12.sp),
                ),
                Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    $CompletedHomeworkProgressBar(
                      color: Color.fromRGBO(76, 199, 147, 1),
                      percent: taskItem.objectivePrecision,
                      title: '客观题正确率：',
                      padingEdg: padingEdg,
                      fontSize: 8.sp,
                      lineHeight: 5.h,
                      marginEdg: EdgeInsets.only(top: 5.h),
                    ),
                    $CompletedHomeworkProgressBar(
                      color: Color.fromRGBO(76, 199, 147, 1),
                      percent: taskItem.subjectivePrecision,
                      title: '主观题正确率：',
                      fontSize: 8.sp,
                      lineHeight: 5.h,
                      padingEdg: padingEdg,
                      marginEdg: EdgeInsets.only(top: 5.h),
                    ),
                    $CompletedHomeworkProgressBar(
                      color: Color.fromRGBO(76, 199, 147, 1),
                      percent: taskItem.precision,
                      title: '总正确率：',
                      fontSize: 8.sp,
                      lineHeight: 5.h,
                      padingEdg: padingEdg,
                      marginEdg: EdgeInsets.only(top: 5.h),
                    ),
                  ],
                ),
                SizedBox(height: 4.h),
                Padding(
                  padding: padingEdg,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(16.r),
                          child: InkWell(
                            onTap: () => easyThrottle(
                                'OneClickReview', () => showStudentList([taskItem.id], taskItem.className, true)),
                            borderRadius: BorderRadius.circular(8.r),
                            splashColor: Theme.of(context).primaryColor,
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 4.h),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(20.r),
                              ),
                              child: quickText('已提交:${taskItem.commitStudentCount}',
                                  size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        ),
                      ),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(20.r),
                          child: InkWell(
                            onTap: () => easyThrottle(
                                'OneClickReview', () => showStudentList([taskItem.id], taskItem.className)),
                            splashColor: Theme.of(context).primaryColor,
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 4.h),
                              decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                              child: quickText('未提交:${taskItem.studentCount - taskItem.commitStudentCount}',
                                  size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        ),
                      ),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(
                          flex: 4,
                          child: Material(
                            color: Color.fromRGBO(244, 244, 244, 1),
                            borderRadius: BorderRadius.circular(20.r),
                            child: InkWell(
                              onTap: () => bookmarks(taskItem),
                              splashColor: Theme.of(context).primaryColor,
                              borderRadius: BorderRadius.circular(8.r),
                              child: Container(
                                alignment: Alignment.center,
                                padding: EdgeInsets.symmetric(vertical: 4.h),
                                decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                                child: quickText(taskItem.collectNumber <= 0 ? '收藏夹' : '收藏夹(${taskItem.collectNumber})',
                                    size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                              ),
                            ),
                          )),
                    ],
                  ),
                ),
                SizedBox(height: 4.h),
                Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.only(
                      bottomLeft: Radius.circular(10.r),
                      bottomRight: Radius.circular(10.r),
                    ),
                    color: Colors.white,
                    boxShadow: [
                      BoxShadow(
                        color: const Color.fromRGBO(0, 0, 0, 0.15),
                        offset: Offset(0, -0.0001), //阴影y轴偏移量
                        blurRadius: 5, //阴影模糊程度
                        spreadRadius: 0, //阴影扩散程度
                      )
                    ],
                  ),
                  child: Row(children: [
                    Expanded(
                      child: InkWell(
                        onTap: () => easyThrottle('go_to_review_homework', () => quickDataCheck(taskItem)),
                        child: Container(
                          alignment: Alignment.center,
                          child: quickText('数据快查', color: Color.fromRGBO(118, 118, 118, 1), size: 11.sp),
                        ),
                      ),
                    ),
                    Container(width: 1.w, height: 26.h, color: Color.fromRGBO(221, 221, 221, 1)),
                    Expanded(
                        child: InkWell(
                      onTap: () => easyThrottle('go_to_end_review_homework', () => jobViewReport(taskItem)),
                      child: Container(
                        alignment: Alignment.center,
                        child: quickText('查看报告', color: Color.fromRGBO(118, 118, 118, 1), size: 10.sp),
                      ),
                    )),
                  ]),
                ),
              ],
            ),
          );
        }).toList(),
      ),
    );
  }
}

/// 手机端（已完成）
class MobileEndCompleted extends StatelessWidget {
  final String genderName;
  final List<MarkingTasks> data;

  final Bookmarks bookmarks; // 收藏夹
  final JobViewReport jobViewReport; // 查看报告
  final QuickDataCheck quickDataCheck; // 数据快查
  final ShowStudentList showStudentList; // 学生名单

  const MobileEndCompleted({
    required this.genderName,
    required this.data,

    /// 方法
    required this.bookmarks,
    required this.showStudentList,
    required this.jobViewReport,
    required this.quickDataCheck,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    var padingEdg = EdgeInsets.only(left: 10.w, right: 10.w);
    return ListView(
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.h),
      children: data.map((task) {
        return Container(
            padding: EdgeInsets.only(top: 11.h),
            margin: EdgeInsets.only(bottom: 18.h),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadiusDirectional.circular(10.r),
              boxShadow: [BoxShadow(color: Color.fromRGBO(0, 0, 0, 0.15), blurRadius: 10)],
              // border: Border(bottom: BorderSide(color: Color.fromRGBO(238, 238, 238, 1), width: 1.r)),
            ),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h),
                  alignment: Alignment.centerLeft,
                  decoration: BoxDecoration(
                    border: Border(bottom: BorderSide(color: Color.fromRGBO(238, 238, 238, 1), width: 0.5.r)),
                  ),
                  child: quickText(task.className, color: Color.fromRGBO(104, 136, 253, 1), size: 14.sp),
                ),
                SizedBox(height: 4.h),
                if (task.isFinish)
                  $CompletedHomeworkProgressBar(
                    color: Color.fromRGBO(76, 199, 147, 1),
                    percent: task.objectivePrecision,
                    title: '客观题正确率：',
                    padingEdg: padingEdg,
                    marginEdg: EdgeInsets.only(top: 8.h),
                  ),
                if (task.isFinish)
                  $CompletedHomeworkProgressBar(
                    color: Color.fromRGBO(76, 199, 147, 1),
                    percent: task.subjectivePrecision,
                    title: '主观题正确率：',
                    padingEdg: padingEdg,
                    marginEdg: EdgeInsets.only(top: 8.h),
                  ),
                if (task.isFinish)
                  $CompletedHomeworkProgressBar(
                    color: Color.fromRGBO(76, 199, 147, 1),
                    percent: task.precision,
                    title: '总正确率：',
                    padingEdg: padingEdg,
                    marginEdg: EdgeInsets.only(top: 8.h),
                  ),
                SizedBox(height: 13.h),
                Padding(
                  padding: padingEdg,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(16.r),
                          child: InkWell(
                            onTap: () =>
                                easyThrottle('OneClickReview', () => showStudentList([task.id], task.className, true)),
                            splashColor: Theme.of(context).primaryColor,
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 5.h),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(20.r),
                              ),
                              child: quickText('已提交:${task.commitStudentCount}',
                                  size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        ),
                      ),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(20.r),
                          child: InkWell(
                            onTap: () =>
                                easyThrottle('OneClickReview', () => showStudentList([task.id], task.className)),
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 5.h),
                              decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                              child: quickText('未提交:${task.studentCount - task.commitStudentCount}',
                                  size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        ),
                      ),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(
                          flex: 4,
                          child: Material(
                            color: Color.fromRGBO(244, 244, 244, 1),
                            borderRadius: BorderRadius.circular(20.r),
                            child: InkWell(
                              onTap: () => bookmarks(task),
                              borderRadius: BorderRadius.circular(8.r),
                              child: Container(
                                alignment: Alignment.center,
                                padding: EdgeInsets.symmetric(vertical: 5.h),
                                decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                                child: quickText(task.collectNumber > 0 ? '收藏夹(${task.collectNumber})' : '收藏夹',
                                    size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                              ),
                            ),
                          )),
                    ],
                  ),
                ),
                SizedBox(height: 13.h),
                Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.only(
                      bottomLeft: Radius.circular(10.r),
                      bottomRight: Radius.circular(10.r),
                    ),
                    color: Colors.white,
                    boxShadow: [
                      BoxShadow(
                        color: const Color.fromRGBO(0, 0, 0, 0.15),
                        offset: Offset(0, -0.0001), //阴影y轴偏移量
                        blurRadius: 5, //阴影模糊程度
                        spreadRadius: 0, //阴影扩散程度
                      )
                    ],
                  ),
                  child: Row(children: [
                    Expanded(
                      child: InkWell(
                        onTap: () => easyThrottle('go_to_review_homework', () => quickDataCheck(task)),
                        child: Container(
                          alignment: Alignment.center,
                          child: quickText('数据快查', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                        ),
                      ),
                    ),
                    Container(width: 1.w, height: 36.h, color: Color.fromRGBO(221, 221, 221, 1)),
                    Expanded(
                        child: InkWell(
                      onTap: () => easyThrottle('go_to_end_review_homework', () => jobViewReport(task)),
                      child: Container(
                        alignment: Alignment.center,
                        child: quickText('查看报告', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                      ),
                    )),
                  ]),
                ),
              ],
            ));
      }).toList(),
    );
  }
}

/// 移动端
class MobileEnd extends StatelessWidget {
  final String genderName;
  final List<MarkingTasks> data;

  final EndReview endReview; // 结束批阅
  final Bookmarks bookmarks; // 收藏夹
  final GoToReview goToReview; // 前往批阅
  final JobViewReport jobViewReport;
  final OneClickReview oneClickReview; // 一键批阅
  final QuickDataCheck quickDataCheck; // 数据快查
  final ShowStudentList showStudentList; // 数据快查

  const MobileEnd({
    required this.genderName,
    required this.data,

    /// 方法
    required this.endReview,
    required this.bookmarks,
    required this.goToReview,
    required this.jobViewReport,
    required this.oneClickReview,
    required this.quickDataCheck,
    required this.showStudentList,
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return ListView(
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.h),
      children: data.map((e) {
        return $ItemDataView(
          task: e,
          bookmarks: bookmarks,
          endReview: endReview,
          genderName: genderName,
          goToReview: goToReview,
          jobViewReport: jobViewReport,
          quickDataCheck: quickDataCheck,
          oneClickReview: oneClickReview,
          showStudentList: showStudentList,
        );
      }).toList(),
    );
  }
}

/// pad item view
@swidget
Widget $itemDataViewOfPad(
  BuildContext context, {
  required MarkingTasks task,
  required String genderName,

  /// 方法
  required EndReview endReview,
  required Bookmarks bookmarks,
  required GoToReview goToReview,
  required JobViewReport jobViewReport,
  required OneClickReview oneClickReview,
  required QuickDataCheck quickDataCheck,
  required ShowStudentList showStudentList,
}) {
  EdgeInsets edgins = EdgeInsets.only(left: 8.w, right: 8.w);
  return Container(
    width: ScreenUtil().screenWidth / 2 - (12.w + 4.w),
    decoration: BoxDecoration(
      color: Colors.white,
      borderRadius: BorderRadiusDirectional.circular(4.r),
      boxShadow: [BoxShadow(color: Color.fromRGBO(0, 0, 0, 0.15), blurRadius: 10)],
    ),
    padding: EdgeInsets.only(top: 10.h),
    child: Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Padding(
          padding: edgins,
          child: Row(
            children: [
              quickText(genderName + task.className, color: Color.fromRGBO(0, 0, 0, 1), size: 10.sp),
              Expanded(child: SizedBox()),
              InkWell(
                onTap: () => easyThrottle('OneClickReview', () => showStudentList([task.id], task.className, true)),
                child: quickText('已交：${task.commitStudentCount}', color: Color.fromRGBO(104, 136, 253, 1), size: 8.sp),
              ),
              SizedBox(width: 10.w),
              InkWell(
                onTap: () => easyThrottle('OneClickReview', () => showStudentList([task.id], task.className)),
                child: quickText('未交：${task.studentCount - task.commitStudentCount}',
                    color: Color.fromRGBO(255, 86, 86, 1), size: 8.sp),
              ),
            ],
          ),
        ),
        SizedBox(height: 10.h),
        Padding(
          padding: edgins,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: task.isFinish
                ? [
                    Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(20.r),
                          child: InkWell(
                            onTap: () => bookmarks(task),
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 3.h),
                              decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                              child: quickText(task.collectNumber <= 0 ? '收藏夹' : '收藏夹(${task.collectNumber})',
                                  size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        )),
                    Expanded(flex: 1, child: SizedBox()),
                    Expanded(flex: 4, child: SizedBox()),
                    Expanded(flex: 1, child: SizedBox()),
                    Expanded(flex: 4, child: SizedBox()),
                  ]
                : [
                    Expanded(
                      flex: 4,
                      child: Material(
                        color: Color.fromRGBO(244, 244, 244, 1),
                        borderRadius: BorderRadius.circular(16.r),
                        child: InkWell(
                          splashColor: Theme.of(context).primaryColor,
                          onTap: () => easyThrottle('OneClickReview', () {
                            if (!task.canMarking) {
                              return AchievementView(
                                elevation: 0.5,
                                duration: Duration(seconds: 1),
                                title: "提示",
                                subTitle: "此账号无法批阅该任务",
                                color: Theme.of(context).primaryColor,
                              ).show(context);
                            }
                            oneClickReview(task.id);
                          }),
                          borderRadius: BorderRadius.circular(8.r),
                          child: Container(
                            alignment: Alignment.center,
                            padding: EdgeInsets.symmetric(vertical: 3.h),
                            decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                            child: quickText('一键批阅', size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                          ),
                        ),
                      ),
                    ),
                    Expanded(flex: 1, child: SizedBox()),
                    Expanded(
                      flex: 4,
                      child: Material(
                        color: Color.fromRGBO(244, 244, 244, 1),
                        borderRadius: BorderRadius.circular(20.r),
                        child: InkWell(
                          onTap: () => quickDataCheck(task),
                          splashColor: Theme.of(context).primaryColor,
                          borderRadius: BorderRadius.circular(8.r),
                          child: Container(
                            alignment: Alignment.center,
                            padding: EdgeInsets.symmetric(vertical: 3.h),
                            decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                            child: quickText('数据快查', size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                          ),
                        ),
                      ),
                    ),
                    Expanded(flex: 1, child: SizedBox()),
                    Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(20.r),
                          child: InkWell(
                            splashColor: Theme.of(context).primaryColor,
                            onTap: () => bookmarks(task),
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 3.h),
                              decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                              child: quickText('收藏夹(${task.collectNumber})',
                                  size: 8.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        )),
                  ],
          ),
        ),
        SizedBox(height: 8.h),
        if (!task.isFinish)
          Padding(
            padding: EdgeInsets.only(left: 10.w, right: 10.w),
            child: Row(
              children: [
                Expanded(
                  child: LinearPercentIndicator(
                    padding: EdgeInsets.zero,
                    animation: true,
                    lineHeight: 5.h,
                    animationDuration: 2500,
                    percent: task.progressPercentage / 100,
                    linearGradient: LinearGradient(
                      tileMode: TileMode.mirror,
                      stops: [0.0, 1.0],
                      colors: task.progressPercentage / 100 != 1
                          ? [Theme.of(context).primaryColor.withOpacity(0.1), Theme.of(context).primaryColor]
                          : [
                              Color.fromRGBO(144, 224, 190, 1).withOpacity(0.1),
                              Color.fromRGBO(144, 224, 190, 1),
                            ],
                    ),
                    backgroundColor: Color.fromRGBO(232, 232, 232, 1),
                    barRadius: Radius.circular(10.r),
                  ),
                ),
                SizedBox(width: 7.w),
                quickText('${getDoubleRemoveZero(task.progressPercentage)}%',
                    size: 8.sp, color: Color.fromRGBO(70, 70, 70, 1))
              ],
            ),
          ),
        if (task.isFinish)
          $CompletedHomeworkProgressBar(
            fontSize: 8.sp,
            lineHeight: 6.h,
            color: Color.fromRGBO(76, 199, 147, 1),
            percent: task.objectivePrecision,
            title: '客观题正确率：',
            padingEdg: edgins,
            marginEdg: EdgeInsets.only(top: 8.h),
          ),
        if (task.isFinish)
          $CompletedHomeworkProgressBar(
            fontSize: 8.sp,
            lineHeight: 6.h,
            color: Color.fromRGBO(76, 199, 147, 1),
            percent: task.subjectivePrecision,
            title: '主观题正确率：',
            padingEdg: edgins,
            marginEdg: EdgeInsets.only(top: 8.h),
          ),
        if (task.isFinish)
          $CompletedHomeworkProgressBar(
            fontSize: 8.sp,
            lineHeight: 6.h,
            color: Color.fromRGBO(76, 199, 147, 1),
            percent: task.precision,
            title: '总正确率：',
            padingEdg: edgins,
            marginEdg: EdgeInsets.only(top: 8.h),
          ),
        SizedBox(height: 8.h),
        Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.only(bottomLeft: Radius.circular(4.r), bottomRight: Radius.circular(4.r)),
            color: Colors.white,
            boxShadow: [
              BoxShadow(
                color: const Color.fromRGBO(0, 0, 0, 0.15),
                offset: Offset(0, -0.0001), //阴影y轴偏移量
                blurRadius: 4, //阴影模糊程度
                spreadRadius: 0, //阴影扩散程度
              )
            ],
          ),
          child: Row(
            children: task.isFinish
                ? [
                    Expanded(
                      child: InkWell(
                        onTap: () => easyThrottle('go_to_review_homework', () => quickDataCheck(task)),
                        child: Container(
                          alignment: Alignment.center,
                          child: quickText('数据快查', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                        ),
                      ),
                    ),
                    Container(width: 1.w, height: 30.h, color: Color.fromRGBO(221, 221, 221, 1)),
                    Expanded(
                        child: InkWell(
                      onTap: () => easyThrottle('go_to_end_review_homework', () => jobViewReport(task)),
                      child: Container(
                        alignment: Alignment.center,
                        child: quickText('查看报告', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                      ),
                    )),
                  ]
                : [
                    Expanded(
                      child: InkWell(
                        onTap: () => easyThrottle('go_to_review_homework', () => goToReview(task)),
                        child: Container(
                          alignment: Alignment.center,
                          child: quickText('批阅', color: Color.fromRGBO(79, 79, 79, 1), size: 11.sp),
                        ),
                      ),
                    ),
                    Container(width: 0.3.w, height: 30.h, color: Color.fromRGBO(221, 221, 221, 1)),
                    Expanded(
                        child: InkWell(
                      onTap: () => easyThrottle('go_to_end_review_homework', () => endReview(task)),
                      child: Container(
                        alignment: Alignment.center,
                        child: quickText('结束批阅', color: Color.fromRGBO(118, 118, 118, 1), size: 10.sp),
                      ),
                    )),
                  ],
          ),
        ),
      ],
    ),
  );
}

/// item view
@swidget
Widget $itemDataView(
  BuildContext context, {
  required MarkingTasks task,
  required String genderName,

  /// 方法
  required EndReview endReview,
  required Bookmarks bookmarks,
  required GoToReview goToReview,
  required OneClickReview oneClickReview,
  required QuickDataCheck quickDataCheck,
  required JobViewReport jobViewReport,
  required ShowStudentList showStudentList,
}) {
  var padingEdg = EdgeInsets.only(left: 10.w, right: 10.w);
  return Container(
      padding: EdgeInsets.only(top: 11.h),
      margin: EdgeInsets.only(bottom: 12.h),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadiusDirectional.circular(10.r),
        boxShadow: [BoxShadow(color: Color.fromRGBO(0, 0, 0, 0.15), blurRadius: 10)],
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Padding(
            padding: padingEdg,
            child: Row(
              children: [
                quickText(genderName + task.className, color: Color.fromRGBO(0, 0, 0, 1), size: 14.sp),
                Expanded(child: SizedBox()),
                InkWell(
                  onTap: () => easyThrottle('OneClickReview', () => showStudentList([task.id], task.className, true)),
                  child:
                      quickText('已交：${task.commitStudentCount}', color: Color.fromRGBO(104, 136, 253, 1), size: 12.sp),
                ),
                SizedBox(width: 16.w),
                InkWell(
                  onTap: () => easyThrottle('OneClickReview', () => showStudentList([task.id], task.className)),
                  child: quickText('未交：${task.studentCount - task.commitStudentCount}',
                      color: Color.fromRGBO(255, 86, 86, 1), size: 12.sp),
                ),
              ],
            ),
          ),
          SizedBox(height: 13.h),
          Padding(
            padding: padingEdg,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: task.isFinish
                  ? [
                      Expanded(
                          flex: 4,
                          child: Material(
                            color: Color.fromRGBO(244, 244, 244, 1),
                            borderRadius: BorderRadius.circular(20.r),
                            child: InkWell(
                              onTap: () => bookmarks(task),
                              borderRadius: BorderRadius.circular(8.r),
                              child: Container(
                                alignment: Alignment.center,
                                padding: EdgeInsets.symmetric(vertical: 5.h),
                                decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                                child: quickText(task.collectNumber <= 0 ? '收藏夹' : '收藏夹(${task.collectNumber})',
                                    size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                              ),
                            ),
                          )),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(flex: 4, child: SizedBox()),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(flex: 4, child: SizedBox()),
                    ]
                  : [
                      Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(16.r),
                          child: InkWell(
                            splashColor: Theme.of(context).primaryColor,
                            onTap: () => easyThrottle('OneClickReview', () {
                              if (!task.canMarking) {
                                return AchievementView(
                                  elevation: 0.5,
                                  duration: Duration(seconds: 1),
                                  title: "提示",
                                  subTitle: "此账号无法批阅该任务",
                                  color: Theme.of(context).primaryColor,
                                ).show(context);
                              }
                              oneClickReview(task.id);
                            }),
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 5.h),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(20.r),
                              ),
                              child: quickText('一键批阅', size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        ),
                      ),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(
                        flex: 4,
                        child: Material(
                          color: Color.fromRGBO(244, 244, 244, 1),
                          borderRadius: BorderRadius.circular(20.r),
                          child: InkWell(
                            splashColor: Theme.of(context).primaryColor,
                            onTap: () => quickDataCheck(task),
                            borderRadius: BorderRadius.circular(8.r),
                            child: Container(
                              alignment: Alignment.center,
                              padding: EdgeInsets.symmetric(vertical: 5.h),
                              decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                              child: quickText('数据快查', size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                            ),
                          ),
                        ),
                      ),
                      Expanded(flex: 1, child: SizedBox()),
                      Expanded(
                          flex: 4,
                          child: Material(
                            color: Color.fromRGBO(244, 244, 244, 1),
                            borderRadius: BorderRadius.circular(20.r),
                            child: InkWell(
                              onTap: () => bookmarks(task),
                              splashColor: Theme.of(context).primaryColor,
                              borderRadius: BorderRadius.circular(8.r),
                              child: Container(
                                alignment: Alignment.center,
                                padding: EdgeInsets.symmetric(vertical: 5.h),
                                decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.r)),
                                child: quickText(task.collectNumber <= 0 ? '收藏夹' : '收藏夹(${task.collectNumber})',
                                    size: 10.sp, color: Color.fromRGBO(102, 102, 102, 1)),
                              ),
                            ),
                          )),
                    ],
            ),
          ),
          SizedBox(height: 10.h),
          if (!task.isFinish)
            Padding(
              padding: padingEdg,
              child: Row(
                children: [
                  Expanded(
                    child: LinearPercentIndicator(
                      padding: EdgeInsets.zero,
                      animation: true,
                      lineHeight: 8.h,
                      animationDuration: 2500,

                      percent: task.progressPercentage / 100,
                      // center: Text(
                      //   '${getDoubleRemoveZero(jobTaskClassItem.progressPercentage)}%',
                      //   style: TextStyle(color: Colors.white, fontSize: 8.sp),
                      // ),
                      linearGradient: LinearGradient(
                        tileMode: TileMode.mirror,
                        stops: [0.0, 1.0],
                        colors: task.progressPercentage / 100 != 1
                            ? [Theme.of(context).primaryColor.withOpacity(0.1), Theme.of(context).primaryColor]
                            : [
                                Color.fromRGBO(144, 224, 190, 1).withOpacity(0.1),
                                Color.fromRGBO(144, 224, 190, 1),
                              ],
                      ),
                      // linearStrokeCap: LinearStrokeCap.butt,
                      // progressColor: Theme.of(context).primaryColor,
                      backgroundColor: Color.fromRGBO(232, 232, 232, 1),
                      barRadius: Radius.circular(10.r),
                    ),
                  ),
                  SizedBox(width: 7.w),
                  quickText('${getDoubleRemoveZero(task.progressPercentage)}%',
                      size: 10.sp, color: Color.fromRGBO(70, 70, 70, 1))
                ],
              ),
            ),
          if (task.isFinish)
            $CompletedHomeworkProgressBar(
              color: Color.fromRGBO(76, 199, 147, 1),
              percent: task.objectivePrecision,
              title: '客观题正确率：',
              padingEdg: padingEdg,
              marginEdg: EdgeInsets.only(top: 8.h),
            ),
          if (task.isFinish)
            $CompletedHomeworkProgressBar(
              color: Color.fromRGBO(76, 199, 147, 1),
              percent: task.subjectivePrecision,
              title: '主观题正确率：',
              padingEdg: padingEdg,
              marginEdg: EdgeInsets.only(top: 8.h),
            ),
          if (task.isFinish)
            $CompletedHomeworkProgressBar(
              color: Color.fromRGBO(76, 199, 147, 1),
              percent: task.precision,
              title: '总正确率：',
              padingEdg: padingEdg,
              marginEdg: EdgeInsets.only(top: 8.h),
            ),
          SizedBox(height: 13.h),
          Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.only(
                bottomLeft: Radius.circular(10.r),
                bottomRight: Radius.circular(10.r),
              ),
              color: Colors.white,
              boxShadow: [
                BoxShadow(
                  color: const Color.fromRGBO(0, 0, 0, 0.15),
                  offset: Offset(0, -0.0001), //阴影y轴偏移量
                  blurRadius: 5, //阴影模糊程度
                  spreadRadius: 0, //阴影扩散程度
                )
              ],
            ),
            child: Row(
              children: task.isFinish
                  ? [
                      Expanded(
                        child: InkWell(
                          onTap: () => easyThrottle('go_to_review_homework', () => quickDataCheck(task)),
                          child: Container(
                            alignment: Alignment.center,
                            child: quickText('数据快查', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                          ),
                        ),
                      ),
                      Container(width: 1.w, height: 36.h, color: Color.fromRGBO(221, 221, 221, 1)),
                      Expanded(
                          child: InkWell(
                        onTap: () => easyThrottle('go_to_end_review_homework', () => jobViewReport(task)),
                        child: Container(
                          alignment: Alignment.center,
                          child: quickText('查看报告', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                        ),
                      )),
                    ]
                  : [
                      Expanded(
                        child: InkWell(
                          onTap: () => easyThrottle('go_to_review_homework', () => goToReview(task)),
                          child: Container(
                            alignment: Alignment.center,
                            child: quickText('批阅', color: Color.fromRGBO(79, 79, 79, 1), size: 12.sp),
                          ),
                        ),
                      ),
                      Container(width: 1.w, height: 36.h, color: Color.fromRGBO(221, 221, 221, 1)),
                      Expanded(
                          child: InkWell(
                        onTap: () => easyThrottle('go_to_end_review_homework', () => endReview(task)),
                        child: Container(
                          alignment: Alignment.center,
                          child: quickText('结束批阅', color: Color.fromRGBO(118, 118, 118, 1), size: 12.sp),
                        ),
                      )),
                    ],
            ),
          ),
        ],
      ));
}

@swidget
Widget $completedHomeworkProgressBar(
  BuildContext context, {
  double? fontSize,
  double? lineHeight,
  required String title,
  required Color color,
  required double percent,
  required EdgeInsets padingEdg,
  required EdgeInsets marginEdg,
}) {
  var percentStr = '${doubleToStringAsFixed(percent * 100)}%';
  fontSize ??= 10.sp;
  lineHeight ??= 8.h;
  return Container(
    margin: marginEdg,
    padding: padingEdg,
    child: Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        if (title == '总正确率：') quickText('确率', color: Colors.transparent, size: fontSize),
        quickText(title, color: Color.fromRGBO(139, 139, 139, 1), size: fontSize),
        Expanded(
          flex: 1,
          child: Container(
            child: Row(
              children: [
                Expanded(
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(10.r),
                      boxShadow: [
                        BoxShadow(
                          color: color,
                          spreadRadius: 0.6,
                          blurRadius: 3,
                          offset: Offset(0, 0),
                        ),
                      ],
                    ),
                    child: LinearPercentIndicator(
                      padding: EdgeInsets.zero,
                      animation: true,
                      lineHeight: lineHeight,
                      animationDuration: 2500,
                      percent: percent,
                      center: Text(
                        percentStr,
                        style: TextStyle(color: Colors.white, fontSize: 4.5.sp),
                      ),
                      // linearStrokeCap: LinearStrokeCap.butt,
                      progressColor: color,
                      backgroundColor: Colors.white,
                      barRadius: Radius.circular(10.r),
                      // linearGradient: LinearGradient(
                      //   tileMode: TileMode.mirror,
                      //   stops: [0.0, 1.0],
                      //   colors: [color.withOpacity(0.1), color],
                      // ),
                    ),
                  ),
                ),
                SizedBox(width: 4.w),
                quickText(percentStr, size: fontSize, color: color)
              ],
            ),
          ),
        ),
      ],
    ),
  );
}

/// 一键批阅
typedef OneClickReview = void Function(int);

/// 前往批阅
typedef GoToReview = void Function(MarkingTasks);

/// 结束批阅
typedef EndReview = void Function(MarkingTasks);

/// 数据快查
typedef QuickDataCheck = void Function(MarkingTasks);

/// 收藏夹
typedef Bookmarks = void Function(MarkingTasks);

/// 查看作业报告
typedef JobViewReport = void Function(MarkingTasks);

/// 展示学生名单
typedef ShowStudentList = void Function(List<int> taskIds, [String? className, bool submitted]);

/// 查看学生名单
// void showStudentList([bool submitted = false]) {

// }
