|
|
|
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_upload_controller.dart';
|
|
|
|
import 'package:problem_check_system/modules/problem/views/widgets/problem_card.dart';
|
|
|
|
|
|
|
|
class ProblemUploadPage extends StatelessWidget {
|
|
|
|
ProblemUploadPage({super.key});
|
|
|
|
|
|
|
|
final ProblemUploadController controller = Get.put(ProblemUploadController());
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: _buildAppBar(),
|
|
|
|
body: _buildBody(),
|
|
|
|
bottomNavigationBar: _buildBottomBar(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 构建顶部 AppBar
|
|
|
|
PreferredSizeWidget _buildAppBar() {
|
|
|
|
return AppBar(
|
|
|
|
title: Obx(() {
|
|
|
|
final selectedCount = controller.selectedProblems.length;
|
|
|
|
return Text(selectedCount > 0 ? '已选择$selectedCount项' : '问题上传');
|
|
|
|
}),
|
|
|
|
centerTitle: true,
|
|
|
|
leading: IconButton(icon: Icon(Icons.close), onPressed: () => Get.back()),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: controller.selectAll,
|
|
|
|
child: Obx(
|
|
|
|
() => Text(
|
|
|
|
controller.allSelected.value ? '取消全选' : '全选',
|
|
|
|
style: TextStyle(color: Colors.blue),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 构建页面主体
|
|
|
|
Widget _buildBody() {
|
|
|
|
return Obx(() {
|
|
|
|
return ListView.builder(
|
|
|
|
itemCount: controller.problems.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final problem = controller.problems[index];
|
|
|
|
return ProblemCard(
|
|
|
|
problem,
|
|
|
|
// 传递视图类型,显示 Checkbox
|
|
|
|
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: ElevatedButton(
|
|
|
|
onPressed: controller.isUploadEnabled.value
|
|
|
|
? controller.uploadProblems
|
|
|
|
: null,
|
|
|
|
child: Text('点击上传'),
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
backgroundColor: Colors.blue,
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(8.r),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|