处理部分问题

This commit is contained in:
1147192855@qq.com 2024-11-07 10:09:17 +08:00
parent 1ec5c5eb62
commit 261d1ad4a4
6 changed files with 35 additions and 53 deletions

View File

@ -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); //

View File

@ -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)),

View File

@ -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<BottomOperationBar
children: [
$TheCachedNetworkImage(
imageUrl: imageUrl,
imgWidth: maxWidth,
(context, imageProvider) {
Image imageWidget = Image(image: imageProvider, fit: BoxFit.fitWidth);
imageStream?.removeListener(imageStreamListener.value);
@ -648,6 +648,7 @@ class QuestionImageView extends HookWidget with EventBusMixin<BottomOperationBar
foregroundPainter: DrawingPainter(ctrl: vnHandWritings),
child: showZgtAnnotate != null
? $TheCachedNetworkImage(
imgWidth: maxWidth,
imageUrl: showZgtAnnotate,
(_, imageProvider) => Image(image: imageProvider, fit: BoxFit.fitWidth),
)

View File

@ -61,8 +61,7 @@ class HomeworkReviewLogic extends GetxController with RequestToolMixin {
late StreamSubscription<DoPaperDetailsParam> _paramListen;
late StreamSubscription<DoPaperDetailsResult?> _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<int> bytes = byteData.buffer
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);
List<int> 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;

View File

@ -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<HomeworkReview> {
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,

View File

@ -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