diff --git a/making_school_asignment_app/lib/common/config/request_config.dart b/making_school_asignment_app/lib/common/config/request_config.dart index a101124..9803e1b 100644 --- a/making_school_asignment_app/lib/common/config/request_config.dart +++ b/making_school_asignment_app/lib/common/config/request_config.dart @@ -20,8 +20,8 @@ class RequestConfig { static const connectTimeout = 8000; // 连接超时 static const receiveTimeout = 8000; // 接收超时 - static const bool requestDataPrinting = true; // 打印返回数据 - static const bool printSwitch = true; // 打印返回数据 + static const bool requestDataPrinting = false; // 打印返回数据 + static const bool printSwitch = false; // 打印返回数据 static const successCode = [204, 200]; // 返回成功code static final BasePage basePage = BasePage(1, 10); // 分页参数 diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart index f241f2b..954415e 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; +import 'package:gesture_zoom_box/gesture_zoom_box.dart'; import 'package:get/get.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart'; @@ -41,15 +42,14 @@ class _QuestionPaperViewState extends State { // 试题图片视图 Expanded( flex: 7, - child: LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { var maxWidth = constraints.maxWidth; var maxHeight = constraints.maxHeight; + return Stack( children: [ // 主图 - QuestionImageView( - maxWidth, maxHeight, sateData, annotationState, logic), + QuestionImageView(maxWidth, maxHeight, sateData, annotationState, logic), // 继续批阅按钮 // Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)), // 上一题按钮 @@ -63,19 +63,15 @@ class _QuestionPaperViewState extends State { heroTag: '点击前往上一题', tooltip: '点击前往上一题', focusColor: Theme.of(context).primaryColor, - backgroundColor: - const Color.fromRGBO(24, 32, 32, 0.05), + backgroundColor: const Color.fromRGBO(24, 32, 32, 0.05), elevation: 10.r, - onPressed: () => - easyThrottle('TestQuestionSwitch', () { + onPressed: () => easyThrottle('TestQuestionSwitch', () { var param = sateData.param.value; param.studentId = lastPageVal.studentId; param.templateId = lastPageVal.templateId; - sateData.param.value = - DoPaperDetailsParam.fromJson(param.toJson()); + sateData.param.value = DoPaperDetailsParam.fromJson(param.toJson()); }), - child: Icon(Icons.arrow_back_ios, - color: Colors.white, size: 22.sp), + child: Icon(Icons.arrow_back_ios, color: Colors.white, size: 22.sp), ); }), ), @@ -90,18 +86,14 @@ class _QuestionPaperViewState extends State { heroTag: '点击前往下一题', tooltip: '点击前往下一题', elevation: 10.r, - backgroundColor: - const Color.fromRGBO(24, 32, 32, 0.05), - onPressed: () => - easyThrottle('TestQuestionSwitch', () { + backgroundColor: const Color.fromRGBO(24, 32, 32, 0.05), + onPressed: () => easyThrottle('TestQuestionSwitch', () { var param = sateData.param.value; param.studentId = nextPageVal.studentId; param.templateId = nextPageVal.templateId; - sateData.param.value = - DoPaperDetailsParam.fromJson(param.toJson()); + sateData.param.value = DoPaperDetailsParam.fromJson(param.toJson()); }), - child: Icon(Icons.arrow_forward_ios, - color: Colors.white, size: 22.sp), + child: Icon(Icons.arrow_forward_ios, color: Colors.white, size: 22.sp), ); }), ), @@ -122,8 +114,7 @@ class _QuestionPaperViewState extends State { child: CupertinoButton( color: Colors.grey[300], onPressed: () => easyThrottle('home_work_reload_data', () { - sateData.param.value = - DoPaperDetailsParam.fromJson(sateData.param.value.toJson()); + sateData.param.value = DoPaperDetailsParam.fromJson(sateData.param.value.toJson()); }), child: quickText('重新请求', color: Colors.black38), ), @@ -136,8 +127,7 @@ class _QuestionPaperViewState extends State { // 底部已阅数量和待阅数量 @swidget -Widget $totalSubmitCountView( - BuildContext context, HomeworkReviewState sateData) { +Widget $totalSubmitCountView(BuildContext context, HomeworkReviewState sateData) { return Obx(() { var data = sateData.data.value; if (data == null) return Container(); @@ -152,10 +142,7 @@ Widget $totalSubmitCountView( context: context, elevation: 10, backgroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10.r), - topRight: Radius.circular(10.r))), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(10.r), topRight: Radius.circular(10.r))), builder: (BuildContext context) { return Padding( padding: EdgeInsets.symmetric(horizontal: 2.w), @@ -173,8 +160,7 @@ Widget $totalSubmitCountView( SizedBox(height: 10.h), Expanded( child: ListView( - padding: EdgeInsets.symmetric( - vertical: 8.h, horizontal: 4.w), + padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 4.w), children: [ Wrap( spacing: 7.2.w, // 主轴(水平)方向间距 @@ -185,39 +171,27 @@ Widget $totalSubmitCountView( alignment: const FractionalOffset(0.05, 0.09), children: [ Container( - padding: EdgeInsets.only( - top: 1.2.h, - bottom: 1.5.h, - left: 13.w, - right: 5.w), + padding: EdgeInsets.only(top: 1.2.h, bottom: 1.5.h, left: 13.w, right: 5.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: const Color.fromRGBO( - 239, 242, 255, 1), + color: const Color.fromRGBO(239, 242, 255, 1), ), child: quickText( e.name, size: 12.sp, wordSpacing: 2, - color: - const Color.fromRGBO(80, 94, 110, 1), + color: const Color.fromRGBO(80, 94, 110, 1), ), ), Stack( - alignment: - const FractionalOffset(0.52, 0.24), + alignment: const FractionalOffset(0.52, 0.24), children: [ Icon( - const IconData(0xe63d, - fontFamily: "AlibabaIcon"), + const IconData(0xe63d, fontFamily: "AlibabaIcon"), size: 12.sp, - color: e.isPriority - ? Theme.of(context).primaryColor - : const Color.fromRGBO( - 164, 164, 164, 1), + color: e.isPriority ? Theme.of(context).primaryColor : const Color.fromRGBO(164, 164, 164, 1), ), - quickText('优先', - size: 4.sp, color: Colors.white), + quickText('优先', size: 4.sp, color: Colors.white), ], ), ], @@ -239,17 +213,11 @@ Widget $totalSubmitCountView( children: [ Padding( padding: EdgeInsets.only(bottom: 1.h), - child: quickText('已阅', - color: const Color.fromRGBO(117, 117, 117, 1), size: 10.sp), + child: quickText('已阅', color: const Color.fromRGBO(117, 117, 117, 1), size: 10.sp), ), - quickText(data.annotatedCount, - color: Theme.of(context).primaryColor, - size: 12.sp, - fontWeight: FontWeight.bold), - quickText('/', - color: const Color.fromRGBO(117, 117, 117, 1), size: 12.sp), - quickText(data.submitCount - data.annotatedCount, - color: const Color.fromRGBO(117, 117, 117, 1), size: 10.sp), + quickText(data.annotatedCount, color: Theme.of(context).primaryColor, size: 12.sp, fontWeight: FontWeight.bold), + quickText('/', color: const Color.fromRGBO(117, 117, 117, 1), size: 12.sp), + quickText(data.submitCount - data.annotatedCount, color: const Color.fromRGBO(117, 117, 117, 1), size: 10.sp), ], ), ), @@ -259,18 +227,15 @@ Widget $totalSubmitCountView( // 试题题号视图 @hwidget -Widget $questionNumberView(BuildContext context, HomeworkReviewLogic logic, - HomeworkReviewState sateData) { +Widget $questionNumberView(BuildContext context, HomeworkReviewLogic logic, HomeworkReviewState sateData) { final scrollControllerNum = useScrollController(); // 试题题号区域 useEffect(() { scrollControllerNum.addListener(() { - if (sateData.panQuestView == false) - sateData.slide.value = scrollControllerNum.offset; + if (sateData.panQuestView == false) sateData.slide.value = scrollControllerNum.offset; }); var listenVal = sateData.slide.listen((e) { - if (e != scrollControllerNum.offset && sateData.panQuestView == true) - scrollControllerNum.jumpTo(e); + if (e != scrollControllerNum.offset && sateData.panQuestView == true) scrollControllerNum.jumpTo(e); }); return () { @@ -307,20 +272,13 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewLogic logic, return Container( height: boxHeight > actualImgHeight ? boxHeight : actualImgHeight, - padding: EdgeInsets.only( - top: imageVal.remainingHeight > 0 - ? imageVal.remainingHeight / 2 - : 0), + padding: EdgeInsets.only(top: imageVal.remainingHeight > 0 ? imageVal.remainingHeight / 2 : 0), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: studentQuestions ?.asMap() .keys - .map((e) => $ScoringQuestionsView( - logic, - studentQuestions[e], - imageVal.scaleRatio, - studentQuestions)) + .map((e) => $ScoringQuestionsView(logic, studentQuestions[e], imageVal.scaleRatio, studentQuestions)) .toList() ?? [], ), @@ -333,11 +291,7 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewLogic logic, // 单道题得分框 @hwidget Widget $scoringQuestionsView( - BuildContext context, - HomeworkReviewLogic logic, - StudentQuestions item, - double scaleRatio, - List? studentQuestions) { + BuildContext context, HomeworkReviewLogic logic, StudentQuestions item, double scaleRatio, List? studentQuestions) { var studentScore = useState(item.studentScore); useValueChanged(studentScore.value, (_, __) { @@ -346,8 +300,7 @@ Widget $scoringQuestionsView( // 校验是否自动提交 对于已经批阅过的试题 不重复自动提交 var annotateTime = logic.state.data.value?.annotateTime; if (annotateTime == null) { - var noRatingGiven = - studentQuestions!.firstWhereOrNull((e) => e.studentScore == null); + var noRatingGiven = studentQuestions!.firstWhereOrNull((e) => e.studentScore == null); if (noRatingGiven == null) logic.submit(context); } }); @@ -359,143 +312,122 @@ Widget $scoringQuestionsView( useEffect(() { return () {}; }, []); - var padinVal = item.correctRate > 0 - ? EdgeInsets.only(top: 6.4.h) - : EdgeInsets.symmetric(vertical: 2.h); + var padinVal = item.correctRate > 0 ? EdgeInsets.only(top: 6.4.h) : EdgeInsets.symmetric(vertical: 2.h); return Container( height: item.height! * scaleRatio, padding: EdgeInsets.zero, - child: item.useTime == 0?Container():Stack( - alignment: const FractionalOffset(0, 0), - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // 对 - Expanded( - child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: EdgeInsets.zero, - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - backgroundColor: - const Color.fromRGBO(237, 237, 237, 1), // 设置背景色 - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero), // 去除圆角 - ), - child: Padding( - padding: padinVal, - child: Icon( - size: 22.sp, - color: studentScore.value == 2 - ? const Color(0xFF54971F) - : const Color.fromRGBO(114, 114, 114, 1), - const IconData(0xe62b, fontFamily: "AlibabaIcon"), - ), - ), - onPressed: () => easyThrottle('scoring_homework_questions', () { - studentScore.value = studentScore.value == 2 ? null : 2; - }, duration: const Duration(milliseconds: 222)), - ), - ), - // 半 - Expanded( - child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: EdgeInsets.zero, - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - backgroundColor: - const Color.fromRGBO(237, 237, 237, 1), // 设置背景色 - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero), // 去除圆角 - ), - child: Padding( - padding: padinVal, - child: Icon( - size: 22.sp, - color: studentScore.value == 1 - ? const Color(0xFF54971F) - : const Color.fromRGBO(114, 114, 114, 1), - const IconData(0xe62c, fontFamily: "AlibabaIcon"), - ), - ), - onPressed: () => easyThrottle('scoring_homework_questions', () { - studentScore.value = studentScore.value == 1 ? null : 1; - }, duration: const Duration(milliseconds: 222)), - ), - ), - // 错 - Expanded( - child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: EdgeInsets.zero, - tapTargetSize: MaterialTapTargetSize.shrinkWrap, - backgroundColor: - const Color.fromRGBO(237, 237, 237, 1), // 设置背景色 - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.zero), // 去除圆角 - ), - child: Padding( - padding: padinVal, - child: Icon( - size: 22.sp, - color: studentScore.value == 0 - ? const Color(0xFF54971F) - : const Color.fromRGBO(114, 114, 114, 1), - const IconData(0xe62a, fontFamily: "AlibabaIcon"), - ), - ), - onPressed: () => easyThrottle('scoring_homework_questions', () { - studentScore.value = studentScore.value == 0 ? null : 0; - }, duration: const Duration(milliseconds: 222)), - ), - ), - ], - ), - IgnorePointer( - // 事件穿透 - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, + child: item.useTime == 0 + ? Container() + : Stack( + alignment: const FractionalOffset(0, 0), children: [ - SizedBox(width: 1.1.w), - quickText('${item.questionNo}', - color: Theme.of(context).primaryColor.withOpacity(0.7), - size: 8.sp), - if (item.correctRate > 0) - quickText(' 正确率', color: Colors.grey, size: 5.sp), - if (item.correctRate > 0) - Expanded( - child: LinearPercentIndicator( - lineHeight: 6.h, - percent: item.correctRate / 100, - barRadius: Radius.circular(1.2.r), - alignment: MainAxisAlignment.center, - progressColor: Theme.of(context).primaryColor, - backgroundColor: const Color(0xFFB8C7CB).withOpacity(0.35), - center: quickText("${item.correctRate}%", - size: 5.sp, - align: TextAlign.center, - color: Colors.white), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 对 + Expanded( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + padding: EdgeInsets.zero, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + backgroundColor: const Color.fromRGBO(237, 237, 237, 1), // 设置背景色 + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), // 去除圆角 + ), + child: Padding( + padding: padinVal, + child: Icon( + size: 22.sp, + color: studentScore.value == 2 ? Colors.green : const Color.fromRGBO(114, 114, 114, 1), + const IconData(0xe62b, fontFamily: "AlibabaIcon"), + ), + ), + onPressed: () => easyThrottle('scoring_homework_questions', () { + studentScore.value = studentScore.value == 2 ? null : 2; + }, duration: const Duration(milliseconds: 222)), + ), ), - ) + // 半 + Expanded( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + padding: EdgeInsets.zero, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + backgroundColor: const Color.fromRGBO(237, 237, 237, 1), // 设置背景色 + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), // 去除圆角 + ), + child: Padding( + padding: padinVal, + child: Icon( + size: 22.sp, + color: studentScore.value == 1 ? Colors.green : const Color.fromRGBO(114, 114, 114, 1), + const IconData(0xe62c, fontFamily: "AlibabaIcon"), + ), + ), + onPressed: () => easyThrottle('scoring_homework_questions', () { + studentScore.value = studentScore.value == 1 ? null : 1; + }, duration: const Duration(milliseconds: 222)), + ), + ), + // 错 + Expanded( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + padding: EdgeInsets.zero, + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + backgroundColor: const Color.fromRGBO(237, 237, 237, 1), // 设置背景色 + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero), // 去除圆角 + ), + child: Padding( + padding: padinVal, + child: Icon( + size: 22.sp, + color: studentScore.value == 0 ? Colors.green : const Color.fromRGBO(114, 114, 114, 1), + const IconData(0xe62a, fontFamily: "AlibabaIcon"), + ), + ), + onPressed: () => easyThrottle('scoring_homework_questions', () { + studentScore.value = studentScore.value == 0 ? null : 0; + }, duration: const Duration(milliseconds: 222)), + ), + ), + ], + ), + IgnorePointer( + // 事件穿透 + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(width: 1.1.w), + quickText('${item.questionNo}', color: Theme.of(context).primaryColor.withOpacity(0.7), size: 8.sp), + if (item.correctRate > 0) quickText(' 正确率', color: Colors.grey, size: 5.sp), + if (item.correctRate > 0) + Expanded( + child: LinearPercentIndicator( + lineHeight: 6.h, + percent: item.correctRate / 100, + barRadius: Radius.circular(1.2.r), + alignment: MainAxisAlignment.center, + progressColor: Theme.of(context).primaryColor, + backgroundColor: const Color(0xFFB8C7CB).withOpacity(0.35), + center: quickText("${item.correctRate}%", size: 5.sp, align: TextAlign.center, color: Colors.white), + ), + ) + ], + ), + ), ], ), - ), - ], - ), ); } // 试题图片视图 -class QuestionImageView extends HookWidget - with EventBusMixin { +class QuestionImageView extends HookWidget with EventBusMixin { final double maxWidth; final double maxHeight; final HomeworkReviewLogic logic; final HomeworkReviewState sateData; final HomeworkReviewAnnotationsControlState annotationState; - QuestionImageView(this.maxWidth, this.maxHeight, this.sateData, - this.annotationState, this.logic, - {super.key}); + QuestionImageView(this.maxWidth, this.maxHeight, this.sateData, this.annotationState, this.logic, {super.key}); /// 获取数组指定倒数具体值的下标 int _findTargetIndex(List list, T target, [int reciprocal = 2]) { @@ -511,10 +443,14 @@ class QuestionImageView extends HookWidget int activePointers = 0; + ImageStream? imageStream; + @override Widget build(BuildContext context) { + final theMaxHeight = useState(maxHeight); final scrollControllerQuestion = useScrollController(); // 试题图片区域 var vnHandWritings = useValueNotifier>([]); + var customPaintSize = useState(Size.zero); useEffect(() { var listenStream = sateData.data.listen((e) { @@ -522,17 +458,24 @@ class QuestionImageView extends HookWidget sateData.handwritings = []; vnHandWritings.value = sateData.handwritings; }); - return () => listenStream.cancel(); + var listenStreamImageScale = sateData.imageScale.listen((e) { + customPaintSize.value = Size( + sateData.imageScale.value?.actualImgWidth ?? 0, + sateData.imageScale.value?.actualImgHeight ?? 0, + ); + }); + return () { + listenStream.cancel(); + listenStreamImageScale.cancel(); + }; }, []); - ImageStream? imageStream; - var imageStreamListener = useState( - ImageStreamListener((ImageInfo info, bool _) { + var imageStreamListener = useState(ImageStreamListener((ImageInfo info, bool _) { WidgetsBinding.instance.addPostFrameCallback((_) { sateData.imageScale.value = TestQuestionsImageInfo( templateId: sateData.data.value?.templateId, boxWidth: maxWidth, - boxHeight: maxHeight, + boxHeight: theMaxHeight.value, imageWidth: info.image.width.toDouble(), imageHeight: info.image.height.toDouble(), url: sateData.data.value!.zgtAnswer, @@ -550,17 +493,10 @@ class QuestionImageView extends HookWidget bool? res = await showDialog( context: context, builder: (context1) { - return AlertDialog( - content: quickText("是否撤销全部批注痕迹?"), - actions: [ - TextButton( - child: quickText("取消"), - onPressed: () => Navigator.pop(context1, false)), - TextButton( - child: quickText("确定", - color: Theme.of(context).primaryColor), - onPressed: () => Navigator.pop(context1, true)) - ]); + return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: [ + TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), + TextButton(child: quickText("确定", color: Theme.of(context).primaryColor), onPressed: () => Navigator.pop(context1, true)) + ]); }, ); if (res == true) vnHandWritings.value = []; @@ -570,22 +506,17 @@ class QuestionImageView extends HookWidget await showDialog( context: context, builder: (context1) { - return AlertDialog( - content: quickText("是否撤销上次批阅批注痕迹?"), - actions: [ - TextButton( - child: quickText("取消"), - onPressed: () => Navigator.pop(context1, false)), - TextButton( - child: quickText("确定", - color: Theme.of(context).primaryColor), - onPressed: () { - Navigator.pop(context1, true); - sateData.data.value?.zgtAnnotate = null; - sateData.data.value?.showZgtAnnotate = null; - }, - ) - ]); + return AlertDialog(content: quickText("是否撤销上次批阅批注痕迹?"), actions: [ + TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), + TextButton( + child: quickText("确定", color: Theme.of(context).primaryColor), + onPressed: () { + Navigator.pop(context1, true); + sateData.data.value?.zgtAnnotate = null; + sateData.data.value?.showZgtAnnotate = null; + }, + ) + ]); }, ); } @@ -600,22 +531,17 @@ class QuestionImageView extends HookWidget await showDialog( context: context, builder: (context1) { - return AlertDialog( - content: quickText("是否撤销上次批阅批注痕迹?"), - actions: [ - TextButton( - child: quickText("取消"), - onPressed: () => Navigator.pop(context1, false)), - TextButton( - child: quickText("确定", - color: Theme.of(context).primaryColor), - onPressed: () { - Navigator.pop(context1, true); - sateData.data.value?.zgtAnnotate = null; - sateData.data.value?.showZgtAnnotate = null; - }, - ) - ]); + return AlertDialog(content: quickText("是否撤销上次批阅批注痕迹?"), actions: [ + TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), + TextButton( + child: quickText("确定", color: Theme.of(context).primaryColor), + onPressed: () { + Navigator.pop(context1, true); + sateData.data.value?.zgtAnnotate = null; + sateData.data.value?.showZgtAnnotate = null; + }, + ) + ]); }, ); } @@ -636,8 +562,7 @@ class QuestionImageView extends HookWidget }); // 执行滚动相关的逻辑,例如打印滚动位置 var listenVal = sateData.slide.listen((e) { - if (e != scrollControllerQuestion.offset && - sateData.panQuestView == false) scrollControllerQuestion.jumpTo(e); + if (e != scrollControllerQuestion.offset && sateData.panQuestView == false) scrollControllerQuestion.jumpTo(e); }); // 返回一个清理函数,在组件销毁时移除监听 @@ -648,6 +573,10 @@ class QuestionImageView extends HookWidget }; }, []); + useValueChanged(maxHeight, (oldValue, __) { + theMaxHeight.value = maxHeight; + }); + return Container( height: maxHeight, // padding: EdgeInsets.only(bottom: 2.h, top: 2.h), @@ -655,25 +584,19 @@ class QuestionImageView extends HookWidget child: Obx(() { var imageUrl = sateData.data.value?.zgtAnswer; var showZgtAnnotate = sateData.data.value?.showZgtAnnotate; + if (imageUrl == null) return const SizedBox(); return GestureDetector( onPanDown: (_) => sateData.panQuestView = true, child: SingleChildScrollView( controller: scrollControllerQuestion, - physics: !annotationState.pen.value - ? const BouncingScrollPhysics() - : const NeverScrollableScrollPhysics(), + physics: !annotationState.pen.value ? const BouncingScrollPhysics() : const NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, scrollDirection: Axis.vertical, // 设置垂直滚动 child: Container( - decoration: BoxDecoration(boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.2), - offset: Offset(-6.r, 1.r), - blurRadius: 10.r, - spreadRadius: 8.r) - ]), + decoration: BoxDecoration( + boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), offset: Offset(-6.r, 1.r), blurRadius: 10.r, spreadRadius: 8.r)]), child: Listener( behavior: HitTestBehavior.opaque, onPointerDown: (PointerDownEvent event) { @@ -700,11 +623,9 @@ class QuestionImageView extends HookWidget if (imageScale == null || !annotationState.pen.value) return; Offset localPosition = event.localPosition; var dy = localPosition.dy; - if (dy > imageScale.actualImgHeight || dy < 0) - return; // 检查笔记是否超出图片范围 + if (dy > imageScale.actualImgHeight || dy < 0) return; // 检查笔记是否超出图片范围 - vnHandWritings.value = List.from(vnHandWritings.value) - ..add(localPosition); + vnHandWritings.value = List.from(vnHandWritings.value)..add(localPosition); sateData.handwritings = vnHandWritings.value; }, child: Stack( @@ -712,28 +633,23 @@ class QuestionImageView extends HookWidget $TheCachedNetworkImage( imageUrl: imageUrl, (context, imageProvider) { - Image imageWidget = - Image(image: imageProvider, fit: BoxFit.fitWidth); + Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth); imageStream?.removeListener(imageStreamListener.value); - imageStream = imageWidget.image - .resolve(const ImageConfiguration()) - ..addListener(imageStreamListener.value); + imageStream = imageWidget.image.resolve(const ImageConfiguration())..addListener(imageStreamListener.value); + // return imageWidget; return imageWidget; }, ), RepaintBoundary( key: logic.pictureOverviewKey, child: CustomPaint( + isComplex: true, + size: customPaintSize.value, foregroundPainter: DrawingPainter(ctrl: vnHandWritings), - size: Size( - sateData.imageScale.value?.actualImgWidth ?? 0, - sateData.imageScale.value?.actualImgHeight ?? 0, - ), child: showZgtAnnotate != null ? $TheCachedNetworkImage( imageUrl: showZgtAnnotate, - (_, imageProvider) => Image( - image: imageProvider, fit: BoxFit.fitWidth), + (_, imageProvider) => Image(image: imageProvider, fit: BoxFit.fitWidth), ) : null, ), @@ -765,8 +681,7 @@ class DrawingPainter extends CustomPainter { for (int i = 0; i < pointsLength; i++) { Offset? offsetData = points[i]; Offset? nextOffsetData = pointsLength - 1 == i ? null : points[i + 1]; - if (offsetData != null && nextOffsetData != null) - canvas.drawLine(offsetData, nextOffsetData, paintBrush); + if (offsetData != null && nextOffsetData != null) canvas.drawLine(offsetData, nextOffsetData, paintBrush); } } diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart index a43bd33..20d7ab4 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart @@ -5,12 +5,12 @@ import 'package:get/get.dart'; import 'package:making_school_asignment_app/page/global_widget/ReturnToHomepage.dart'; import 'package:making_school_asignment_app/page/global_widget/my_text.dart'; import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_logic.dart'; +import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/question_paper_view.dart'; import 'package:making_school_asignment_app/page/home_page/home_logic.dart'; import 'components/bottom_operation_bar.dart'; import 'components/dropdown_switch_students_type.dart'; import 'components/favorite_widget.dart'; -import 'components/question_paper_view.dart'; import 'configuration_files/index.dart'; class HomeworkReview extends StatefulWidget { @@ -21,6 +21,7 @@ class HomeworkReview extends StatefulWidget { } class _HomeworkReviewState extends State { + final ScrollController controller = ScrollController(); final logic = Get.find(); final sateData = Get.find().state; final AnnotateClassLogic _controller = Get.find(); @@ -29,12 +30,14 @@ class _HomeworkReviewState extends State { @override void initState() { WidgetsFlutterBinding.ensureInitialized(); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); // 屏幕刘海 super.initState(); } @override void dispose() { Get.delete(); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]); // 屏幕刘海 super.dispose(); } @@ -48,40 +51,46 @@ class _HomeworkReviewState extends State { _homeLogicController.getList(); } }, - child: AnnotatedRegion( - value: const SystemUiOverlayStyle( - systemNavigationBarColor: Color(0xFF000000), - systemNavigationBarDividerColor: null, - statusBarColor: Colors.transparent, - systemNavigationBarIconBrightness: Brightness.light, - statusBarIconBrightness: Brightness.light, - statusBarBrightness: Brightness.light, - ), - child: SafeArea( - child: Scaffold( - appBar: AppBar( - // titleSpacing: 0, - leading: IconButton(icon: const Icon(Icons.arrow_back_ios), onPressed: () => Get.back()), - iconTheme: const IconThemeData(color: Colors.black), - title: quickText(sateData.param.value.homeworkName), - backgroundColor: Colors.white, - elevation: 0, - actions: [const FavoriteWidget(), SizedBox(width: 5.w), const ReturnToHomepage()], - ), - body: SafeArea( - child: Column( - children: [ - // 下拉切换 - const DropdownSwitchStudentsType(), - SizedBox(height: 1.h), - const Expanded(child: QuestionPaperView()), - const BottomAnnotationSwitch() - ], - ), - ), - // floatingActionButton: const ButtonFloatingAction(), - // floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, + child: SafeArea( + child: Scaffold( + appBar: AppBar( + // titleSpacing: 0, + leading: IconButton(icon: const Icon(Icons.arrow_back_ios), onPressed: () => Get.back()), + iconTheme: const IconThemeData(color: Colors.black), + title: quickText(sateData.param.value.homeworkName), + backgroundColor: Colors.white, + elevation: 0, + actions: [const FavoriteWidget(), SizedBox(width: 5.w), const ReturnToHomepage()], ), + body: SafeArea( + child: Column( + children: [ + // 下拉切换 + const DropdownSwitchStudentsType(), + SizedBox(height: 1.h), + const Expanded(child: QuestionPaperView() + // child: CustomZoomWidget( + // child: Image.network('https://cdn3-banquan.ituchong.com/weili/image/l/903170934517792920.jpeg'), + // ), + // child: CustomZoomWidget( + // child: Image.network('https://cdn3-banquan.ituchong.com/weili/image/l/903170934517792920.jpeg'), + // minScale: 0.8, + // maxScale: 4, + // resetDuration: const Duration(milliseconds: 200), + // boundaryMargin: const EdgeInsets.only(bottom: 0), + // clipBehavior: Clip.hardEdge, + // useOverlay: false, + // maxOverlayOpacity: 0.5, + // overlayColor: Colors.black, + // fingersRequiredToPinch: 2, + // ), + ), + const BottomAnnotationSwitch() + ], + ), + ), + // floatingActionButton: const ButtonFloatingAction(), + // floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, ), ), ); diff --git a/making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.dart b/making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.dart index 88396c5..f12cded 100644 --- a/making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.dart +++ b/making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.dart @@ -28,9 +28,10 @@ class _ReadOverPageState extends State { Widget build(BuildContext context) { return AnnotatedRegion( value: const SystemUiOverlayStyle( - /* systemNavigationBarColor: Color(0xFF000000), + /* systemNavigationBarColor: Color(0xFF000000), systemNavigationBarDividerColor: null,*/ - statusBarColor: Colors.transparent, + statusBarColor: Colors.white, + systemNavigationBarDividerColor: null, systemNavigationBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light, statusBarBrightness: Brightness.light, @@ -177,7 +178,12 @@ class _ReadOverPageState extends State { @override void dispose() { Get.delete(); - super.dispose(); logic.homeController.getList(); + SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( + statusBarColor: Colors.transparent, //状态栏背景颜色 + statusBarIconBrightness: Brightness.light, + systemStatusBarContrastEnforced: false, + )); + super.dispose(); } } diff --git a/making_school_asignment_app/lib/page/home_page/children/read_over/widget/annotate_list.dart b/making_school_asignment_app/lib/page/home_page/children/read_over/widget/annotate_list.dart index d720c2a..1140f73 100644 --- a/making_school_asignment_app/lib/page/home_page/children/read_over/widget/annotate_list.dart +++ b/making_school_asignment_app/lib/page/home_page/children/read_over/widget/annotate_list.dart @@ -19,23 +19,22 @@ import 'package:making_school_asignment_app/common/job/work_student.dart'; part 'annotate_list.g.dart'; -class AnnotateList extends StatefulWidget{ +class AnnotateList extends StatefulWidget { final int tabIndex; final int assessType; - const AnnotateList({Key? key,required this.tabIndex,required this.assessType}) : super(key: key); + const AnnotateList({super.key, required this.tabIndex, required this.assessType}); @override State createState() => _AnnotateListState(); } -class _AnnotateListState extends State with RequestToolMixin, SingleTickerProviderStateMixin{ +class _AnnotateListState extends State with RequestToolMixin, SingleTickerProviderStateMixin { late RxString customTimeStr = '自定义'.obs; int active = 1; late RxList unAnnotateList = RxList(); late RxList annotateList = RxList(); late int page = 1; - late TabController tabController2; /* 待阅卷 */ late final EasyRefreshController refreshController1; @@ -50,7 +49,7 @@ class _AnnotateListState extends State with RequestToolMixin, Sing ); @override - void initState(){ + void initState() { super.initState(); params.assessType = widget.assessType; params2.assessType = widget.assessType; @@ -61,7 +60,6 @@ class _AnnotateListState extends State with RequestToolMixin, Sing EasyLoading.show(status: 'loading...'); getUnAnnotateList(); getAnnotateList(); - } //待批阅列表 @@ -75,6 +73,7 @@ class _AnnotateListState extends State with RequestToolMixin, Sing EasyLoading.dismiss(); print('state.unAnnotateList.length=${unAnnotateList.length}'); } + //已批阅列表 void getAnnotateList() async { WorkStudent data = WorkStudent([], 0); @@ -87,6 +86,7 @@ class _AnnotateListState extends State with RequestToolMixin, Sing EasyLoading.dismiss(); print('state.annotateList.length=${annotateList.length}'); } + /// 刷新方法 Future onMyRefresh(EasyRefreshController controller, int tab) async { /* params.page = RequestConfig.basePage.page; @@ -95,19 +95,18 @@ class _AnnotateListState extends State with RequestToolMixin, Sing tab == 1 ? (markingDatas1 = lists) : (markingDatas2 = lists); } catch (e) {} toUpState(setState, () {}, mounted);*/ - if(widget.tabIndex == 0){ + if (widget.tabIndex == 0) { getUnAnnotateList(); - }else{ + } else { getAnnotateList(); } - } Future getCollect(item) async { await getClient().getCollect(item.id); - if(widget.tabIndex == 0){ + if (widget.tabIndex == 0) { getUnAnnotateList(); - }else{ + } else { getAnnotateList(); } } @@ -122,52 +121,51 @@ class _AnnotateListState extends State with RequestToolMixin, Sing }*/ } - @override Widget build(BuildContext context) { return Column( children: [ - if(widget.tabIndex == 1) - JobConditionFilter( - customTimeStr: customTimeStr.value, - controller: tabController2, - hasAll: true, - jobType: 1, - customTime: tabController2.index != 3 || (params2.startDate == null && params2.endDate == null) - ? null - : PickerDateRange( - params2.startDate == null ? null : DateTime.parse(params2.startDate!), - params2.endDate == null ? null : DateTime.parse(params2.endDate!), - ), - onTimeFilter: (String? startTime, String? endTime) { - if (startTime == null && endTime == null && tabController2.index == 3) { - tabController2.animateTo(0); - } - params2.endDate = endTime; - params2.startDate = startTime; - page = 1; - if(widget.tabIndex == 0){ - getUnAnnotateList(); - }else{ - getAnnotateList(); - } - // refreshController2.callRefresh(); - }, - refreshTime: (value) { - if (value != null && value.startDate != null) { - customTimeStr.value = value.startDate?.toString().substring(0, 10) ?? ''; + if (widget.tabIndex == 1) + JobConditionFilter( + customTimeStr: customTimeStr.value, + controller: tabController2, + hasAll: true, + jobType: 1, + customTime: tabController2.index != 3 || (params2.startDate == null && params2.endDate == null) + ? null + : PickerDateRange( + params2.startDate == null ? null : DateTime.parse(params2.startDate!), + params2.endDate == null ? null : DateTime.parse(params2.endDate!), + ), + onTimeFilter: (String? startTime, String? endTime) { + if (startTime == null && endTime == null && tabController2.index == 3) { + tabController2.animateTo(0); + } + params2.endDate = endTime; + params2.startDate = startTime; + page = 1; + if (widget.tabIndex == 0) { + getUnAnnotateList(); + } else { + getAnnotateList(); + } + // refreshController2.callRefresh(); + }, + refreshTime: (value) { + if (value != null && value.startDate != null) { + customTimeStr.value = value.startDate?.toString().substring(0, 10) ?? ''; - if (value.endDate != null) { - if (!Utils.isPad() && value.startDate!.year == value.endDate!.year) { - customTimeStr.value = - '${value.startDate.toString().substring(5, 10)}~${value.endDate.toString().substring(5, 10)}'; - } else { - customTimeStr.value = '${customTimeStr.value}~${value.endDate?.toString().substring(0, 10)}'; + if (value.endDate != null) { + if (!Utils.isPad() && value.startDate!.year == value.endDate!.year) { + customTimeStr.value = '${value.startDate.toString().substring(5, 10)}~${value.endDate.toString().substring(5, 10)}'; + } else { + customTimeStr.value = '${customTimeStr.value}~${value.endDate?.toString().substring(0, 10)}'; + } } } - } - }), - Expanded(child: IndexedStack( + }), + Expanded( + child: IndexedStack( index: widget.tabIndex, children: [ $EasyRefresh( @@ -220,33 +218,27 @@ Widget $easyRefresh({ footer: TaurusFooter(), child: completed && isPadFlag ? GridView( - padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, //横轴三个子widget - mainAxisSpacing: 10.h, - crossAxisSpacing: 6.w, - childAspectRatio: 1.81 //宽高比为1时,子widget - ), - children: List.generate(data.length, (index) { - Items item = data[index]; - String subjectName = EnumUtils.formatSubject(item.subject); - return $reviewedItem(jobTaskItem: item, type: type, subjectName: subjectName, collectFun: collectFun,tabIndex:tab - 1); - }), - ) + padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, //横轴三个子widget + mainAxisSpacing: 10.h, + crossAxisSpacing: 6.w, + childAspectRatio: 1.81 //宽高比为1时,子widget + ), + children: List.generate(data.length, (index) { + Items item = data[index]; + String subjectName = EnumUtils.formatSubject(item.subject); + return $reviewedItem(jobTaskItem: item, type: type, subjectName: subjectName, collectFun: collectFun, tabIndex: tab - 1); + }), + ) : ListView.builder( - padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), - itemBuilder: (context, index) { - Items item = data[index]; - return TaskListItem( - completed: completed, - jobTaskItem: item, - type: type, - collectFun: collectFun, - tabIndex:tab - 1 - ); - }, - itemCount: data.length, - ), + padding: EdgeInsets.only(top: 11.h, bottom: 10.h, left: 12.w, right: 12.w), + itemBuilder: (context, index) { + Items item = data[index]; + return TaskListItem(completed: completed, jobTaskItem: item, type: type, collectFun: collectFun, tabIndex: tab - 1); + }, + itemCount: data.length, + ), onRefresh: () => onRefresh(controller, tab), onLoad: () => onLoad(controller, tab), ); @@ -265,8 +257,14 @@ Widget $reviewedItem({ return InkWell( onTap: () { - Get.toNamed(Routes.annotateClassPage, - arguments: {'id': jobTaskItem.id, 'name': jobTaskItem.name, 'grade': jobTaskItem.grade,'subject':jobTaskItem.subject, 'completed': true,'tabIndex':tabIndex}); + Get.toNamed(Routes.annotateClassPage, arguments: { + 'id': jobTaskItem.id, + 'name': jobTaskItem.name, + 'grade': jobTaskItem.grade, + 'subject': jobTaskItem.subject, + 'completed': true, + 'tabIndex': tabIndex + }); }, child: Container( padding: EdgeInsets.only(right: 5.w), @@ -288,7 +286,6 @@ Widget $reviewedItem({ // 顶部任务名称 Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ Container( width: 32.w, @@ -304,7 +301,7 @@ Widget $reviewedItem({ bottomRight: Radius.circular(12.r), ), ), - margin: EdgeInsets.only(top:0.h,right: 4.w), + margin: EdgeInsets.only(top: 0.h, right: 4.w), child: quickText(type == 1 ? '作业' : '考试', color: Colors.white, size: 10.sp), ), Expanded(