|
|
|
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(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 构建顶部 AppBar
|
|
|
|
PreferredSizeWidget _buildAppBar() {
|
|
|
|
return AppBar(
|
|
|
|
title: Obx(() {
|
|
|
|
final selectedCount = controller.selectedCount;
|
|
|
|
return Text('已选择$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 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),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text('点击上传'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|