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.

188 lines
7.7 KiB

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:problem_check_system/controllers/auth_controller.dart';
import 'package:problem_check_system/controllers/problem_controller.dart';
import 'package:problem_check_system/modules/problem/components/date_picker_button.dart';
import 'package:problem_check_system/modules/problem/problem_card.dart';
import 'package:problem_check_system/views/add_problem_page.dart';
class ProblemPage extends StatelessWidget {
ProblemPage({super.key});
final AuthController authController = Get.put(AuthController());
final ProblemController problemController = Get.put(ProblemController());
final List<Map<String, bool>> problemData = [
{"initialBound": false, "initialUploaded": false},
{"initialBound": true, "initialUploaded": true},
{"initialBound": true, "initialUploaded": false},
{"initialBound": false, "initialUploaded": false},
{"initialBound": true, "initialUploaded": true},
{"initialBound": true, "initialUploaded": false},
{"initialBound": false, "initialUploaded": false},
{"initialBound": true, "initialUploaded": true},
{"initialBound": true, "initialUploaded": false},
{"initialBound": false, "initialUploaded": false},
{"initialBound": true, "initialUploaded": true},
{"initialBound": true, "initialUploaded": false},
];
@override
Widget build(BuildContext context) {
return DefaultTabController(
initialIndex: 0,
length: 2,
child: Scaffold(
body: ConstrainedBox(
constraints: BoxConstraints(maxHeight: 812.h),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 375.w,
height: 83.5.h,
alignment: Alignment.bottomLeft,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft, // 从左开始
end: Alignment.centerRight, // 到右结束
colors: [
Color(0xFF418CFC), // 左侧颜色
Color(0xFF3DBFFC), // 右侧颜色
],
),
),
child: TabBar(
indicatorSize: TabBarIndicatorSize.tab,
indicator: BoxDecoration(
// border: const Border(
// bottom: BorderSide(color: Colors.blue, width: 5.0),
// ),
color: const Color(0xfffff7f7),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(60),
),
),
tabs: const [
Tab(text: '问题列表'),
Tab(text: '历史问题列表'),
],
labelStyle: TextStyle(
fontFamily: 'MyFont', // 字体名称
fontWeight: FontWeight.w800, // 字重
fontSize: 14.sp, // 字体大小
),
unselectedLabelStyle: TextStyle(
fontFamily: 'MyFont',
fontWeight: FontWeight.w800,
fontSize: 14.sp,
),
labelColor: Colors.black, // 选中文字颜色
unselectedLabelColor: Colors.white, // 未选中文字颜色
),
),
Expanded(
child: TabBarView(
children: [
Column(
children: [
Container(
margin: EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [DatePickerButton(), DatePickerButton()],
),
),
Expanded(
child: Stack(
children: [
// SingleChildScrollView(
// child: Column(
// children: [
// ...problemData.map((data) {
// return ProblemCard(
// initialBound:
// data["initialBound"] ?? false,
// initialUploaded:
// data["initialUploaded"] ?? false,
// );
// }),
// SizedBox(height: 64.h),
// ],
// ),
// ),
Obx(() {
if (problemController.isLoading.value) {
return Center(
child: CircularProgressIndicator(),
);
}
return ListView.builder(
itemCount: problemController.problems.length,
itemBuilder: (context, index) {
final problem =
problemController.problems[index];
return ProblemCard(problem);
},
);
}),
Positioned(
bottom: 5.h,
right: 160.5.w,
child: FloatingActionButton(
heroTag: "123",
onPressed: () {
Get.to(() => AddProblemPage());
},
shape: CircleBorder(),
backgroundColor: Colors.blue[300],
foregroundColor: Colors.white,
child: const Icon(Icons.add),
),
),
],
),
),
],
),
Obx(() {
if (problemController.isLoading.value) {
return Center(child: CircularProgressIndicator());
}
return ListView.builder(
itemCount: problemController.problems.length,
itemBuilder: (context, index) {
final problem = problemController.problems[index];
return ProblemCard(
problem,
viewType: ProblemCardViewType.checkbox,
);
},
);
}),
],
),
),
],
),
),
floatingActionButton: FloatingActionButton(
heroTag: "abc",
onPressed: () {
print('object');
},
foregroundColor: Colors.white,
backgroundColor: Colors.red[300],
child: const Icon(Icons.file_upload_outlined),
),
),
);
}
}