diff --git a/marking_app/lib/components/PictureOverview.dart b/marking_app/lib/components/PictureOverview.dart index 545f4c5..447df53 100644 --- a/marking_app/lib/components/PictureOverview.dart +++ b/marking_app/lib/components/PictureOverview.dart @@ -165,8 +165,7 @@ class PictureOverviewState extends ConsumerState with CommonMix crypto.Digest fileMd5 = crypto.md5.convert(await temFile!.readAsBytes()); RestClient _client = await getClient(); - BaseStructureResult resUploadConfig = - await _client.getUploadFile(UploadFileInterfaceConfigParams( + BaseStructureResult resUploadConfig = await _client.getUploadFile(UploadFileInterfaceConfigParams( fileName: '1.png', fileMd5: fileMd5.toString(), contentLength: temFile!.lengthSync(), @@ -179,8 +178,7 @@ class PictureOverviewState extends ConsumerState with CommonMix if (resUploadConfig.data!.uploadUri == null) { return FileResult(myObject: '', success: true, url: resUploadConfig.data!.downloadUri); } - FileResult? resFile = - await ref.read(uploadFileProvider.notifier).getUploadFileConfig(resUploadConfig.data!, temFile!); + FileResult? resFile = await ref.read(uploadFileProvider.notifier).getUploadFileConfig(resUploadConfig.data!, temFile!); // FileResult? resFile = await ref // .read(uploadFileProvider.notifier) // .uploadFile(temFile!.path, widget.imageItems[currentIndex], ref.read(userProvider).id.toString()); @@ -230,7 +228,6 @@ class PictureOverviewState extends ConsumerState with CommonMix @override Widget build(BuildContext context) { - DoMarkingKeyboardModel _model = ref.watch(markingKeyboardProvider); return Container( width: double.infinity, height: double.infinity, @@ -259,8 +256,7 @@ class PictureOverviewState extends ConsumerState with CommonMix }, imageBuilder: (context, imageProvider) { Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth); - if (imagInfoModel == null || - (imagInfoModel?.boxHeight != containerHeight || imagInfoModel?.boxWidth != containerWidth)) { + if (imagInfoModel == null || (imagInfoModel?.boxHeight != containerHeight || imagInfoModel?.boxWidth != containerWidth)) { if (_imageStreamListener != null) _imageStream?.removeListener(_imageStreamListener!); _imageStreamListener = ImageStreamListener((ImageInfo info, bool _) { imagInfoModel = TestQuestionsImageInfo( @@ -303,24 +299,25 @@ class PictureOverviewState extends ConsumerState with CommonMix // 试卷绘制 class ExamPaperDrawing extends StatefulHookConsumerWidget { - String imgUrl; + // String imgUrl; bool homework; BoxDecoration? decoration; AnnotationGraffitiSwitch graffitiSwitch; List? points; List? pointsPureData; ValueNotifier> imageLoaded; - + Widget child; GlobalKey globalKey; // Function(String) imageCall; ExamPaperDrawing({ - required this.imgUrl, + // required this.imgUrl, required this.homework, required this.points, required this.pointsPureData, required this.graffitiSwitch, required this.globalKey, required this.imageLoaded, + required this.child, this.decoration, Key? key, }) : super(key: key); @@ -329,54 +326,17 @@ class ExamPaperDrawing extends StatefulHookConsumerWidget { _ExamPaperDrawingState createState() => _ExamPaperDrawingState(); } -class _ExamPaperDrawingState extends ConsumerState - with EventBusMixin { - late Future _future; // 考试试卷 - +class _ExamPaperDrawingState extends ConsumerState with EventBusMixin { // 用于记录手指位置的变量 late List points; late List pointsPureData; // 用于记录绘图结果的变量 - bool _isEraserPressed = false; // 橡皮擦按下 - Offset? _eraserPosition; // 按下位置 - Offset? globalPosition = null; // 是否正在绘制 - - Future loadImage(String url) async { - try { - Map map = widget.imageLoaded.value; - ui.Image? image = map[url]; - if (image != null) { - return image; - } - final httpClient = HttpClient(); - final request = await httpClient.getUrl(Uri.parse(url)); - final response = await request.close(); - final bytes = await consolidateHttpClientResponseBytes(response); - final codec = await ui.instantiateImageCodec(bytes); - final frame = await codec.getNextFrame(); - ui.Image theImage = frame.image; - map[url] = theImage; - return theImage; - } catch (e) { - print('请求图片报错:${e.toString()}'); - } - return null; - } - - // void _onPointerDown(DragDownDetails details) { - // if (widget.graffitiSwitch.openEraser) { - // _eraserPosition = (context.findRenderObject() as RenderBox).globalToLocal(details.globalPosition); - // _isEraserPressed = true; - // toUpState(setState, ()=>{}, mounted); - // } - // } + Offset? globalPosition; // 是否正在绘制 @override void initState() { points = widget.points ?? []; pointsPureData = widget.pointsPureData ?? []; - print('图片地址:${widget.imgUrl}'); - _future = loadImage(widget.imgUrl); // 事件总线监听 eventOn(callback: (BottomAnnotationSwitchCleanall item) { if (item.previousStep) { @@ -434,190 +394,79 @@ class _ExamPaperDrawingState extends ConsumerState @override Widget build(BuildContext context) { - return MyFutureBuilder.buildFutureBuilderOfSingleInstance( - context, - _future, - (ui.Image? theImage) { - if (theImage == null) return const Center(child: Text('图片加载错误')); + return Listener( + behavior: HitTestBehavior.opaque, + onPointerMove: (PointerMoveEvent details) { + if (globalPosition != null) { + // 预防双指同时作用于屏幕 + double dx = globalPosition!.dx; + double dy = globalPosition!.dy; - return LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - final double containerWidth = constraints.maxWidth; // 展示区域总宽度 - final double containerHeight = constraints.maxHeight; // 展示区域总宽度 - - final double imageWidth = theImage.width.toDouble(); // 图片原始宽度 - final double imageHeight = theImage.height.toDouble(); // 图片原始高度 - final double widthRatio = containerWidth / imageWidth; // - final double heightRatio = containerHeight / imageHeight; - final double scale = widthRatio > heightRatio ? heightRatio : widthRatio; - final double destWidth = imageWidth * scale; - final double destHeight = imageHeight * scale; - - final bool homework = widget.homework; - - return GestureDetector( - behavior: HitTestBehavior.opaque, - onPanUpdate: (DragUpdateDetails details) { - if (globalPosition != null) { - // 预防双指同时作用于屏幕 - double dx = globalPosition!.dx; - double dy = globalPosition!.dy; - - double dxNew = details.globalPosition.dx; - double dyNew = details.globalPosition.dy; - if ((dxNew - dx).abs() > 22 || (dyNew - dy).abs() > 22) { - return; - } - } - globalPosition = details.globalPosition; - try { - if (widget.graffitiSwitch.openBrush || widget.graffitiSwitch.openEraser) { - RenderBox renderBox = context.findRenderObject() as RenderBox; - Offset localPosition = renderBox.globalToLocal(details.globalPosition); - pointsPureData = List.from(pointsPureData)..add(localPosition); - points = List.from(points) - ..add(GestureRecording(eraser: widget.graffitiSwitch.openEraser, data: localPosition)); - _eraserPosition = localPosition; - _isEraserPressed = true; - setState(() {}); - } - } catch (e) { - toPrint(val: '进入报错'); - } - }, - onPanEnd: (DragEndDetails details) { - print('离开.............'); - globalPosition = null; - if (widget.graffitiSwitch.openBrush || widget.graffitiSwitch.openEraser) { - pointsPureData.add(null); // 增加空点以分隔不同的线段 - points.add(GestureRecording(eraser: widget.graffitiSwitch.openEraser)); - _isEraserPressed = false; - _eraserPosition = null; - } - }, - child: RepaintBoundary( - key: widget.globalKey, - child: CustomPaint( - // isComplex: true, - // willChange: true, - painter: DrawingPainter( - image: theImage, - points: points, - isErasing: widget.graffitiSwitch.openEraser, - destWidth: destWidth, - destHeight: destHeight, - imageWidth: imageWidth, - imageHeight: imageHeight, - homework: homework, - containerWidth: containerWidth, - containerHeight: containerHeight, - ), - // size: Size(homework ? containerWidth : destWidth, homework ? containerHeight : destHeight), - size: Size(containerWidth, containerHeight), - ), - ), - ); - }, - ); + double dxNew = details.localPosition.dx; + double dyNew = details.localPosition.dy; + if ((dxNew - dx).abs() > 22 || (dyNew - dy).abs() > 22) { + return; + } + } + globalPosition = details.localPosition; + try { + // if (widget.graffitiSwitch.openBrush || widget.graffitiSwitch.openEraser) { + RenderBox renderBox = context.findRenderObject() as RenderBox; + Offset localPosition = renderBox.globalToLocal(details.localPosition); + pointsPureData = List.from(pointsPureData)..add(localPosition); + points = List.from(points)..add(GestureRecording(eraser: widget.graffitiSwitch.openEraser, data: localPosition)); + setState(() {}); + // } + } catch (e) { + toPrint(val: '进入报错'); + } }, + onPointerUp: (PointerUpEvent details) { + print('离开.............'); + globalPosition = null; + if (widget.graffitiSwitch.openBrush || widget.graffitiSwitch.openEraser) { + pointsPureData.add(null); // 增加空点以分隔不同的线段 + points.add(GestureRecording(eraser: widget.graffitiSwitch.openEraser)); + } + }, + child: RepaintBoundary( + key: widget.globalKey, + child: CustomPaint( + foregroundPainter: DrawingPainter(points: points), + child: widget.child, + ), + ), ); } } class DrawingPainter extends CustomPainter { final List points; - final bool isErasing; - final ui.Image image; - final bool homework; - final double containerWidth; - final double containerHeight; - double destWidth; - double destHeight; - final double imageWidth; - final double imageHeight; + DrawingPainter({required this.points}) : super(); - // final Rect destRect; - // final Rect srcRect; - final bool openErasing; - DrawingPainter({ - required this.homework, - required this.points, - required this.isErasing, - required this.image, - required this.destWidth, - required this.destHeight, - required this.containerWidth, - required this.containerHeight, - required this.imageWidth, - required this.imageHeight, - }) : - // destRect = Rect.fromLTWH(0, 0,destWidth,destHeight), - // srcRect = Rect.fromLTWH(0, 0, imageWidth, imageHeight), - openErasing = points.isNotEmpty && isErasing, - super(); - - Paint paintBrush = Paint() + final Paint paintBrush = Paint() ..color = Colors.red ..strokeCap = StrokeCap.round - ..strokeWidth = 1.5; - - Paint eraser = Paint() - ..blendMode = BlendMode.clear - ..color = Colors.transparent - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.round - ..strokeWidth = 100; - - final emptyPaint = Paint(); - final emptyPaintWithWidth = Paint()..strokeWidth = 60.0; + ..strokeWidth = 1.5.r; @override void paint(Canvas canvas, Size size) { - double offsetX = (size.width - destWidth) / 2; - double offsetY = (size.height - destHeight) / 2; - if (destWidth < (size.width / 2)) { - destWidth = size.width / 2; - offsetX = (size.width - destWidth) / 2; - } - - // final rect = Rect.fromCenter(center: center, width: destWidth, height: destHeight); - Rect srcRect = Rect.fromLTRB(0, 0, image.width.toDouble(), image.height.toDouble()); - // Rect destRect = Rect.fromLTRB(offsetX, offsetY, containerWidth, containerHeight); - Rect destRect = Offset(offsetX, offsetY) & Size(destWidth, destHeight); - - canvas.drawImageRect(image, srcRect, destRect, emptyPaint); - - // canvas.drawImage(image, Offset.zero, emptyPaint); - if (points.isNotEmpty) { - // canvas.saveLayer(destRect, emptyPaintWithWidth); // 只绘制图片大小区域 - canvas.saveLayer(Rect.largest, emptyPaintWithWidth); // 整个视图区域 - - canvas.drawColor(Colors.transparent, BlendMode.clear); - } - - for (int i = 0; i < points.length - 1; i++) { + print('数据.....................'); + for (int i = 0; i < points.length; i++) { GestureRecording item = points[i]; GestureRecording nextItem = points[i + 1]; Offset? offsetData = item.data; Offset? nextOffsetData = nextItem.data; if (offsetData != null && nextOffsetData != null) { - canvas.drawLine(offsetData, nextOffsetData, !item.eraser ? paintBrush : eraser); + canvas.drawLine(offsetData, nextOffsetData, paintBrush); } } - - // 恢复画布状态. - if (points.isNotEmpty) canvas.restore(); } - // @override - // bool shouldRepaint(DrawingPainter oldDelegate) { - // List thePoints = oldDelegate.points; - // // var flag = oldDelegate.points != points || oldDelegate.isErasing != isErasing; - // return thePoints != points; - // } - @override - bool shouldRepaint(DrawingPainter oldDelegate) => true; + bool shouldRepaint(DrawingPainter oldDelegate) { + return oldDelegate.points.length != points.length || oldDelegate.points != points; + } } /** @@ -802,9 +651,7 @@ Widget $localAndNetworkSwitch( useValueChanged(drawFlag, (oldValue, oldResult) { if (!drawFlag) { // 关闭的时候创建临时图片文件在设备 - _useSwitch - .createTempFile(context, theglobalKey: theglobalKey, examGlobalKey: examGlobalKey) - .then((File? theFile) { + _useSwitch.createTempFile(context, theglobalKey: theglobalKey, examGlobalKey: examGlobalKey).then((File? theFile) { if (theFile == null) { // TODO 代表保存失败的逻辑 // 当前情况:_useSwich.showZoomImg.value 没有设置为true还是展示的原来的绘图组件ExamPaperDrawing @@ -832,50 +679,23 @@ Widget $localAndNetworkSwitch( }, []); print('是否更新视图.... ${_useZoomHistory.initPosition.value}'); - return _useSwitch.showZoomImg.value - ? - /** - Scrollbar( - // thumbVisibility: true, - thumbVisibility: true, - controller: _useScrollController, - child: SingleChildScrollView( - physics: AlwaysScrollableScrollPhysics(), - padding: EdgeInsets.zero, - scrollDirection: Axis.vertical, // 设置垂直滚动 - child: Transform.scale( - scale: 0.4, - alignment: Alignment.topCenter, - child: $MyCachedNetworkImage( - imageUrl: imageUrl, - tempFile: _useSwitch.temFile.value, - width: containerWidth, - height: containerHeight, - ), - ), - ), - )*/ - - /** */ - $MyCachedNetworkImage( - imageUrl: imageUrl, - tempFile: _useSwitch.temFile.value, - width: containerWidth, - height: containerHeight, - imageBuilder: imageBuilder, - ) - : ExamPaperDrawing( - imgUrl: imageUrl, - graffitiSwitch: graffitiSwitch, - points: _useSwitch.points.value, - pointsPureData: _useSwitch.pointsPureData.value, - decoration: const BoxDecoration(color: const Color.fromRGBO(249, 250, 254, 1)), - globalKey: theglobalKey, - key: examGlobalKey, - imageLoaded: _useSwitch.imageLoaded, - homework: homework, - // imageCall: (String str) => widget.imageCall(str, currentIndex), - ); + return ExamPaperDrawing( + graffitiSwitch: graffitiSwitch, + points: _useSwitch.points.value, + pointsPureData: _useSwitch.pointsPureData.value, + decoration: const BoxDecoration(color: const Color.fromRGBO(249, 250, 254, 1)), + globalKey: theglobalKey, + key: examGlobalKey, + imageLoaded: _useSwitch.imageLoaded, + homework: homework, + child: $MyCachedNetworkImage( + imageUrl: imageUrl, + tempFile: _useSwitch.temFile.value, + width: containerWidth, + height: containerHeight, + imageBuilder: imageBuilder, + ), + ); } class UseLocalAndNetworkSwitch { diff --git a/marking_app/lib/pages/marking/do_papers.dart b/marking_app/lib/pages/marking/do_papers.dart index 366d583..335bdf4 100644 --- a/marking_app/lib/pages/marking/do_papers.dart +++ b/marking_app/lib/pages/marking/do_papers.dart @@ -44,6 +44,7 @@ import 'package:marking_app/common/model/marking/submit_exam_small_params.dart'; import 'package:marking_app/common/model/marking/switch_keyboard_to_reload_images.dart'; import 'package:marking_app/components/PictureOverview.dart'; +import 'package:marking_app/components/marking/bottom_annotation_switch.dart'; import 'package:marking_app/components/marking/marking_keyboard_switch.dart'; import 'package:marking_app/components/marking/marking_question_type_drawer.dart'; import 'package:marking_app/components/marking/marking_seting.dart'; @@ -174,9 +175,8 @@ class _MarkingPapersState extends ConsumerState screenDirectionSwitch(state.screenDirection); } else { ScreenDirection nowScreenDirection = state.screenDirection; // 当前屏幕方向 - ScreenDirection theOrientation = MediaQuery.of(context).orientation == Orientation.landscape - ? ScreenDirection.HORIZONTAL_SCREEN - : ScreenDirection.VERTICAL_SCREEN; + ScreenDirection theOrientation = + MediaQuery.of(context).orientation == Orientation.landscape ? ScreenDirection.HORIZONTAL_SCREEN : ScreenDirection.VERTICAL_SCREEN; if (theOrientation != nowScreenDirection) { screenDirectionSwitch(nowScreenDirection); } @@ -243,8 +243,7 @@ class _MarkingPapersState extends ConsumerState bool isHorizontal = direction == ScreenDirection.HORIZONTAL_SCREEN; Future.delayed(Duration.zero, () { - SystemChrome.setPreferredOrientations( - [isHorizontal ? DeviceOrientation.landscapeLeft : DeviceOrientation.portraitUp]); + SystemChrome.setPreferredOrientations([isHorizontal ? DeviceOrientation.landscapeLeft : DeviceOrientation.portraitUp]); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); setTimeOut(1000, () => toUpState(setState, () => annotationsFlag = true, mounted)); }); @@ -260,8 +259,7 @@ class _MarkingPapersState extends ConsumerState return null; } currentQuestion!.papersUrlStr = paperUrls; - currentQuestion!.papersUrl = - paperUrls.asMap().keys.map((e) => GalleryExampleItemModel(id: e.toString(), resource: paperUrls[e])).toList(); + currentQuestion!.papersUrl = paperUrls.asMap().keys.map((e) => GalleryExampleItemModel(id: e.toString(), resource: paperUrls[e])).toList(); return currentQuestion!.papersUrl; } @@ -426,8 +424,7 @@ class _MarkingPapersState extends ConsumerState Future submitTestQuestions(BuildContext theContext, MarkingTextQuestion data) async { Timer timer = Timer(const Duration(milliseconds: 300), () => ToastUtils.showLoading()); try { - if (widget.markingtype == MarkingListType.NORMAL && currentQuestion!.isException) - return ToastUtils.showError('异常题,不允许再评分'); + if (widget.markingtype == MarkingListType.NORMAL && currentQuestion!.isException) return ToastUtils.showError('异常题,不允许再评分'); if (currentQuestion == null) { return ToastUtils.showError('提交失败,请退出重试。'); @@ -762,8 +759,7 @@ class _MarkingPapersState extends ConsumerState bool isReview = widget.isReview; if (theId != null && _currentTab != null && theQuestionNum != _currentTab!.questionNum) { - MarkingTextQuestionTab? _foundCrrentTab = - _currentTabs.firstWhereOrNull((element) => element.questionNum == theQuestionNum); + MarkingTextQuestionTab? _foundCrrentTab = _currentTabs.firstWhereOrNull((element) => element.questionNum == theQuestionNum); if (_foundCrrentTab != null) { _currentTab = _foundCrrentTab; } @@ -791,11 +787,7 @@ class _MarkingPapersState extends ConsumerState // 同步小题得分 score:分值 continueScoring:是否可以持续打分 hasSubtopic:是否有小题; cleanScore:是否是清空 Future synchroScore( - {required double score, - required bool continueScoring, - required bool hasSubtopic, - bool allWrong = false, - bool cleanScore = false}) async { + {required double score, required bool continueScoring, required bool hasSubtopic, bool allWrong = false, bool cleanScore = false}) async { if (currentQuestion == null) return; if (cleanScore) { @@ -879,8 +871,8 @@ class _MarkingPapersState extends ConsumerState res.data = res.data!.where((element) => !(element.isFinished && element.finishCount == 0)).toList(); // 方便更新tags key是题号 - Map _currentTabsMap = Map.fromIterable(_currentTabs, - key: (item) => item.questionNum, value: (item) => item); + Map _currentTabsMap = + Map.fromIterable(_currentTabs, key: (item) => item.questionNum, value: (item) => item); MarkingTextQuestionTab? theCurrentTab; String currentTagQueNum = _currentTab!.questionNum; res.data!.forEach((e) { @@ -918,31 +910,25 @@ class _MarkingPapersState extends ConsumerState if (!widget.exceptional && _currentTabs.length <= 0 && _currentTab == null) { // tag为空,请求tag数据并且为对应的tag赋值上分值步长 RestClient client = await getClient(); - List res = await Future.wait([ - client.getTestQuestionsOfTab(widget.markingUserId), - client.getTestQuestionsOfTabStepSize(widget.examSubjectId) - ]); - BaseStructureResult> resultTab = - res[0] as BaseStructureResult>; - BaseStructureResult> resultTabStep = - res[1] as BaseStructureResult>; + List res = + await Future.wait([client.getTestQuestionsOfTab(widget.markingUserId), client.getTestQuestionsOfTabStepSize(widget.examSubjectId)]); + BaseStructureResult> resultTab = res[0] as BaseStructureResult>; + BaseStructureResult> resultTabStep = res[1] as BaseStructureResult>; if ((!resultTab.success || (resultTab.data?.isEmpty ?? true)) || (!resultTabStep.success || (resultTabStep.data?.isEmpty ?? true)) || (resultTabStep.data!.length < resultTab.data!.length)) { throw Error(); } - Map tabStepMap = Map.fromIterable(resultTabStep.data!, - key: (item) => item.questionNum, value: (item) => item.scoreInterval); + Map tabStepMap = + Map.fromIterable(resultTabStep.data!, key: (item) => item.questionNum, value: (item) => item.scoreInterval); resultTab.data = resultTab.data!.where((element) => !(element.isFinished && element.finishCount == 0)).toList(); resultTab.data!.forEach((element) => element.setStepSize(tabStepMap[element.questionNum] ?? 1.0)); _currentTabs = resultTab.data!; // 获取当前tabs批次下第一个没有完成数据 - currentTab = resultTab.data!.firstWhere( - tabQuestionNum == null ? firstWhereCall : (e) => e.questionNum == tabQuestionNum, - orElse: () => - MarkingTextQuestionTab(isFinished: false, questionNum: '0.0', total: 0, finishCount: 0, isExcess: false)); + currentTab = resultTab.data!.firstWhere(tabQuestionNum == null ? firstWhereCall : (e) => e.questionNum == tabQuestionNum, + orElse: () => MarkingTextQuestionTab(isFinished: false, questionNum: '0.0', total: 0, finishCount: 0, isExcess: false)); if (currentTab.questionNum == '0.0') { // 全部都批改完成了,默认tab设置为第一个 @@ -1025,8 +1011,7 @@ class _MarkingPapersState extends ConsumerState if (hasNext) { // 查找下一个tab return _currentTabs.firstWhere(firstWhereCall, - orElse: () => MarkingTextQuestionTab( - questionNum: '0.0', total: 0, finishCount: 0, isExcess: false, isFinished: false)); + orElse: () => MarkingTextQuestionTab(questionNum: '0.0', total: 0, finishCount: 0, isExcess: false, isFinished: false)); } if (tabQuestionNum != null) { @@ -1036,8 +1021,7 @@ class _MarkingPapersState extends ConsumerState if (resetting) { // 是否进行重置,继续阅卷 MarkingTextQuestionTab theMarking = _currentTabs.firstWhere(firstWhereCall, - orElse: () => MarkingTextQuestionTab( - questionNum: '0.0', total: 0, finishCount: 0, isExcess: false, isFinished: false)); + orElse: () => MarkingTextQuestionTab(questionNum: '0.0', total: 0, finishCount: 0, isExcess: false, isFinished: false)); if (theMarking.questionNum != '0.0') { currentTab = theMarking; } @@ -1143,8 +1127,8 @@ class _MarkingPapersState extends ConsumerState currentQuestion = result.data; if (temTab != null) { result.data!.scoreInterval = temTab.scoreInterval ?? 1; - MarkingZoom? markingZoom = await UseZoomImageHistoryUtils.getZoomImageInfo( - widget.markingUserId.toString() + '-' + (currentQuestion?.questionNum.toString() ?? '')); + MarkingZoom? markingZoom = + await UseZoomImageHistoryUtils.getZoomImageInfo(widget.markingUserId.toString() + '-' + (currentQuestion?.questionNum.toString() ?? '')); if (markingZoom != null) { imageScale = double.parse(markingZoom.scale.toStringAsFixed(2)); imagePosition = Offset( @@ -1232,8 +1216,7 @@ class _MarkingPapersState extends ConsumerState if (firstComeIn) setTimeOut(2000, () => firstComeIn = false); if (ref.read(markingSubtopicSwitchingProvider.notifier).state != activeQuestIndex) { // 重置小题题号位置下标 - Future.delayed( - Duration.zero, () => ref.read(markingSubtopicSwitchingProvider.notifier).setVal(activeQuestIndex)); + Future.delayed(Duration.zero, () => ref.read(markingSubtopicSwitchingProvider.notifier).setVal(activeQuestIndex)); } if (currentQuestion != null && widget.markingtype == MarkingListType.EXCEPTIONAL) { BaseStructureResult res = await client.getMarkingQuestionsErrorInfo(currentQuestion!.id); @@ -1435,8 +1418,7 @@ class _MarkingPapersState extends ConsumerState bool isNormal = !widget.exceptional; // 正常批题 bool notNextTest = data.nextId == 0; // 没有下一个试题了 // 下一题点击触发的方法 - var pressedNextTest = - notNextTest ? null : () => easyThrottle('TestQuestionSwitch', () => refresh(isNext: true)); + var pressedNextTest = notNextTest ? null : () => easyThrottle('TestQuestionSwitch', () => refresh(isNext: true)); bool notHasPreviousTest = data.prevId == 0; /** 无需根据当前位置判断 @@ -1501,8 +1483,7 @@ class _MarkingPapersState extends ConsumerState color: const Color.fromRGBO(148, 163, 182, 1), ), ), - if (_currentTab!.isExcess && - _currentTab!.finishCount > _currentTab!.total) + if (_currentTab!.isExcess && _currentTab!.finishCount > _currentTab!.total) Container( margin: EdgeInsets.only(left: 4.w), child: Row( @@ -1513,8 +1494,7 @@ class _MarkingPapersState extends ConsumerState color: const Color.fromRGBO(148, 163, 182, 1), ), quickText( - (_currentTab!.finishCount - _currentTab!.total) - .toString(), + (_currentTab!.finishCount - _currentTab!.total).toString(), size: isBroadwise ? 18.sp : 14.sp, color: Color.fromRGBO(251, 144, 84, 1), ), @@ -1540,19 +1520,16 @@ class _MarkingPapersState extends ConsumerState ), ), SizedBox(width: 8.w), - if (model.hideQuestionId && - model.screenDirection == ScreenDirection.HORIZONTAL_SCREEN) + if (model.hideQuestionId && model.screenDirection == ScreenDirection.HORIZONTAL_SCREEN) InkWell( onTap: () { - Clipboard.setData(ClipboardData(text: data.paperNum ?? '')) - .then((value) { + Clipboard.setData(ClipboardData(text: data.paperNum ?? '')).then((value) { ToastUtils.showSuccess('试卷编号已复制'); }); }, child: Row( children: [ - quickText('试卷编号: ', - size: 16.sp, color: const Color.fromRGBO(148, 163, 182, 1)), + quickText('试卷编号: ', size: 16.sp, color: const Color.fromRGBO(148, 163, 182, 1)), quickText( data.paperNum ?? '', size: 16.sp, @@ -1585,8 +1562,7 @@ class _MarkingPapersState extends ConsumerState color: const Color.fromRGBO(4, 201, 208, 1), ), ), - if (isBroadwise && widget.markingtype == MarkingListType.EXCEPTIONAL || - data.isException) + if (isBroadwise && widget.markingtype == MarkingListType.EXCEPTIONAL || data.isException) Container( padding: EdgeInsets.symmetric(horizontal: 2.w, vertical: 2.h), color: const Color.fromRGBO(245, 108, 108, 0.236), @@ -1630,18 +1606,14 @@ class _MarkingPapersState extends ConsumerState size: isBroadwise ? 15.sp : 12.sp, ), SizedBox(width: 1.w), - quickText('继续阅卷', - color: const Color.fromRGBO(80, 87, 103, 1), - size: isBroadwise ? 15.sp : 12.sp), + quickText('继续阅卷', color: const Color.fromRGBO(80, 87, 103, 1), size: isBroadwise ? 15.sp : 12.sp), ], ), ), SizedBox(width: 10.w), InkWell( onTap: () { - ref - .read(ratingProgressProvider.notifier) - .setState(EndDrawerViewEnum.REVIEW_RECORD); + ref.read(ratingProgressProvider.notifier).setState(EndDrawerViewEnum.REVIEW_RECORD); scaffoldKey.currentState?.openEndDrawer(); }, child: Row( @@ -1652,9 +1624,7 @@ class _MarkingPapersState extends ConsumerState size: isBroadwise ? 15.sp : 12.sp, ), SizedBox(width: 1.w), - quickText('阅卷记录', - color: const Color.fromRGBO(80, 87, 103, 1), - size: isBroadwise ? 15.sp : 12.sp), + quickText('阅卷记录', color: const Color.fromRGBO(80, 87, 103, 1), size: isBroadwise ? 15.sp : 12.sp), ], ), ), @@ -1666,9 +1636,7 @@ class _MarkingPapersState extends ConsumerState ), InkWell( onTap: () { - ref - .read(ratingProgressProvider.notifier) - .setState(EndDrawerViewEnum.RATING_PROGRESS); + ref.read(ratingProgressProvider.notifier).setState(EndDrawerViewEnum.RATING_PROGRESS); scaffoldKey.currentState?.openEndDrawer(); }, child: Row( @@ -1679,9 +1647,7 @@ class _MarkingPapersState extends ConsumerState size: isBroadwise ? 15.sp : 12.sp, ), SizedBox(width: 1.w), - quickText('评分进度', - color: const Color.fromRGBO(80, 87, 103, 1), - size: isBroadwise ? 15.sp : 12.sp), + quickText('评分进度', color: const Color.fromRGBO(80, 87, 103, 1), size: isBroadwise ? 15.sp : 12.sp), ], ), ), @@ -1690,8 +1656,7 @@ class _MarkingPapersState extends ConsumerState InkWell( onTap: () { if (data.isException) { - return ToastUtils.getFluttertoast( - context: context, msg: '当前试题已为异常题,无需重复提交'); + return ToastUtils.getFluttertoast(context: context, msg: '当前试题已为异常题,无需重复提交'); } toUpState(setState, () => showAbnormal = true, mounted); }, @@ -1817,17 +1782,14 @@ class _MarkingPapersState extends ConsumerState return InkWell( onTap: () { double? getScore = quest.subQuestionGotScore; - ref - .read(markingSubtopicSwitchingProvider.notifier) - .setVal(index); + ref.read(markingSubtopicSwitchingProvider.notifier).setVal(index); toUpState(setState, () { activeQuestIndex = index; // TODO 这是什么 // pictureOverviewKey.currentState?.jumpToPage(activeQuestIndex); questScore = getScore?.toString() ?? ''; - hasZeroPointFive = - questScore != '' && getScore! >= quest.subQuestionScore; + hasZeroPointFive = questScore != '' && getScore! >= quest.subQuestionScore; }, mounted); }, child: Container( @@ -1848,8 +1810,7 @@ class _MarkingPapersState extends ConsumerState alignment: const FractionalOffset(0.5, 1.78), children: [ Container( - padding: EdgeInsets.symmetric( - horizontal: 4.w, vertical: 8.h), + padding: EdgeInsets.symmetric(horizontal: 4.w, vertical: 8.h), alignment: Alignment.center, decoration: BoxDecoration( color: !activeIndex @@ -1871,9 +1832,7 @@ class _MarkingPapersState extends ConsumerState maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( - color: activeIndex - ? Colors.white - : const Color.fromRGBO(80, 87, 103, 1), + color: activeIndex ? Colors.white : const Color.fromRGBO(80, 87, 103, 1), fontSize: 13.sp, fontWeight: FontWeight.w500, ), @@ -1884,22 +1843,18 @@ class _MarkingPapersState extends ConsumerState child: quickText( '(${getDoubleRemoveZero(data.subQuestionDetailList[index].subQuestionScore)})', size: 11.sp, - color: activeIndex - ? Colors.white - : const Color.fromRGBO( - 80, 87, 103, 1)), + color: + activeIndex ? Colors.white : const Color.fromRGBO(80, 87, 103, 1)), ) ], )), if (activeIndex) Icon(Icons.arrow_drop_down_outlined, - color: const Color.fromRGBO(46, 91, 255, 1), - size: 20.sp) + color: const Color.fromRGBO(46, 91, 255, 1), size: 20.sp) ], ), Container( - padding: - EdgeInsets.symmetric(horizontal: 4.w, vertical: 8.h), + padding: EdgeInsets.symmetric(horizontal: 4.w, vertical: 8.h), alignment: Alignment.center, child: Text( getDoubleRemoveZero(quest.subQuestionGotScore, '请评分'), @@ -1945,8 +1900,7 @@ class _MarkingPapersState extends ConsumerState ), child: Text( '>>', - style: - TextStyle(color: Theme.of(context).primaryColor, fontSize: 12.sp), + style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 12.sp), ), )), onHorizontalDragEnd: (detail) { @@ -1976,7 +1930,7 @@ class _MarkingPapersState extends ConsumerState imageItems: data.getImageData(), ), ), - // 批注开关 暂时注释 + // 批注开关 暂时注释 TODO // if (!showSetingFlag && // !widget.exceptional && // currentQuestion != null && @@ -1986,7 +1940,7 @@ class _MarkingPapersState extends ConsumerState // Positioned( // left: 0, // bottom: 0, - // child: BottomAnnotationSwitch(maxWidth: maxWidth - 1.5.w), + // child: BottomAnnotationSwitch(maxWidth: ScreenUtil().screenWidth - 1.5.w), // ), // 大题评分展示框 if (!hasSubtopic) @@ -2000,10 +1954,7 @@ class _MarkingPapersState extends ConsumerState color: data.isException ? Colors.red : const Color.fromRGBO(46, 91, 255, 1), child: Container( padding: EdgeInsets.symmetric( - horizontal: (data.score == null || - (getDoubleRemoveZero(data.score ?? 0)).length >= 2) - ? 4.w - : 12.w, + horizontal: (data.score == null || (getDoubleRemoveZero(data.score ?? 0)).length >= 2) ? 4.w : 12.w, vertical: 6.h), alignment: Alignment.center, child: Text( @@ -2029,15 +1980,11 @@ class _MarkingPapersState extends ConsumerState color: data.isException ? Colors.red : const Color.fromRGBO(46, 91, 255, 1), child: Container( padding: EdgeInsets.symmetric( - horizontal: (data.score == null || - (getDoubleRemoveZero(data.score ?? 0)).length >= 2) - ? 4.w - : 12.w, + horizontal: (data.score == null || (getDoubleRemoveZero(data.score ?? 0)).length >= 2) ? 4.w : 12.w, vertical: 6.h), alignment: Alignment.center, child: Text( - getDoubleRemoveZero(data.score, - '请评分,满分${getDoubleRemoveZero(currentQuestion?.totalScore)}'), + getDoubleRemoveZero(data.score, '请评分,满分${getDoubleRemoveZero(currentQuestion?.totalScore)}'), style: TextStyle( fontSize: 18.sp, color: const Color.fromRGBO(46, 91, 255, 1), @@ -2047,22 +1994,17 @@ class _MarkingPapersState extends ConsumerState ), ), // 上一题 按钮 - if (widget.markingtype != MarkingListType.EXCEPTIONAL && - !_theOldAnnotationGraffiti && - !notHasPreviousTest) + if (widget.markingtype != MarkingListType.EXCEPTIONAL && !_theOldAnnotationGraffiti && !notHasPreviousTest) Positioned( left: 3.w, top: ScreenUtil().setHeight(MediaQuery.of(context).size.height) / 2 * 0.87, child: FloatingActionButton( tooltip: '前往上一题', - backgroundColor: notHasPreviousTest - ? const Color.fromRGBO(24, 32, 32, 0.04) - : const Color.fromRGBO(24, 32, 32, 0.1), + backgroundColor: + notHasPreviousTest ? const Color.fromRGBO(24, 32, 32, 0.04) : const Color.fromRGBO(24, 32, 32, 0.1), focusColor: Theme.of(context).primaryColor, elevation: 0, - onPressed: notHasPreviousTest - ? null - : () => easyThrottle('TestQuestionSwitch', () => refresh()), + onPressed: notHasPreviousTest ? null : () => easyThrottle('TestQuestionSwitch', () => refresh()), child: const Icon(Icons.arrow_back_ios, color: Colors.white), heroTag: 'other', ), @@ -2075,9 +2017,8 @@ class _MarkingPapersState extends ConsumerState child: FloatingActionButton( elevation: 0, tooltip: '点击前往下一题', - backgroundColor: notNextTest - ? const Color.fromRGBO(24, 32, 32, 0.04) - : const Color.fromRGBO(24, 32, 32, 0.1), + backgroundColor: + notNextTest ? const Color.fromRGBO(24, 32, 32, 0.04) : const Color.fromRGBO(24, 32, 32, 0.1), foregroundColor: Colors.white, onPressed: pressedNextTest, child: const Icon(Icons.arrow_forward_ios, color: Colors.white), @@ -2169,8 +2110,7 @@ class _MarkingPapersState extends ConsumerState // 异常显示区域 $AbnormalBox( - businessHandle: (bool flag, String? reasonKey, String? otherReasons) => - initiateException(flag, reasonKey, otherReasons), + businessHandle: (bool flag, String? reasonKey, String? otherReasons) => initiateException(flag, reasonKey, otherReasons), isBroadwise: isBroadwise, showAbnormal: !showAbnormal, ), @@ -2202,8 +2142,7 @@ class _MarkingPapersState extends ConsumerState eventFireSub(model: SwitchKeyboardToReloadImages(true)); }); ref.read(annotationGraffitiSwitchProvider.notifier).setSwitch(false); - ToastUtils.showSuccess(newOpenAuxiliary ? '开启双栏打分' : '关闭双栏打分', - duration: const Duration(milliseconds: 300)); + ToastUtils.showSuccess(newOpenAuxiliary ? '开启双栏打分' : '关闭双栏打分', duration: const Duration(milliseconds: 300)); }); }, // 触发总线事件 @@ -2212,8 +2151,7 @@ class _MarkingPapersState extends ConsumerState width: isBroadwise ? 18.w : 42.w, alignment: Alignment.center, decoration: BoxDecoration( - borderRadius: - BorderRadius.only(topLeft: Radius.circular(8.w), bottomLeft: Radius.circular(8.w)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(8.w), bottomLeft: Radius.circular(8.w)), color: Theme.of(context).primaryColor, ), child: Row( @@ -2247,8 +2185,7 @@ class _MarkingPapersState extends ConsumerState tabName: _currentTab?.questionNum ?? '', tabs: _currentTabs, direction: keyboardModel?.screenDirection ?? ScreenDirection.HORIZONTAL_SCREEN, - call: (int detailId, String selectedQuesiontNum) => - refresh(theId: detailId, theQuestionNum: selectedQuesiontNum), + call: (int detailId, String selectedQuesiontNum) => refresh(theId: detailId, theQuestionNum: selectedQuesiontNum), markingUserId: widget.markingUserId, questionNum: _currentTab?.questionNum, ), @@ -2429,10 +2366,8 @@ Widget $abnormalBox( child: TextField( controller: controller, textInputAction: TextInputAction.next, - onEditingComplete: () => easyThrottle( - 'Abnormal_submission_confirmation_button', - () => _useAbnormal.submit(context, controller, - (reasonType, reason) => businessHandle(true, reasonType, reason))), + onEditingComplete: () => easyThrottle('Abnormal_submission_confirmation_button', + () => _useAbnormal.submit(context, controller, (reasonType, reason) => businessHandle(true, reasonType, reason))), maxLines: 15, keyboardType: TextInputType.multiline, decoration: InputDecoration( @@ -2452,8 +2387,7 @@ Widget $abnormalBox( mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( - onTap: () => easyThrottle( - 'Abnormal_submission_confirmation_button', () => businessHandle(false, null, null)), + onTap: () => easyThrottle('Abnormal_submission_confirmation_button', () => businessHandle(false, null, null)), child: Container( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h), margin: EdgeInsets.only(right: 16.w), @@ -2483,8 +2417,7 @@ Widget $abnormalBox( InkWell( onTap: () => easyThrottle( 'Abnormal_submission_confirmation_button', - () => _useAbnormal.submit( - context, controller, (reasonType, reason) => businessHandle(true, reasonType, reason)), + () => _useAbnormal.submit(context, controller, (reasonType, reason) => businessHandle(true, reasonType, reason)), ), // () { @@ -2582,8 +2515,7 @@ class StandardAnswerRegion extends StatelessWidget { /// 异常题提交异常信息 @hwidget -Widget $abnormalQuestionInfo( - {required bool hasSubtopic, required bool isBroadwise, required bool show, double? score, ExceptionInfo? info}) { +Widget $abnormalQuestionInfo({required bool hasSubtopic, required bool isBroadwise, required bool show, double? score, ExceptionInfo? info}) { final _useFlagAnimation = useState(true); AnimationController _useAnimationHorizontal = useAnimationController( initialValue: 300, @@ -2675,14 +2607,12 @@ Widget $abnormalQuestionInfo( Row( children: [ if ((info?.studentName.length ?? 0) > 0) - quickText('考生:${info!.studentName}', - color: const Color.fromRGBO(104, 104, 113, 1), size: 14.sp + quickText('考生:${info!.studentName}', color: const Color.fromRGBO(104, 104, 113, 1), size: 14.sp // overflow: TextOverflow.clip, ), SizedBox(width: 3.w), if ((info?.studentExamNum.length ?? 0) > 0) - quickText('考号:${info!.studentExamNum}', - color: const Color.fromRGBO(104, 104, 113, 1), size: 14.sp + quickText('考号:${info!.studentExamNum}', color: const Color.fromRGBO(104, 104, 113, 1), size: 14.sp // overflow: TextOverflow.clip, ), ], @@ -2716,8 +2646,7 @@ Widget $abnormalQuestionInfo( /// 冲裁题仲裁历史得分信息 @hwidget -Widget $arbitrationQuestionInfo( - {required bool show, required bool isBroadwise, required bool hasSubtopic, required List data}) { +Widget $arbitrationQuestionInfo({required bool show, required bool isBroadwise, required bool hasSubtopic, required List data}) { final _useFlagAnimation = useState(true); AnimationController _useAnimationHorizontal = useAnimationController( initialValue: 300,