From 261d1ad4a4dffa72238cf668114dd3dc952c495f Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Thu, 7 Nov 2024 10:09:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E9=83=A8=E5=88=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/common/config/request_config.dart | 4 +- .../lib/common/utils/cached_network_img.dart | 4 +- .../components/question_paper_view.dart | 3 +- .../configuration_files/index.dart | 32 +++++--------- .../children/homework_review/index.dart | 44 ++++++++----------- making_school_asignment_app/pubspec.yaml | 1 + 6 files changed, 35 insertions(+), 53 deletions(-) diff --git a/making_school_asignment_app/lib/common/config/request_config.dart b/making_school_asignment_app/lib/common/config/request_config.dart index 9803e1b..a101124 100644 --- a/making_school_asignment_app/lib/common/config/request_config.dart +++ b/making_school_asignment_app/lib/common/config/request_config.dart @@ -20,8 +20,8 @@ class RequestConfig { static const connectTimeout = 8000; // 连接超时 static const receiveTimeout = 8000; // 接收超时 - static const bool requestDataPrinting = false; // 打印返回数据 - static const bool printSwitch = false; // 打印返回数据 + static const bool requestDataPrinting = true; // 打印返回数据 + static const bool printSwitch = true; // 打印返回数据 static const successCode = [204, 200]; // 返回成功code static final BasePage basePage = BasePage(1, 10); // 分页参数 diff --git a/making_school_asignment_app/lib/common/utils/cached_network_img.dart b/making_school_asignment_app/lib/common/utils/cached_network_img.dart index ac198fc..1d2c090 100644 --- a/making_school_asignment_app/lib/common/utils/cached_network_img.dart +++ b/making_school_asignment_app/lib/common/utils/cached_network_img.dart @@ -9,14 +9,14 @@ import 'package:functional_widget_annotation/functional_widget_annotation.dart'; part 'cached_network_img.g.dart'; @hwidget -Widget $theCachedNetworkImage(ImageWidgetBuilder imageBuilder, {required String imageUrl}) { +Widget $theCachedNetworkImage(ImageWidgetBuilder imageBuilder, {required String imageUrl, double? imgWidth}) { UseCachedImgRefresh useImgRefsh = UseCachedImgRefresh.use(); return CachedNetworkImage( key: useImgRefsh.imageKey.value, cacheKey: imageUrl, fit: BoxFit.fitWidth, - width: double.infinity, + width: imgWidth ?? double.infinity, imageUrl: imageUrl, imageBuilder: imageBuilder, placeholder: (context, url) => Center(child: SpinKitWave(color: Theme.of(context).primaryColor, size: 50.r)), 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 954415e..9626922 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 @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:functional_widget_annotation/functional_widget_annotation.dart'; -import 'package:gesture_zoom_box/gesture_zoom_box.dart'; import 'package:get/get.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_bus.dart'; import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart'; @@ -632,6 +631,7 @@ class QuestionImageView extends HookWidget with EventBusMixin Image(image: imageProvider, fit: BoxFit.fitWidth), ) diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart index e130bc4..57b5507 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/configuration_files/index.dart @@ -61,8 +61,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { late StreamSubscription _paramListen; late StreamSubscription _dataListen; final HomeworkReviewState state = HomeworkReviewState(); - final HomeworkReviewAnnotationsControlState annotationState = - HomeworkReviewAnnotationsControlState(); + final HomeworkReviewAnnotationsControlState annotationState = HomeworkReviewAnnotationsControlState(); @override void onInit() { @@ -92,11 +91,9 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { } void getData() async { - var timerControl = Timer( - const Duration(milliseconds: 300), () => ToastUtils.showLoading()); + var timerControl = Timer(const Duration(milliseconds: 300), () => ToastUtils.showLoading()); try { - DoPaperDetailsResult? data = - await getClient().getDoPaperDetails(state.param.value); + DoPaperDetailsResult? data = await getClient().getDoPaperDetails(state.param.value); // var studentQuestions = data.studentQuestions; // // 第0个的下标数据不需要处理 // for (var i = 0; i < studentQuestions.length; i++) { @@ -110,7 +107,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { state.studentQuestions.value = data.studentQuestions; } catch (e) { print('获取数据报错了:$e'); - ToastUtils.showError('获取试题数据出错,请重试'); + ToastUtils.showError('未获取到试题数据,请重试'); state.getDataError.value = true; } finally { if (timerControl.isActive) timerControl.cancel(); @@ -168,16 +165,12 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { if (data == null) return null; // 获取OSS 图片url - String imgKey = UploadOssImgUtils.getInstance().setImgKey( - param.homeworkId, - data.studentId.toString(), - data.templateId.toString()); + String imgKey = UploadOssImgUtils.getInstance().setImgKey(param.homeworkId, data.studentId.toString(), data.templateId.toString()); var resUrl = await getClient().getOssPresignedUri(imgKey); if (resUrl == null) return null; // 没有图片就上传图片 - RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext! - .findRenderObject() as RenderRepaintBoundary?; + RenderRepaintBoundary? boundary = pictureOverviewKey.currentContext!.findRenderObject() as RenderRepaintBoundary?; if (boundary == null) return null; // double dpr = MediaQuery.of(context).devicePixelRatio; @@ -189,20 +182,16 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { } ui.Image image = await boundary.toImage(pixelRatio: pixelRatio); - ByteData? byteData = - await image.toByteData(format: ui.ImageByteFormat.png); + ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); if (byteData == null) return null; Dio dio = Dio(); dio.options.contentType = null; - List bytes = byteData.buffer - .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes); + List bytes = byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes); await dio.put( resUrl, data: Stream.fromIterable(bytes.map((e) => [e])), - options: Options( - contentType: null, - headers: {Headers.contentLengthHeader: bytes.length}), + options: Options(contentType: null, headers: {Headers.contentLengthHeader: bytes.length}), ); return imgKey; @@ -224,8 +213,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin { if (state.data.value?.studentQuestions.isEmpty ?? true) return; var studentQuestions = state.data.value!.studentQuestions; - var noRatingElement = - studentQuestions.firstWhereOrNull((e) => e.studentScore == null); + var noRatingElement = studentQuestions.firstWhereOrNull((e) => e.studentScore == null); if (noRatingElement != null) { ToastUtils.showInfo('${noRatingElement.questionNo}题请评分'); return; diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart index 20d7ab4..26f8afc 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/index.dart @@ -7,6 +7,7 @@ import 'package:making_school_asignment_app/page/global_widget/my_text.dart'; import 'package:making_school_asignment_app/page/home_page/children/annotate_class/annotate_class_logic.dart'; import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/question_paper_view.dart'; import 'package:making_school_asignment_app/page/home_page/home_logic.dart'; +import 'package:zoom_widget/zoom_widget.dart'; import 'components/bottom_operation_bar.dart'; import 'components/dropdown_switch_students_type.dart'; @@ -62,32 +63,23 @@ class _HomeworkReviewState extends State { elevation: 0, actions: [const FavoriteWidget(), SizedBox(width: 5.w), const ReturnToHomepage()], ), - body: SafeArea( - child: Column( - children: [ - // 下拉切换 - const DropdownSwitchStudentsType(), - SizedBox(height: 1.h), - const Expanded(child: QuestionPaperView() - // child: CustomZoomWidget( - // child: Image.network('https://cdn3-banquan.ituchong.com/weili/image/l/903170934517792920.jpeg'), - // ), - // child: CustomZoomWidget( - // child: Image.network('https://cdn3-banquan.ituchong.com/weili/image/l/903170934517792920.jpeg'), - // minScale: 0.8, - // maxScale: 4, - // resetDuration: const Duration(milliseconds: 200), - // boundaryMargin: const EdgeInsets.only(bottom: 0), - // clipBehavior: Clip.hardEdge, - // useOverlay: false, - // maxOverlayOpacity: 0.5, - // overlayColor: Colors.black, - // fingersRequiredToPinch: 2, - // ), - ), - const BottomAnnotationSwitch() - ], - ), + body: Column( + children: [ + // 下拉切换 + const DropdownSwitchStudentsType(), + SizedBox(height: 1.h), + const Expanded( + child: QuestionPaperView(), + + // child: Container( + // height: double.infinity, + // width: double.infinity, + // color: Colors.red, + // ), + // child: QuestionPaperView(), + ), + const BottomAnnotationSwitch() + ], ), // floatingActionButton: const ButtonFloatingAction(), // floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, diff --git a/making_school_asignment_app/pubspec.yaml b/making_school_asignment_app/pubspec.yaml index 6a329f1..ff38be2 100644 --- a/making_school_asignment_app/pubspec.yaml +++ b/making_school_asignment_app/pubspec.yaml @@ -97,6 +97,7 @@ dependencies: icons_launcher: ^2.1.7 app_settings: ^5.1.1 device_info_plus: ^11.1.0 + zoom_widget: ^2.0.1