Merge branch 'new_main' into mcy_new

This commit is contained in:
machuanyu 2024-06-24 17:38:22 +08:00
commit cec4aec9d5
2 changed files with 76 additions and 62 deletions

View File

@ -34,18 +34,11 @@ class AnswerHandwriting extends Dialog {
final int? questionNo;
final Function closeCall;
AnswerHandwriting(
{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,
);
}
{super.key, required this.homeworkId, required this.studentId, required this.closeCall, this.templateId, this.pageNum, this.questionNo});
final _handwritingLogic = Get.find<HandwritingLogic>();
@override
Widget build(BuildContext context) {
return OrientationBuilder(builder: (BuildContext context, Orientation orientation) {
var boxHeight = ScreenUtil().screenHeight / 1.168; //
var boxWidth = ScreenUtil().screenWidth - (ScreenUtil().scaleWidth < 1.5 ? 40.r : 40.r); //
@ -67,6 +60,7 @@ class AnswerHandwriting extends Dialog {
),
),
);
});
}
}
@ -78,12 +72,18 @@ Future<void> showAnswerHandwriting(
int? pageNum,
int? questionNo,
}) async {
try {
backCall() {
Navigator.of(context).pop();
}
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(
@ -94,10 +94,7 @@ Future<void> showAnswerHandwriting(
questionNo: questionNo,
closeCall: backCall,
),
);
} finally {
Get.delete<HandwritingLogic>();
}
).then((e) => Get.delete<HandwritingLogic>());
}
//
@ -364,7 +361,12 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
_packagedHandwritingDataAll = [];
}
// _vnPrimaryHandWritings.is
try {
_vnPrimaryHandWritings.value = [..._packagedHandwritingDataAll]; //
} catch (e) {
_vnPrimaryHandWritings = ValueNotifier<List<GestureHandwritingRecording>>(_packagedHandwritingDataAll);
}
// eventFire(model: JobHandwritingPlaybarBus);
});
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) {
switch (e.runtimeType) {
@ -421,6 +429,8 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
@override
void dispose() {
imageStream?.removeListener(theImageStreamListener);
_vnHandWritings.dispose();
_vnPrimaryHandWritings.dispose();
showManuscriptStream.cancel();
executionDataStream.cancel();
eventCancel();
@ -537,7 +547,8 @@ class _HandwritingDrawBoxState extends State<HandwritingDrawBox> with EventBusMi
imageUrl: paperPicture,
(context, imageProvider) {
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 = imageWidget.image.resolve(const ImageConfiguration());
imageStream?.addListener(theImageStreamListener);
@ -873,7 +884,6 @@ class StudentManuscriptBtn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Obx(() {
print('显示原噶:${handwritingLogic.toolbar.showManuscript.value}');
return InkWell(
onTap: () => easyThrottle('job_handwriting_udent_manuscript', () {
var showManuscript = handwritingLogic.toolbar.showManuscript.value;

View File

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