|
|
@ -1,4 +1,3 @@ |
|
|
|
// problem_page.dart |
|
|
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
@ -8,12 +7,11 @@ import 'package:problem_check_system/modules/problem/views/widgets/date_picker_b |
|
|
|
import 'package:problem_check_system/modules/problem/views/widgets/problem_card.dart'; |
|
|
|
import 'package:problem_check_system/modules/problem/views/widgets/problem_card.dart'; |
|
|
|
import 'package:problem_check_system/modules/problem/views/problem_form_page.dart'; |
|
|
|
import 'package:problem_check_system/modules/problem/views/problem_form_page.dart'; |
|
|
|
|
|
|
|
|
|
|
|
class ProblemPage extends StatelessWidget { |
|
|
|
class ProblemPage extends GetView<ProblemController> { |
|
|
|
const ProblemPage({super.key}); |
|
|
|
const ProblemPage({super.key}); |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
final ProblemController problemController = Get.find<ProblemController>(); |
|
|
|
|
|
|
|
return DefaultTabController( |
|
|
|
return DefaultTabController( |
|
|
|
initialIndex: 0, |
|
|
|
initialIndex: 0, |
|
|
|
length: 2, |
|
|
|
length: 2, |
|
|
@ -74,58 +72,44 @@ class ProblemPage extends StatelessWidget { |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Expanded( |
|
|
|
Expanded( |
|
|
|
child: Stack( |
|
|
|
child: Obx(() { |
|
|
|
children: [ |
|
|
|
if (controller.isLoading.value) { |
|
|
|
Obx(() { |
|
|
|
return Center(child: CircularProgressIndicator()); |
|
|
|
if (problemController.isLoading.value) { |
|
|
|
} |
|
|
|
return Center( |
|
|
|
|
|
|
|
child: CircularProgressIndicator(), |
|
|
|
return ListView.builder( |
|
|
|
); |
|
|
|
// +1 是为了在列表末尾添加一个额外的“空”项 |
|
|
|
|
|
|
|
itemCount: controller.problems.length + 1, |
|
|
|
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
|
|
|
// 如果是最后一个“空”项,返回一个 SizedBox |
|
|
|
|
|
|
|
if (index == controller.problems.length) { |
|
|
|
|
|
|
|
return SizedBox(height: 79.5.h); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ListView.builder( |
|
|
|
// 否则,返回正常的列表项 |
|
|
|
itemCount: problemController.problems.length, |
|
|
|
final problem = controller.problems[index]; |
|
|
|
itemBuilder: (context, index) { |
|
|
|
return _buildSwipeableProblemCard( |
|
|
|
final problem = |
|
|
|
problem, |
|
|
|
problemController.problems[index]; |
|
|
|
controller, |
|
|
|
return _buildSwipeableProblemCard( |
|
|
|
|
|
|
|
problem, |
|
|
|
|
|
|
|
problemController, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
}), |
|
|
|
}, |
|
|
|
Positioned( |
|
|
|
); |
|
|
|
bottom: 5.h, |
|
|
|
}), |
|
|
|
right: 160.5.w, |
|
|
|
|
|
|
|
child: FloatingActionButton( |
|
|
|
|
|
|
|
heroTag: "123", |
|
|
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
|
|
Get.to(() => ProblemFormPage()); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
shape: CircleBorder(), |
|
|
|
|
|
|
|
backgroundColor: Colors.blue[300], |
|
|
|
|
|
|
|
foregroundColor: Colors.white, |
|
|
|
|
|
|
|
child: const Icon(Icons.add), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
Obx(() { |
|
|
|
Obx(() { |
|
|
|
if (problemController.isLoading.value) { |
|
|
|
if (controller.isLoading.value) { |
|
|
|
return Center(child: CircularProgressIndicator()); |
|
|
|
return Center(child: CircularProgressIndicator()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ListView.builder( |
|
|
|
return ListView.builder( |
|
|
|
itemCount: problemController.problems.length, |
|
|
|
itemCount: controller.problems.length, |
|
|
|
itemBuilder: (context, index) { |
|
|
|
itemBuilder: (context, index) { |
|
|
|
final problem = problemController.problems[index]; |
|
|
|
final problem = controller.problems[index]; |
|
|
|
return _buildSwipeableProblemCard( |
|
|
|
return _buildSwipeableProblemCard( |
|
|
|
problem, |
|
|
|
problem, |
|
|
|
problemController, |
|
|
|
controller, |
|
|
|
viewType: ProblemCardViewType.checkbox, |
|
|
|
viewType: ProblemCardViewType.checkbox, |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -137,20 +121,46 @@ class ProblemPage extends StatelessWidget { |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
floatingActionButton: Obx(() { |
|
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, |
|
|
|
final bool isOnline = problemController.isOnline.value; |
|
|
|
floatingActionButton: Stack( |
|
|
|
return FloatingActionButton( |
|
|
|
children: [ |
|
|
|
heroTag: "abc", |
|
|
|
Align( |
|
|
|
onPressed: isOnline |
|
|
|
alignment: Alignment.bottomCenter, |
|
|
|
? () => problemController.uploadAllUnuploaded() |
|
|
|
child: FloatingActionButton( |
|
|
|
: null, |
|
|
|
heroTag: "btn_add", |
|
|
|
foregroundColor: Colors.white, |
|
|
|
onPressed: () { |
|
|
|
backgroundColor: isOnline ? Colors.red[300] : Colors.grey[400], |
|
|
|
Get.to(() => ProblemFormPage()); |
|
|
|
child: Icon( |
|
|
|
}, |
|
|
|
isOnline ? Icons.file_upload_outlined : Icons.cloud_off_outlined, |
|
|
|
shape: CircleBorder(), |
|
|
|
|
|
|
|
backgroundColor: Colors.blue[300], |
|
|
|
|
|
|
|
foregroundColor: Colors.white, |
|
|
|
|
|
|
|
child: const Icon(Icons.add), |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
Positioned( |
|
|
|
}), |
|
|
|
bottom: 56.h, // 设置距离底部100像素 |
|
|
|
|
|
|
|
right: 27.w, // 设置距离右侧16像素(通常的浮动按钮默认位置) |
|
|
|
|
|
|
|
child: Obx(() { |
|
|
|
|
|
|
|
final bool isOnline = controller.isOnline.value; |
|
|
|
|
|
|
|
return FloatingActionButton( |
|
|
|
|
|
|
|
heroTag: "btn_upload", |
|
|
|
|
|
|
|
onPressed: isOnline |
|
|
|
|
|
|
|
? () => controller.uploadAllUnuploaded() |
|
|
|
|
|
|
|
: null, |
|
|
|
|
|
|
|
foregroundColor: Colors.white, |
|
|
|
|
|
|
|
backgroundColor: isOnline |
|
|
|
|
|
|
|
? Colors.red[300] |
|
|
|
|
|
|
|
: Colors.grey[400], |
|
|
|
|
|
|
|
child: Icon( |
|
|
|
|
|
|
|
isOnline |
|
|
|
|
|
|
|
? Icons.file_upload_outlined |
|
|
|
|
|
|
|
: Icons.cloud_off_outlined, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|