mcy_new #1
|
|
@ -57,7 +57,6 @@ class _QuestionPaperViewState extends State<QuestionPaperView> {
|
|||
child: Obx(() {
|
||||
LastPage? lastPageVal = sateData.data.value?.lastPage;
|
||||
if (lastPageVal == null) return const SizedBox();
|
||||
|
||||
return FloatingActionButton(
|
||||
heroTag: '点击前往上一题',
|
||||
tooltip: '点击前往上一题',
|
||||
|
|
@ -81,7 +80,6 @@ class _QuestionPaperViewState extends State<QuestionPaperView> {
|
|||
child: Obx(() {
|
||||
NextPage? nextPageVal = sateData.data.value?.nextPage;
|
||||
if (nextPageVal == null) return const SizedBox();
|
||||
|
||||
return FloatingActionButton(
|
||||
heroTag: '点击前往下一题',
|
||||
tooltip: '点击前往下一题',
|
||||
|
|
@ -114,8 +112,11 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) {
|
|||
final scrollControllerNum = useScrollController(); // 试题题号区域
|
||||
|
||||
useEffect(() {
|
||||
scrollControllerNum.addListener(() {
|
||||
if (sateData.panQuestView == false) sateData.slide.value = scrollControllerNum.offset;
|
||||
});
|
||||
var listenVal = sateData.slide.listen((e) {
|
||||
if (e != scrollControllerNum.offset) scrollControllerNum.jumpTo(e);
|
||||
if (e != scrollControllerNum.offset && sateData.panQuestView == true) scrollControllerNum.jumpTo(e);
|
||||
});
|
||||
|
||||
return () {
|
||||
|
|
@ -136,29 +137,31 @@ Widget $questionNumberView(BuildContext context, HomeworkReviewState sateData) {
|
|||
)
|
||||
],
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollControllerNum,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
||||
child: Obx(() {
|
||||
var imageVal = sateData.imageScale.value;
|
||||
if (imageVal == null) return const SizedBox();
|
||||
var studentQuestions = sateData.studentQuestions.value;
|
||||
child: GestureDetector(
|
||||
onPanDown: (_) => sateData.panQuestView = false,
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollControllerNum,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
||||
child: Obx(() {
|
||||
var imageVal = sateData.imageScale.value;
|
||||
if (imageVal == null) return const SizedBox();
|
||||
var studentQuestions = sateData.studentQuestions.value;
|
||||
|
||||
var boxHeight = imageVal.boxHeight;
|
||||
var actualImgHeight = imageVal.actualImgHeight; // 实际图片高度
|
||||
var boxHeight = imageVal.boxHeight;
|
||||
var actualImgHeight = imageVal.actualImgHeight; // 实际图片高度
|
||||
|
||||
return Container(
|
||||
height: boxHeight > actualImgHeight ? boxHeight : actualImgHeight,
|
||||
padding: EdgeInsets.only(top: imageVal.remainingHeight > 0 ? imageVal.remainingHeight / 2 : 0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: studentQuestions?.asMap().keys.map((e) => $ScoringQuestionsView(studentQuestions[e], imageVal.scaleRatio)).toList() ?? [],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
return Container(
|
||||
height: boxHeight > actualImgHeight ? boxHeight : actualImgHeight,
|
||||
padding: EdgeInsets.only(top: imageVal.remainingHeight > 0 ? imageVal.remainingHeight / 2 : 0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: studentQuestions?.asMap().keys.map((e) => $ScoringQuestionsView(studentQuestions[e], imageVal.scaleRatio)).toList() ?? [],
|
||||
),
|
||||
);
|
||||
}),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -354,9 +357,17 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
|
|||
vnHandWritings.value = annotationsData;
|
||||
});
|
||||
|
||||
scrollControllerQuestion.addListener(() => sateData.slide.value = scrollControllerQuestion.offset); // 执行滚动相关的逻辑,例如打印滚动位置
|
||||
scrollControllerQuestion.addListener(() {
|
||||
sateData.slide.value = scrollControllerQuestion.offset;
|
||||
}); // 执行滚动相关的逻辑,例如打印滚动位置
|
||||
|
||||
var listenVal = sateData.slide.listen((e) {
|
||||
if (e != scrollControllerQuestion.offset && sateData.panQuestView == false) scrollControllerQuestion.jumpTo(e);
|
||||
});
|
||||
|
||||
// 返回一个清理函数,在组件销毁时移除监听
|
||||
return () {
|
||||
listenVal.cancel();
|
||||
imageStream?.removeListener(imageStreamListener.value);
|
||||
};
|
||||
}, []);
|
||||
|
|
@ -369,45 +380,48 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
|
|||
var imageUrl = sateData.data.value?.zgtAnswer;
|
||||
if (imageUrl == null) return const SizedBox();
|
||||
|
||||
return SingleChildScrollView(
|
||||
controller: scrollControllerQuestion,
|
||||
physics: !annotationState.pen.value ? const BouncingScrollPhysics() : const NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), offset: Offset(-6.r, 1.r), blurRadius: 10.r, spreadRadius: 8.r)]),
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onPointerUp: (PointerUpEvent details) {
|
||||
// 处理单个触摸点抬起的逻辑
|
||||
// activePointers--;
|
||||
// globalPosition = null;
|
||||
var imageScale = sateData.imageScale.value;
|
||||
if (imageScale == null || !annotationState.pen.value) return;
|
||||
vnHandWritings.value.add(null); // 增加空点以分隔不同的线段
|
||||
},
|
||||
onPointerMove: (PointerMoveEvent event) {
|
||||
var imageScale = sateData.imageScale.value;
|
||||
if (imageScale == null || !annotationState.pen.value) return;
|
||||
Offset localPosition = event.localPosition;
|
||||
var dy = localPosition.dy;
|
||||
if (dy > imageScale.actualImgHeight || dy < 0) return; // 检查笔记是否超出图片范围
|
||||
return GestureDetector(
|
||||
onPanDown: (_) => sateData.panQuestView = true,
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollControllerQuestion,
|
||||
physics: !annotationState.pen.value ? const BouncingScrollPhysics() : const NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.vertical, // 设置垂直滚动
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), offset: Offset(-6.r, 1.r), blurRadius: 10.r, spreadRadius: 8.r)]),
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onPointerUp: (PointerUpEvent details) {
|
||||
// 处理单个触摸点抬起的逻辑
|
||||
// activePointers--;
|
||||
// globalPosition = null;
|
||||
var imageScale = sateData.imageScale.value;
|
||||
if (imageScale == null || !annotationState.pen.value) return;
|
||||
vnHandWritings.value.add(null); // 增加空点以分隔不同的线段
|
||||
},
|
||||
onPointerMove: (PointerMoveEvent event) {
|
||||
var imageScale = sateData.imageScale.value;
|
||||
if (imageScale == null || !annotationState.pen.value) return;
|
||||
Offset localPosition = event.localPosition;
|
||||
var dy = localPosition.dy;
|
||||
if (dy > imageScale.actualImgHeight || dy < 0) return; // 检查笔记是否超出图片范围
|
||||
|
||||
vnHandWritings.value = List.from(vnHandWritings.value)..add(localPosition);
|
||||
},
|
||||
child: RepaintBoundary(
|
||||
child: CustomPaint(
|
||||
foregroundPainter: DrawingPainter(ctrl: vnHandWritings),
|
||||
child: RepaintBoundary(
|
||||
child: $TheCachedNetworkImage(
|
||||
(context, imageProvider) {
|
||||
Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth);
|
||||
imageStream?.removeListener(imageStreamListener.value);
|
||||
imageStream = imageWidget.image.resolve(const ImageConfiguration())..addListener(imageStreamListener.value);
|
||||
return imageWidget;
|
||||
},
|
||||
imageUrl: RequestConfig.imgUrl + imageUrl,
|
||||
vnHandWritings.value = List.from(vnHandWritings.value)..add(localPosition);
|
||||
},
|
||||
child: RepaintBoundary(
|
||||
child: CustomPaint(
|
||||
foregroundPainter: DrawingPainter(ctrl: vnHandWritings),
|
||||
child: RepaintBoundary(
|
||||
child: $TheCachedNetworkImage(
|
||||
(context, imageProvider) {
|
||||
Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth);
|
||||
imageStream?.removeListener(imageStreamListener.value);
|
||||
imageStream = imageWidget.image.resolve(const ImageConfiguration())..addListener(imageStreamListener.value);
|
||||
return imageWidget;
|
||||
},
|
||||
imageUrl: RequestConfig.imgUrl + imageUrl,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class HomeworkReviewState {
|
|||
late Rx<DoPaperDetailsResult?> data;
|
||||
late Rx<List<StudentQuestions>?> studentQuestions;
|
||||
late Rx<double> slide; // 滑动位置
|
||||
late bool? panQuestView;
|
||||
late Rx<TestQuestionsImageInfo?> imageScale;
|
||||
|
||||
// late String dateEnd = '';
|
||||
|
|
|
|||
Loading…
Reference in New Issue