Compare commits

..

2 Commits

Author SHA1 Message Date
machuanyu cec4aec9d5 Merge branch 'new_main' into mcy_new 2024-06-24 17:38:22 +08:00
1147192855@qq.com 952e181e45 no message 2024-06-24 17:27:33 +08:00
2 changed files with 76 additions and 62 deletions

View File

@ -34,39 +34,33 @@ class AnswerHandwriting extends Dialog {
final int? questionNo; final int? questionNo;
final Function closeCall; final Function closeCall;
AnswerHandwriting( AnswerHandwriting(
{super.key, required this.homeworkId, required this.studentId, required this.closeCall, this.templateId, this.pageNum, this.questionNo}) { {super.key, required this.homeworkId, required this.studentId, required this.closeCall, this.templateId, this.pageNum, this.questionNo});
Get.find<HandwritingLogic>().params.value = OriginalManuscriptHandwritingParams(
homeworkId: homeworkId,
studentId: studentId,
templateId: templateId,
pageNum: pageNum,
questionNo: questionNo,
);
}
final _handwritingLogic = Get.find<HandwritingLogic>(); final _handwritingLogic = Get.find<HandwritingLogic>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var boxHeight = ScreenUtil().screenHeight / 1.168; // return OrientationBuilder(builder: (BuildContext context, Orientation orientation) {
var boxWidth = ScreenUtil().screenWidth - (ScreenUtil().scaleWidth < 1.5 ? 40.r : 40.r); // var boxHeight = ScreenUtil().screenHeight / 1.168; //
var boxWidth = ScreenUtil().screenWidth - (ScreenUtil().scaleWidth < 1.5 ? 40.r : 40.r); //
return Center( return Center(
child: Container( child: Container(
height: boxHeight, height: boxHeight,
width: boxWidth, width: boxWidth,
alignment: Alignment.center, alignment: Alignment.center,
child: AnswerHandwritingMainBox( child: AnswerHandwritingMainBox(
handwritingLogic: _handwritingLogic, handwritingLogic: _handwritingLogic,
boxHeight: boxHeight, boxHeight: boxHeight,
boxWidth: boxWidth, boxWidth: boxWidth,
homeworkId: homeworkId, homeworkId: homeworkId,
templateId: templateId, templateId: templateId,
studentId: studentId, studentId: studentId,
pageNum: pageNum, pageNum: pageNum,
questionNo: questionNo, questionNo: questionNo,
closeCall: closeCall, closeCall: closeCall,
),
), ),
), );
); });
} }
} }
@ -78,26 +72,29 @@ Future<void> showAnswerHandwriting(
int? pageNum, int? pageNum,
int? questionNo, int? questionNo,
}) async { }) async {
try { backCall() {
backCall() { Navigator.of(context).pop();
Navigator.of(context).pop();
}
Get.put(HandwritingLogic(backCall));
await showDialog(
context: context,
builder: (BuildContext context) => AnswerHandwriting(
homeworkId: homeworkId,
templateId: templateId,
studentId: studentId,
pageNum: pageNum,
questionNo: questionNo,
closeCall: backCall,
),
);
} finally {
Get.delete<HandwritingLogic>();
} }
Get.put(HandwritingLogic(backCall));
Get.find<HandwritingLogic>().params.value = OriginalManuscriptHandwritingParams(
homeworkId: homeworkId,
studentId: studentId,
templateId: templateId,
pageNum: pageNum,
questionNo: questionNo,
);
await showDialog(
context: context,
builder: (BuildContext context) => AnswerHandwriting(
homeworkId: homeworkId,
templateId: templateId,
studentId: studentId,
pageNum: pageNum,
questionNo: questionNo,
closeCall: backCall,
),
).then((e) => Get.delete<HandwritingLogic>());
} }
// //
@ -364,7 +361,12 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
_packagedHandwritingDataAll = []; _packagedHandwritingDataAll = [];
} }
_vnPrimaryHandWritings.value = [..._packagedHandwritingDataAll]; // // _vnPrimaryHandWritings.is
try {
_vnPrimaryHandWritings.value = [..._packagedHandwritingDataAll]; //
} catch (e) {
_vnPrimaryHandWritings = ValueNotifier<List<GestureHandwritingRecording>>(_packagedHandwritingDataAll);
}
// eventFire(model: JobHandwritingPlaybarBus); // eventFire(model: JobHandwritingPlaybarBus);
}); });
showManuscriptStream = handwritingLogic.toolbar.showManuscript.listen((e) { showManuscriptStream = handwritingLogic.toolbar.showManuscript.listen((e) {
@ -379,7 +381,13 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
} }
}); });
executionDataStream = handwritingLogic.toolbar.executionData.listen((e) => _vnHandWritings.value = e); executionDataStream = handwritingLogic.toolbar.executionData.listen((e) {
try {
_vnHandWritings.value = e;
} catch (e1) {
_vnHandWritings = ValueNotifier<List<GestureHandwritingRecording>>(e);
}
});
eventOn(callback: (e) { eventOn(callback: (e) {
switch (e.runtimeType) { switch (e.runtimeType) {
@ -421,6 +429,8 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
@override @override
void dispose() { void dispose() {
imageStream?.removeListener(theImageStreamListener); imageStream?.removeListener(theImageStreamListener);
_vnHandWritings.dispose();
_vnPrimaryHandWritings.dispose();
showManuscriptStream.cancel(); showManuscriptStream.cancel();
executionDataStream.cancel(); executionDataStream.cancel();
eventCancel(); eventCancel();
@ -537,7 +547,8 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
imageUrl: paperPicture, imageUrl: paperPicture,
(context, imageProvider) { (context, imageProvider) {
Image imageWidget = Image(image: imageProvider, fit: BoxFit.contain); Image imageWidget = Image(image: imageProvider, fit: BoxFit.contain);
if (handwritingLogic.imagInfoModel.value == null) { var imagInfoModel = handwritingLogic.imagInfoModel.value;
if (imagInfoModel == null || imagInfoModel.boxWidth != widget.boxWidth) {
imageStream?.removeListener(theImageStreamListener); imageStream?.removeListener(theImageStreamListener);
imageStream = imageWidget.image.resolve(const ImageConfiguration()); imageStream = imageWidget.image.resolve(const ImageConfiguration());
imageStream?.addListener(theImageStreamListener); imageStream?.addListener(theImageStreamListener);
@ -873,7 +884,6 @@ class StudentManuscriptBtn extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() { return Obx(() {
print('显示原噶:${handwritingLogic.toolbar.showManuscript.value}');
return InkWell( return InkWell(
onTap: () => easyThrottle('job_handwriting_udent_manuscript', () { onTap: () => easyThrottle('job_handwriting_udent_manuscript', () {
var showManuscript = handwritingLogic.toolbar.showManuscript.value; var showManuscript = handwritingLogic.toolbar.showManuscript.value;

View File

@ -1,6 +1,7 @@
// //
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:making_school_asignment_app/common/config/request_config.dart'; import 'package:making_school_asignment_app/common/config/request_config.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_test_questions_image_info.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_test_questions_image_info.dart';
@ -33,6 +34,7 @@ class HandwritingLogic extends GetxController with RequestToolMixin {
ever(params, (callback) => getData()); ever(params, (callback) => getData());
ever(imagInfoModel, (callback) { ever(imagInfoModel, (callback) {
// //
toolbar.initialization.value = false;
handwritingInfo.value = getHandwritingDetail(resultData.value); handwritingInfo.value = getHandwritingDetail(resultData.value);
getCalculatedSize(); getCalculatedSize();
}); });
@ -67,24 +69,25 @@ class HandwritingLogic extends GetxController with RequestToolMixin {
double scaleRatio = imagInfoModel.value!.scaleRatio; double scaleRatio = imagInfoModel.value!.scaleRatio;
if (mapData.isNotEmpty) { if (mapData.isNotEmpty) {
List<int> keys = mapData.keys.toList(); List<int> keys = mapData.keys.toList();
print('重新计算:${scaleRatio}');
List<List<GestureHandwritingRecording>> _packagedHandwritingDatas = []; List<List<GestureHandwritingRecording>> _packagedHandwritingDatas = [];
List<GestureHandwritingRecording> _packagedHandwritingDataAll = []; List<GestureHandwritingRecording> _packagedHandwritingDataAll = [];
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
List<GestureHandwritingRecording> newTrajectoryData = mapData[keys[i]]!.map((e) { List<GestureHandwritingRecording> newTrajectoryData = mapData[keys[i]]!.map((e) {
double theX = e.x; // double theX = e.x;
double theY = e.y; // double theY = e.y;
if (!e.initialization) { // if (!e.initialization) {
// // //
e.toInitialization(scaleRatio); // e.toInitialization(scaleRatio);
theX = e.x; // theX = e.x;
theY = e.y; // theY = e.y;
} // }
return GestureHandwritingRecording( return GestureHandwritingRecording(
data: Offset(theX, theY), stroke: e.stroke,
data: Offset(e.x * scaleRatio, e.y * scaleRatio),
// data: Offset(theX, theY),
usageTime: e.time.toInt(), usageTime: e.time.toInt(),
intervalTime: e.intervalTime, intervalTime: e.intervalTime,
stroke: e.stroke,
); );
}).toList(); }).toList();
@ -101,6 +104,7 @@ class HandwritingLogic extends GetxController with RequestToolMixin {
} }
} }
//
HandwritingInfo? getHandwritingDetail(JobHandwriting? theData) { HandwritingInfo? getHandwritingDetail(JobHandwriting? theData) {
if (theData == null) return null; if (theData == null) return null;
// //