From bdc136ba71eaaba54d82c86f320d1b151883a4fc Mon Sep 17 00:00:00 2001 From: "1147192855@qq.com" <1147192855@qq.com> Date: Fri, 31 May 2024 15:46:30 +0800 Subject: [PATCH] no message --- .gitignore | 3 ++ .../components/bottom_operation_bar.dart | 11 +++++ .../components/button_floating_action.dart | 24 +++++++++++ .../components/favorite_widget.dart | 41 +++++++------------ .../children/homework_review/index.dart | 5 ++- 5 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 making_school_asignment_app/lib/page/home_page/children/homework_review/components/button_floating_action.dart diff --git a/.gitignore b/.gitignore index 64d9515..3e65d0d 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ app.*.map.json making_school_asignment_app/*.g.dart making_school_asignment_app/pubspec.lock making_school_asignment_app/lib/common/api/retrofit_client.g.dart +making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.g.dart +making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.g.dart +making_school_asignment_app/lib/page/home_page/children/read_over/read_over_view.g.dart diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart index a3934ff..9c585b2 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/bottom_operation_bar.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -17,6 +18,7 @@ class BottomAnnotationSwitch extends StatefulWidget { class _BottomAnnotationSwitchJobState extends State with SingleTickerProviderStateMixin { late AnimationController _animationController; // 动画 final _logicControl = Get.find().annotationState; + StreamSubscription? _opControllisten; @override void initState() { @@ -27,6 +29,14 @@ class _BottomAnnotationSwitchJobState extends State with upperBound: 1, duration: const Duration(milliseconds: 300), )..addListener(toUp); + + _opControllisten = _logicControl.opControl.listen((e) { + if (e) { + _animationController.forward(); + } else { + _animationController.reverse(); + } + }); super.initState(); } @@ -35,6 +45,7 @@ class _BottomAnnotationSwitchJobState extends State with _animationController ..removeListener(toUp) ..dispose(); + _opControllisten?.cancel(); super.dispose(); } diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/button_floating_action.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/button_floating_action.dart new file mode 100644 index 0000000..1b1eb24 --- /dev/null +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/button_floating_action.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:making_school_asignment_app/page/home_page/children/homework_review/configuration_files/index.dart'; + +// 底部状态栏隐藏后的开关 +class ButtonFloatingAction extends GetView { + const ButtonFloatingAction({super.key}); + + @override + Widget build(BuildContext context) { + return Obx(() { + if (controller.annotationState.opControl.value) return const SizedBox(); + + return FloatingActionButton( + elevation: 8, + tooltip: "点击打开工具栏", + backgroundColor: Colors.white, + onPressed: () => controller.annotationState.opControl.value = true, + child: Icon(Icons.edit, size: 20.sp, color: Theme.of(context).primaryColor), + ); + }); + } +} diff --git a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/favorite_widget.dart b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/favorite_widget.dart index 608a118..aa80e7d 100644 --- a/making_school_asignment_app/lib/page/home_page/children/homework_review/components/favorite_widget.dart +++ b/making_school_asignment_app/lib/page/home_page/children/homework_review/components/favorite_widget.dart @@ -28,7 +28,8 @@ class _FavoriteState extends State with RequestToolMixin { @override void initState() { _listen = _controller.state.data.listen((e) { - getData(); // 更新数据 + if (e == null) return; + if (favorite.value != e.isFav) favorite.value = !favorite.value; }); super.initState(); } @@ -39,35 +40,21 @@ class _FavoriteState extends State with RequestToolMixin { super.dispose(); } - Future getData() async { - // int taskId, int studentId, int paperId - // try { - // RestClient _client = await getClient(); - // BaseStructureResult res = await _client.getJobCollect(taskId, studentId, paperId); - // if (res.success) return JobCollectParams(paperId, taskId, studentId, res.data ?? false); - // } catch (e) {} - - // return null; - } - Future toFavorite() async { try { - // ToastUtils.showLoading(); - RetrofitClient _client = await getClient(); - // _client.toFavStudent(FavorParam(homeworkId: sateData.homeworkId, studentId: null, templateId: null, questionNo: null, isFav: null)); - // favoriteVal.isCollect = !favoriteVal.isCollect; - // favoriteVal.paperId = _eventModel!.paperId; - // BaseStructureResult res = await _client.toJobFavoriteCancel(favoriteVal); - // if (res.success) { - // _future = getData(favoriteVal.taskId, favoriteVal.studentId, _eventModel!.paperId); - // widget.call(); - // toUpState(setState, () {}, mounted); - // } else { - // ToastUtils.showError(res.message ?? '操作失败,请重试'); - // } + var data = sateData.data.value!; + var param = sateData.param.value; + await getClient().toFavStudent(FavorParam( + homeworkId: param.homeworkId, + studentId: data.studentId, + templateId: data.templateId, + questionNo: data.studentQuestions[0].questionNo, + isFav: !data.isFav, + )); + favorite.value = !data.isFav; + data.isFav = favorite.value; } catch (e) { - } finally { - ToastUtils.dismiss(); + ToastUtils.showError('操作失败,请重试'); } } 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 1f34bff..e57df4d 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 @@ -6,6 +6,7 @@ import 'package:making_school_asignment_app/page/global_widget/ReturnToHomepage. import 'package:making_school_asignment_app/page/global_widget/my_text.dart'; import 'components/bottom_operation_bar.dart'; +import 'components/button_floating_action.dart'; import 'components/dropdown_switch_students_type.dart'; import 'components/favorite_widget.dart'; import 'configuration_files/index.dart'; @@ -24,7 +25,7 @@ class _HomeworkReviewState extends State { @override void initState() { WidgetsFlutterBinding.ensureInitialized(); - SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown]); super.initState(); } @@ -62,6 +63,8 @@ class _HomeworkReviewState extends State { ], ), ), + floatingActionButton: const ButtonFloatingAction(), + floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, ); } }