mcy_new #1
|
|
@ -74,7 +74,7 @@ class _AnnotateItemState extends State<AnnotateItem> {
|
|||
title: "收藏夹",
|
||||
font: widget.font - 2.sp,
|
||||
clickFunction: () {
|
||||
Get.toNamed(Routes.favStudentPage,arguments: {'title':widget.name});
|
||||
Get.toNamed(Routes.favStudentPage,arguments: {'homeworkName':widget.name,'classId':widget.item.classId,'homeworkId':widget.logic.state.homeworkId.value,'grade':widget.item.grade});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
@ -116,7 +116,7 @@ class _AnnotateItemState extends State<AnnotateItem> {
|
|||
title: "收藏夹",
|
||||
font: widget.font - 2.sp,
|
||||
clickFunction: () {
|
||||
Get.toNamed(Routes.favStudentPage,arguments: {'homeworkName':widget.name,'classId':widget.item.classId});
|
||||
Get.toNamed(Routes.favStudentPage,arguments: {'homeworkName':widget.name,'classId':widget.item.classId,'homeworkId':widget.logic.state.homeworkId.value,'grade':widget.item.grade});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -13,14 +13,29 @@ class FavStudentLogic extends GetxController with RequestToolMixin {
|
|||
void onInit() {
|
||||
super.onInit();
|
||||
state.homeworkName.value = Get.arguments['homeworkName'];
|
||||
state.homeworkId = Get.arguments['homeworkId'];
|
||||
state.grade = Get.arguments['grade'];
|
||||
state.classId = Get.arguments['classId'];
|
||||
EasyLoading.show(status: 'loading...');
|
||||
getClass();
|
||||
}
|
||||
|
||||
void getClass() async {
|
||||
List<AnnotatedClass> data = await getClient().getAnnotatedClassList(state.homeworkId);
|
||||
state.involveClasses.value = data;
|
||||
|
||||
state.involveClasses.value = [state.classData.value, ...(data ?? [])];
|
||||
for (var element in state.involveClasses) {
|
||||
if (element.classId == state.classId && element.grade == state.grade) {
|
||||
state.classData.value = element;
|
||||
}
|
||||
}
|
||||
getList();
|
||||
}
|
||||
|
||||
void getList() async {
|
||||
BasePageData<HomeworkFavs> data =
|
||||
await getClient().getFavList(state.homeworkName.value, state.classId);
|
||||
await getClient().getFavList(state.homeworkName.value, state.classData.value.classId != '-1' ? state.classData.value.classId : '');
|
||||
List arr = [];
|
||||
List groupList = [];
|
||||
if(data.items.isNotEmpty){
|
||||
|
|
@ -40,4 +55,15 @@ class FavStudentLogic extends GetxController with RequestToolMixin {
|
|||
state.favList.value = [...groupList];
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
getDelete(student) async {
|
||||
/* RestClient _client = await getClient();
|
||||
BaseStructureResult res = await _client.getJobDeFavorites(
|
||||
widget.jobId, student.studentId, student.questionPage!);
|
||||
if (res.success) {
|
||||
_future = getData();
|
||||
setState(() {});
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,12 @@ class FavStudentState {
|
|||
}
|
||||
|
||||
late RxString homeworkName = ''.obs;
|
||||
late String homeworkId = '';
|
||||
late int grade;
|
||||
late String classId = '';
|
||||
late RxList favList = RxList();
|
||||
late RxList pageList = RxList();
|
||||
late RxList<AnnotatedClass> involveClasses = RxList();
|
||||
late AnnotatedClass defaultClass = AnnotatedClass('', -1, '-1', '', '', -1, -1, -1, -1, -1, [], [], -1, -1, -1, -1, -1, [], []);
|
||||
late Rx<AnnotatedClass> classData = defaultClass.obs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import 'package:making_school_asignment_app/common/utils/utils.dart';
|
|||
import 'package:making_school_asignment_app/page/global_widget/MyEmptyWidget.dart';
|
||||
import 'package:making_school_asignment_app/page/global_widget/ReturnToHomepage.dart';
|
||||
import 'package:making_school_asignment_app/page/global_widget/my_text.dart';
|
||||
import 'package:making_school_asignment_app/page/home_page/children/fav_student/widget/favorite_student_dialog.dart';
|
||||
import 'package:making_school_asignment_app/page/home_page/children/job_report/widget/dropdown_selection.dart';
|
||||
|
||||
import 'fav_student_logic.dart';
|
||||
|
||||
|
|
@ -22,6 +24,75 @@ class _FavStudentPageState extends State<FavStudentPage> {
|
|||
.find<FavStudentLogic>()
|
||||
.state;
|
||||
|
||||
void showStudentDialog(BuildContext context, HomeworkFavs item, List groups) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
insetPadding: EdgeInsets.all(25.r),
|
||||
content: FavoriteStudentDialog(
|
||||
item: item,
|
||||
group: groups,
|
||||
deleteFav: logic.getDelete,
|
||||
confirmDialog: confirmDialog),
|
||||
contentPadding: const EdgeInsets.all(0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(15.r))));
|
||||
},
|
||||
);
|
||||
}
|
||||
Future<bool> confirmDialog() async {
|
||||
return await showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
actionsPadding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 10.r),
|
||||
content: Text(
|
||||
'确定删除吗?',
|
||||
style: TextStyle(fontSize: 14.sp, color: Color(0xFF505E6E)),
|
||||
),
|
||||
actionsAlignment: MainAxisAlignment.center,
|
||||
actions: <Widget>[
|
||||
InkWell(
|
||||
child: Container(
|
||||
width: 97.r,
|
||||
height: 27.r,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.r)),
|
||||
color: Color(0xFF6888FD),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'确定',
|
||||
style: TextStyle(color: Colors.white),
|
||||
))),
|
||||
onTap: () {
|
||||
// 执行操作
|
||||
// Navigator.of(context).pop(true);
|
||||
Get.back(result: true);
|
||||
},
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
// Navigator.of(context).pop(false);
|
||||
Get.back(result: false);
|
||||
},
|
||||
child: Container(
|
||||
width: 97.r,
|
||||
height: 27.r,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20.r)),
|
||||
color: Color(0xFFF4F4F4),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: Color(0xFF666666)),
|
||||
))),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -49,27 +120,33 @@ class _FavStudentPageState extends State<FavStudentPage> {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Obx(() {
|
||||
Expanded(
|
||||
child: Obx(() {
|
||||
return Text(
|
||||
state.homeworkName.value,
|
||||
style:
|
||||
TextStyle(fontSize: 14.sp, color: Color(0xFF3C3C3C)),
|
||||
TextStyle(fontSize: 14.sp, color: Color(0xFF3C3C3C),),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}),
|
||||
),
|
||||
// 下拉框
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 10.h, horizontal: 10.w),
|
||||
child: Row(
|
||||
children: [
|
||||
/* $classSelection(involveClasses, classData,
|
||||
call: (JobReportJoinClass _classData) {
|
||||
classData = _classData;
|
||||
if (_classData.gradeId == -1) classData = null;
|
||||
className = _classData.className;
|
||||
_future = getData();
|
||||
toUpState(setState, () {}, mounted);
|
||||
}),*/
|
||||
Obx(() {
|
||||
return DropdownSelection(
|
||||
bgColor: Colors.white,
|
||||
involveClasses: state.involveClasses.value,
|
||||
classData: state.classData.value,
|
||||
call: (AnnotatedClass item) {
|
||||
state.classData.value = item;
|
||||
if (item.grade == -1) state.classData.value = state.defaultClass;
|
||||
logic.getList();
|
||||
});
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -142,8 +219,8 @@ class _FavStudentPageState extends State<FavStudentPage> {
|
|||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
/*showStudentDialog(context,
|
||||
student, groupList);*/
|
||||
showStudentDialog(context,
|
||||
student, state.favList);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,245 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_rx/get_rx.dart';
|
||||
import 'package:making_school_asignment_app/common/job/annotated_class.dart';
|
||||
import 'package:making_school_asignment_app/page/global_widget/MyEmptyWidget.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:photo_view/photo_view_gallery.dart';
|
||||
|
||||
class FavoriteStudentDialog extends StatefulWidget {
|
||||
final HomeworkFavs item;
|
||||
final List group;
|
||||
final Function deleteFav;
|
||||
final Future<bool> Function() confirmDialog;
|
||||
|
||||
const FavoriteStudentDialog({Key? key,
|
||||
required this.item,
|
||||
required this.group,
|
||||
required this.deleteFav,
|
||||
required this.confirmDialog})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<FavoriteStudentDialog> createState() => _FavoriteStudentDialogState();
|
||||
}
|
||||
|
||||
class _FavoriteStudentDialogState extends State<FavoriteStudentDialog> {
|
||||
RxInt defaultIndex = 0.obs;
|
||||
RxList<HomeworkFavs> imageList = RxList();
|
||||
late PageController pageController;
|
||||
late Rx<HomeworkFavs> currentStudent = Rx(HomeworkFavs('','','',-1,-1,'','',-1,'',-1,-1,'',''));
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
currentStudent.value = widget.item;
|
||||
List<HomeworkFavs> list = [];
|
||||
for (var element in widget.group) {
|
||||
for (var item in element['list']) {
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
imageList.value = list;
|
||||
defaultIndex.value =
|
||||
list.indexWhere((element) => element.id == widget.item.id);
|
||||
|
||||
pageController = PageController(initialPage: defaultIndex.value);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
pageController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
height: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height,
|
||||
padding: EdgeInsets.symmetric(vertical: 10.r, horizontal: 14.r),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Obx(() {
|
||||
return Text(
|
||||
'${currentStudent.value.className} ${currentStudent.value
|
||||
.studentName}',
|
||||
style: TextStyle(fontSize: 12.sp, color: Color(0xFF4E73FD)),
|
||||
);
|
||||
}),
|
||||
Expanded(child: Container()),
|
||||
Text(
|
||||
'第${currentStudent.value.questionNo}页',
|
||||
style: TextStyle(fontSize: 12.sp, color: Color(0xFF868686)),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
bool confim = await widget.confirmDialog();
|
||||
if (confim) {
|
||||
widget.deleteFav(currentStudent);
|
||||
imageList.removeAt(defaultIndex.value);
|
||||
if (imageList.isNotEmpty) {
|
||||
if (defaultIndex.value < imageList.length) {
|
||||
currentStudent.value = imageList[defaultIndex.value];
|
||||
} else {
|
||||
currentStudent.value =
|
||||
imageList[defaultIndex.value - 1];
|
||||
defaultIndex = defaultIndex - 1;
|
||||
}
|
||||
} else {
|
||||
currentStudent.value.className = '';
|
||||
currentStudent.value.studentName = '';
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.r),
|
||||
child: Image.asset(
|
||||
'assets/images/favorite_delete_icon.png',
|
||||
width: 22.r,
|
||||
height: 22.r,
|
||||
),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Image.asset(
|
||||
'assets/images/favorite_dialog_close.png',
|
||||
width: 22.r,
|
||||
height: 22.r,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.r,
|
||||
),
|
||||
Obx(() {
|
||||
return imageList.isNotEmpty
|
||||
? Expanded(
|
||||
child: Container(
|
||||
color: Colors.white,
|
||||
width: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width,
|
||||
child: PhotoViewGallery.builder(
|
||||
scrollPhysics: const BouncingScrollPhysics(),
|
||||
builder: (BuildContext context, int index) {
|
||||
final HomeworkFavs item = imageList[index];
|
||||
return PhotoViewGalleryPageOptions(
|
||||
imageProvider: NetworkImage(item.zgtAnswer!),
|
||||
heroAttributes: PhotoViewHeroAttributes(tag: item.id!),
|
||||
);
|
||||
},
|
||||
itemCount: imageList.length,
|
||||
pageController: pageController,
|
||||
onPageChanged: (index) {
|
||||
defaultIndex.value = index;
|
||||
currentStudent.value = imageList[index];
|
||||
},
|
||||
scrollDirection: Axis.horizontal,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.height / 2 - 200.r),
|
||||
child: const MyEmptyWidget(),
|
||||
);
|
||||
}),
|
||||
Obx(() {
|
||||
return imageList.isNotEmpty?Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.r),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (defaultIndex.value > 0) {
|
||||
defaultIndex.value = defaultIndex.value - 1;
|
||||
pageController.jumpToPage(defaultIndex.value);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width:
|
||||
(MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width - 78.r) / 2 - 10.r,
|
||||
height: 28.r,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6.r)),
|
||||
border: Border.all(
|
||||
width: 1.r,
|
||||
color: Color(0xFFCACACA),
|
||||
style: BorderStyle.solid),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'上一页',
|
||||
style: TextStyle(
|
||||
fontSize: 10.r,
|
||||
color: defaultIndex == 0
|
||||
? Color(0xFFCACACA)
|
||||
: Color(0xFF505E6E)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (defaultIndex.value < imageList.length - 1) {
|
||||
defaultIndex.value = defaultIndex.value + 1;
|
||||
pageController.jumpToPage(defaultIndex.value);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width:
|
||||
(MediaQuery
|
||||
.of(context)
|
||||
.size
|
||||
.width - 78.r) / 2 - 10.r,
|
||||
height: 28.r,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(6.r)),
|
||||
border: Border.all(
|
||||
width: 1.r,
|
||||
color: Color(0xFFCACACA),
|
||||
style: BorderStyle.solid),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'下一页',
|
||||
style: TextStyle(
|
||||
fontSize: 10.r,
|
||||
color: defaultIndex == imageList.length - 1
|
||||
? Color(0xFFCACACA)
|
||||
: Color(0xFF505E6E)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
):Container();
|
||||
})
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,8 @@ class DropdownSelection extends StatefulWidget {
|
|||
final List<AnnotatedClass>? involveClasses;
|
||||
final AnnotatedClass? classData;
|
||||
final Function(AnnotatedClass) call;
|
||||
const DropdownSelection({Key? key, required this.involveClasses, required this.classData, required this.call}) : super(key: key);
|
||||
final Color? bgColor;
|
||||
const DropdownSelection({Key? key, required this.involveClasses, required this.classData, required this.call,this.bgColor}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DropdownSelection> createState() => _DropdownSelectionState();
|
||||
|
|
@ -20,9 +21,9 @@ class _DropdownSelectionState extends State<DropdownSelection> {
|
|||
return Container(
|
||||
// width: 200.r,
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.r),
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFF5F5F5),
|
||||
borderRadius: BorderRadius.vertical(
|
||||
decoration: BoxDecoration(
|
||||
color: widget.bgColor ?? const Color(0xFFF5F5F5),
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.elliptical(10, 10),
|
||||
bottom: Radius.elliptical(10, 10),
|
||||
)),
|
||||
|
|
|
|||
Loading…
Reference in New Issue