完成dy部分问题

This commit is contained in:
1147192855@qq.com 2025-04-19 17:20:47 +08:00
parent 80256a6042
commit 25029477cd
1 changed files with 18 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -59,7 +61,8 @@ 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)),
//
@ -259,7 +262,8 @@ 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]) {
@ -300,7 +304,9 @@ 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);
}
@ -324,7 +330,10 @@ 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 = [];
@ -444,7 +453,10 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
// - imageHeightOffsetStart
// if (theScale == 1) {
// }
localPosition = Offset((localPosition.dx+(sateData.zoomOffset?.dx.abs()??0)) / theScale, (dy / theScale) - (imageHeightOffsetStart/ theScale));
localPosition = Offset(
(localPosition.dx + (sateData.zoomOffset?.dx.abs() ?? 0)) / theScale,
(dy / theScale) - (max(0, imageHeightOffsetStart) / theScale) + ((sateData.zoomOffset?.dy.abs() ?? 0) / theScale),
);
print("最终位置 $localPosition");
vnHandWritings.value = List.from(vnHandWritings.value)..add(localPosition);
@ -462,7 +474,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
ignoring: isPen,
child: Zoom(
key: zoomKey.value,
initTotalZoomOut: true, //
// initTotalZoomOut: true, //
zoomSensibility: 0.05,
scrollWeight: 4.r,
doubleTapAnimDuration: Duration.zero,