|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:problem_check_system/modules/problem/controllers/problem_controller.dart';
|
|
|
|
import 'package:problem_check_system/modules/problem/views/problem_list_page.dart';
|
|
|
|
import 'package:problem_check_system/modules/problem/views/widgets/problem_card.dart';
|
|
|
|
|
|
|
|
class ProblemUploadPage extends GetView<ProblemController> {
|
|
|
|
const ProblemUploadPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: _buildAppBar(),
|
|
|
|
body: _buildBody(),
|
|
|
|
bottomNavigationBar: _buildBottomBar(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
PreferredSizeWidget _buildAppBar() {
|
|
|
|
return AppBar(
|
|
|
|
title: Obx(() {
|
|
|
|
final selectedCount = controller.selectedCount;
|
|
|
|
return Text('已选择$selectedCount项');
|
|
|
|
}),
|
|
|
|
centerTitle: true,
|
|
|
|
// leading: IconButton(
|
|
|
|
// icon: Icon(Icons.close),
|
|
|
|
// onPressed: () {
|
|
|
|
// Get.back();// TODO 返回之后需要刷新卡片列表
|
|
|
|
// controller.clearSelection();
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
actions: [
|
|
|
|
Obx(
|
|
|
|
() => TextButton(
|
|
|
|
onPressed: controller.unUploadedProblems.isNotEmpty
|
|
|
|
? controller.selectAll
|
|
|
|
: null,
|
|
|
|
child: Text(
|
|
|
|
controller.allSelected.value ? '取消全选' : '全选',
|
|
|
|
style: TextStyle(
|
|
|
|
color: controller.unUploadedProblems.isNotEmpty
|
|
|
|
? Colors.blue
|
|
|
|
: Colors.grey,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildBody() {
|
|
|
|
return Obx(() {
|
|
|
|
if (controller.unUploadedProblems.isEmpty) {
|
|
|
|
return Center(
|
|
|
|
child: Text('暂无未上传的问题', style: TextStyle(fontSize: 16.sp)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return ProblemListPage(
|
|
|
|
problemsToShow: controller.unUploadedProblems,
|
|
|
|
viewType: ProblemCardViewType.checkbox,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildBottomBar() {
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.all(16.w),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
border: Border(top: BorderSide(color: Colors.grey.shade300)),
|
|
|
|
),
|
|
|
|
child: Obx(
|
|
|
|
() => ElevatedButton(
|
|
|
|
onPressed: controller.selectedCount > 0
|
|
|
|
? controller.handleUpload
|
|
|
|
: null,
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
backgroundColor: Colors.blue,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
|
|
),
|
|
|
|
minimumSize: Size(double.infinity, 48.h),
|
|
|
|
),
|
|
|
|
child: Text('点击上传 (${controller.selectedCount})'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|