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.

101 lines
2.9 KiB

2 weeks ago
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';
2 weeks ago
class ProblemUploadPage extends GetView<ProblemController> {
const ProblemUploadPage({super.key});
2 weeks ago
@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项');
2 weeks ago
}),
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,
);
2 weeks ago
}
// 构建底部操作栏
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.uploadProblems
: null,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.r),
),
2 weeks ago
),
child: Text('点击上传'),
2 weeks ago
),
),
);
}
Widget uploadProgressWidget() {
return AlertDialog(
title: Text('上传中...'),
content: Obx(() {
final progress = (controller.uploadProgress.value * 100).toInt();
return Column(
mainAxisSize: MainAxisSize.min,
children: [
LinearProgressIndicator(
value: controller.uploadProgress.value,
backgroundColor: Colors.grey[300],
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
),
SizedBox(height: 16),
Text('已完成: $progress%'),
Text(
'已上传: ${controller.unUploadedProblems.length} / ${controller.selectedCount}',
),
],
);
}),
);
}
2 weeks ago
}