You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

85 lines
2.5 KiB

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/widgets/problem_card.dart';
// todo 使用problem_list_page,填充内容,problem_controller 控制内容
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.selectedUnUploadedProblems.length;
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 Obx(() {
return ListView.builder(
itemCount: controller.unUploadedProblems.length,
itemBuilder: (context, index) {
final problem = controller.unUploadedProblems[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: Obx(
() => ElevatedButton(
onPressed: controller.isUploadEnabled.value
? controller.uploadProblems
: null,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.r),
),
),
child: Text('点击上传'),
),
),
);
}
}