处理图片尺寸并且完成批阅部分优化

This commit is contained in:
DESKTOP-I3JPKHK\wy 2025-04-21 11:49:24 +08:00
parent 138b4bb767
commit 3f9661436d
3 changed files with 114 additions and 102 deletions

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
@ -147,8 +148,7 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
width: double.infinity,
height: double.infinity,
child: TextButton(
onPressed: () =>
easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating(context)),
onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.allWrongRating(context)),
child: quickText('全 错', color: Colors.white, size: 12.sp),
),
),
@ -183,7 +183,6 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
),
),
),
],
),
),
@ -212,14 +211,28 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> with
height: double.infinity,
child: TextButton(
onPressed: () => easyThrottle('homework_bottom_operation_bar_scoring_related', () => _homeworkLogic.submit(context)),
child: quickText('提 交', size: 14.sp, color: Theme.of(context).primaryColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Obx(() {
if (_homeworkLogic.state.submitLoading.value) {
return Padding(
padding: EdgeInsets.only(right: 4.w),
child: const SizedBox(width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2)),
);
}
return const SizedBox();
}),
quickText('提 交', size: 14.sp, color: Theme.of(context).primaryColor),
],
),
),
),
),
],
),
),
],
),
);

View File

@ -61,8 +61,7 @@ class QuestionPaperView extends GetView<HomeworkReviewLogic> {
return Stack(
children: [
//
QuestionImageView(maxWidth, maxHeight, annotationState, controller,
zoomState: zoomState, sateData: sateData, actualHeight: zoomFileModel.actualHeight!),
QuestionImageView(maxWidth, maxHeight, annotationState, controller, zoomState: zoomState, sateData: sateData, actualHeight: zoomFileModel.actualHeight!),
//
// Positioned(right: 3.w, bottom: 4.h, child: const $ContinueToReview(isFloatingAction: true)),
//
@ -262,8 +261,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
final ZoomState zoomState;
final HomeworkReviewState sateData;
final HomeworkReviewAnnotationsControlState annotationState;
QuestionImageView(this.maxWidth, this.maxHeight, this.annotationState, this.logic,
{required this.actualHeight, required this.zoomState, required this.sateData, super.key});
QuestionImageView(this.maxWidth, this.maxHeight, this.annotationState, this.logic, {required this.actualHeight, required this.zoomState, required this.sateData, super.key});
///
int _findTargetIndex<T>(List<T> list, T target, [int reciprocal = 2]) {
@ -304,9 +302,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
});
var streamSubscriptionSlide = sateData.slide.listen((e) {
if (sateData.panQuestView != null &&
sateData.panQuestView == false &&
initPosition.value?.dy.abs().toInt().toDouble() != sateData.slide.value) {
if (sateData.panQuestView != null && sateData.panQuestView == false && initPosition.value?.dy.abs().toInt().toDouble() != sateData.slide.value) {
if (sateData.zoomOffset != null) {
sateData.zoomOffset = Offset(sateData.zoomOffset!.dx, -sateData.slide.value);
}
@ -330,10 +326,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
bool? res = await showDialog<bool>(
context: Get.context ?? context,
builder: (context1) {
return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: <Widget>[
TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)),
TextButton(child: quickText("确定", color: Theme.of(context1).primaryColor), onPressed: () => Navigator.pop(context1, true))
]);
return AlertDialog(content: quickText("是否撤销全部批注痕迹?"), actions: <Widget>[TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)), TextButton(child: quickText("确定", color: Theme.of(context1).primaryColor), onPressed: () => Navigator.pop(context1, true))]);
},
);
if (res == true) vnHandWritings.value = [];
@ -347,11 +340,17 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
TextButton(child: quickText("取消"), onPressed: () => Navigator.pop(context1, false)),
TextButton(
child: quickText("确定", color: Theme.of(context).primaryColor),
onPressed: () {
onPressed: () => easyThrottle(
'REVOKE_THE_LAST_ANNOTATION_AND_SUBMIT',
() {
Navigator.pop(context1, true);
sateData.data.value?.zgtAnnotate = null;
sateData.data.value?.showZgtAnnotate = null;
if (sateData.data.value != null) {
sateData.data.update((_) => logic.submit(Get.context ?? context));
}
},
),
)
]);
},
@ -458,14 +457,8 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
var zoomWtdthSpaceVal = zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1);
localPosition = Offset(
(localPosition.dx -
zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1) +
((zoomWtdthSpaceVal <= 0.1) ? (sateData.zoomOffset?.dx.abs() ?? 0) : 0)) /
theScale,
(dy -
max(0, imageHeightOffsetStart) +
((zoomFile.imageHeightOffsetStart == null || zoomFile.imageHeightOffsetStart! <= 0.1) ? (sateData.zoomOffset?.dy.abs() ?? 0) : 0)) /
theScale,
(localPosition.dx - zoomFile.getZoomFileOffsetStartWidth(zoomState.initScale.value ?? 1) + ((zoomWtdthSpaceVal <= 0.1) ? (sateData.zoomOffset?.dx.abs() ?? 0) : 0)) / theScale,
(dy - max(0, imageHeightOffsetStart) + ((zoomFile.imageHeightOffsetStart == null || zoomFile.imageHeightOffsetStart! <= 0.1) ? (sateData.zoomOffset?.dy.abs() ?? 0) : 0)) / theScale,
);
print("最终位置 $localPosition");

View File

@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:get/get_rx/get_rx.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_result.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_test_questions_image_info.dart';
@ -44,6 +45,7 @@ class HomeworkReviewState {
Offset? zoomOffset;
RxBool favorite = false.obs; //
RxBool submitLoading = false.obs; //
// late String dateEnd = '';
// late int knowledgeId = 0;
// late RxList<KnowledgeReportDetail> dataList = RxList();
@ -234,12 +236,11 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
//
RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?;
if (boundary == null) return null;
// double dpr = MediaQuery.of(context).devicePixelRatio;
double dpr = MediaQuery.of(context).devicePixelRatio;
///
// double? pixelRatio = zoomLogic.zoomState.zoomFile.value?.scaleRatio ?? MediaQuery.of(context).devicePixelRatio;
ui.Image image = await boundary.toImage();
var pixelRatio = zoomLogic.zoomState.zoomFile.value?.pixelRatio;
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio ?? dpr);
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData == null) return null;
@ -266,6 +267,9 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
//
/// allPairs
Future<void> submit(BuildContext context) async {
try {
if(state.submitLoading.value) return;
state.submitLoading.value = true;
var data = state.data.value;
if (data == null) return;
@ -282,7 +286,6 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
String? newzgtAnnotate = await saveImage(context);
if (newzgtAnnotate != null) zgtAnnotate = newzgtAnnotate;
// TODO
await getClient()
.reviewSubmission(ReviewSubmissionParams(
homeworkId: state.param.value.homeworkId,
@ -338,6 +341,9 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
}
state.param.value = newParams;
});
} catch (_) {}finally{
state.submitLoading.value= false;
}
}
Future<void> toFavorite() async {