Compare commits

...

2 Commits

Author SHA1 Message Date
1147192855@qq.com 8d27f76311 Merge branch 'new_main' into new_main_wy 2024-05-31 15:47:20 +08:00
1147192855@qq.com bdc136ba71 no message 2024-05-31 15:46:30 +08:00
5 changed files with 56 additions and 28 deletions

3
.gitignore vendored
View File

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

View File

@ -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<BottomAnnotationSwitch> with SingleTickerProviderStateMixin {
late AnimationController _animationController; //
final _logicControl = Get.find<HomeworkReviewLogic>().annotationState;
StreamSubscription? _opControllisten;
@override
void initState() {
@ -27,6 +29,14 @@ class _BottomAnnotationSwitchJobState extends State<BottomAnnotationSwitch> 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<BottomAnnotationSwitch> with
_animationController
..removeListener(toUp)
..dispose();
_opControllisten?.cancel();
super.dispose();
}

View File

@ -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<HomeworkReviewLogic> {
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),
);
});
}
}

View File

@ -28,7 +28,8 @@ class _FavoriteState extends State<FavoriteWidget> 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<FavoriteWidget> with RequestToolMixin {
super.dispose();
}
Future<void> getData() async {
// int taskId, int studentId, int paperId
// try {
// RestClient _client = await getClient();
// BaseStructureResult<bool> res = await _client.getJobCollect(taskId, studentId, paperId);
// if (res.success) return JobCollectParams(paperId, taskId, studentId, res.data ?? false);
// } catch (e) {}
// return null;
}
Future<void> 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<bool> 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('操作失败,请重试');
}
}

View File

@ -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<HomeworkReview> {
@override
void initState() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown]);
super.initState();
}
@ -62,6 +63,8 @@ class _HomeworkReviewState extends State<HomeworkReview> {
],
),
),
floatingActionButton: const ButtonFloatingAction(),
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
);
}
}