From a4dd67ddfa3d8a03a0b80729dd193a19e0f7b808 Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Fri, 14 Jun 2024 09:45:36 +0800 Subject: [PATCH] no message --- .../components/question_paper_view.dart | 89 ++++++++++++++----- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart index 4fed909..e28519f 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/question_paper_view.dart @@ -59,8 +59,8 @@ class _QuestionPaperViewState extends State { heroTag: '点击前往上一题', tooltip: '点击前往上一题', focusColor: Theme.of(context).primaryColor, - backgroundColor: const Color.fromRGBO(24, 32, 32, 0.1), - elevation: 6.r, + backgroundColor: const Color.fromRGBO(24, 32, 32, 0.05), + elevation: 10.r, onPressed: () => easyThrottle('TestQuestionSwitch', () { var param = sateData.param.value; param.studentId = lastPageVal.studentId; @@ -82,8 +82,8 @@ class _QuestionPaperViewState extends State { return FloatingActionButton( heroTag: '点击前往下一题', tooltip: '点击前往下一题', - elevation: 6.r, - backgroundColor: const Color.fromRGBO(24, 32, 32, 0.1), + elevation: 10.r, + backgroundColor: const Color.fromRGBO(24, 32, 32, 0.05), onPressed: () => easyThrottle('TestQuestionSwitch', () { var param = sateData.param.value; param.studentId = nextPageVal.studentId; @@ -279,9 +279,9 @@ Widget $scoringQuestionsView(BuildContext context, StudentQuestions item, double @hwidget Widget $questionImageView(double maxWidth, double maxHeight, HomeworkReviewState sateData) { final scrollControllerQuestion = useScrollController(); // 试题图片区域 + var vnHandWritings = useValueNotifier>([]); ImageStream? imageStream; - - ImageStreamListener imageStreamListener = ImageStreamListener((ImageInfo info, bool _) { + var imageStreamListener = useState(ImageStreamListener((ImageInfo info, bool _) { WidgetsBinding.instance.addPostFrameCallback((_) { sateData.imageScale.value = TestQuestionsImageInfo( boxWidth: maxWidth, @@ -291,7 +291,7 @@ Widget $questionImageView(double maxWidth, double maxHeight, HomeworkReviewState url: sateData.data.value!.zgtAnswer, ); }); - }); + })); // 可选:添加滚动监听 useEffect(() { @@ -301,10 +301,11 @@ Widget $questionImageView(double maxWidth, double maxHeight, HomeworkReviewState }); // 返回一个清理函数,在组件销毁时移除监听 return () { - imageStream?.removeListener(imageStreamListener); + imageStream?.removeListener(imageStreamListener.value); }; }, []); + print('这里是加载了..............'); return Container( height: maxHeight, // padding: EdgeInsets.only(bottom: 2.h, top: 2.h), @@ -316,25 +317,69 @@ Widget $questionImageView(double maxWidth, double maxHeight, HomeworkReviewState scrollDirection: Axis.vertical, // 设置垂直滚动 child: Obx(() { var imageUrl = sateData.data.value?.zgtAnswer; - print(imageUrl); if (imageUrl == null) return const SizedBox(); - // return Container( - // color: Colors.green, - // height: 394.45145018915514, - // ); - return $TheCachedNetworkImage( - (context, imageProvider) { - Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth); - imageStream?.removeListener(imageStreamListener); - imageStream = imageWidget.image.resolve(const ImageConfiguration())..addListener(imageStreamListener); + return Container( + decoration: BoxDecoration(boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.2), + offset: Offset(-6.r, 1.r), //阴影x轴偏移量 + blurRadius: 10.r, //阴影模糊程度 + spreadRadius: 8.r //阴影扩散程度 + ) + ]), + child: Listener( + behavior: HitTestBehavior.opaque, + onPointerUp: (PointerUpEvent details) {}, + onPointerMove: (PointerMoveEvent details) {}, + child: RepaintBoundary( + child: CustomPaint( + foregroundPainter: DrawingPainter(ctrl: vnHandWritings), + child: RepaintBoundary( + child: $TheCachedNetworkImage( + (context, imageProvider) { + print('图片加载了..............'); + 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, - // imageUrl: 'https://cdn3-banquan.ituchong.com/weili/image/l/2000260200787476490.jpeg', + return imageWidget; + }, + imageUrl: RequestConfig.imgUrl + imageUrl, + ), + ), + ), + ), + ), ); }), ), ); } + +// 批注框 +class DrawingPainter extends CustomPainter { + final ValueNotifier> ctrl; + final Paint paintBrush = Paint() + ..color = Colors.red + ..strokeCap = StrokeCap.round + ..strokeWidth = 1.5.r; + DrawingPainter({required this.ctrl}) : super(repaint: ctrl); + + @override + void paint(Canvas canvas, Size size) { + var points = ctrl.value; + var pointsLength = points.length; + // for (int i = 0; i < pointsLength; i++) { + // GestureRecording item = points[i]; + // Offset? offsetData = item.data; + // Offset? nextOffsetData = pointsLength - 1 == i ? null : points[i + 1].data; + // if (offsetData != null && nextOffsetData != null) { + // canvas.drawLine(offsetData, nextOffsetData, paintBrush); + // } + // } + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) => false; +}