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'; // 导入修正后的 ProblemListPage import 'package:problem_check_system/modules/problem/views/problem_form_page.dart'; import 'package:problem_check_system/modules/problem/views/widgets/custom_data_range_dropdown.dart'; import 'package:problem_check_system/modules/problem/views/widgets/custom_string_dropdown.dart'; import 'package:problem_check_system/modules/problem/views/widgets/problem_card.dart'; // 导入自定义下拉菜单 class ProblemPage extends GetView { const ProblemPage({super.key}); @override Widget build(BuildContext context) { return DefaultTabController( initialIndex: 0, length: 2, child: Scaffold( body: 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( controller: controller.tabController, indicatorSize: TabBarIndicatorSize.tab, indicator: const BoxDecoration( color: 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( controller: controller.tabController, children: [ // 问题列表 Tab Column( children: [ Container( padding: EdgeInsets.symmetric(horizontal: 17.w), child: Row( children: [ CustomDateRangeDropdown( selectedRange: controller.selectedDateRange, onChanged: (rangeValue) { controller.updateFiltersAndLoadProblems( newDateRange: rangeValue, ); }, ), CustomStringDropdown( selectedValue: controller.selectedUploadStatus, items: const ['全部', '未上传', '已上传'], onChanged: (uploadValue) { controller.updateFiltersAndLoadProblems( newUploadStatus: uploadValue, ); }, ), CustomStringDropdown( selectedValue: controller.selectedBindingStatus, items: const ['全部', '未绑定', '已绑定'], onChanged: (bindingValue) { controller.updateFiltersAndLoadProblems( newBindingStatus: bindingValue, ); }, ), ], ), ), Expanded( child: // 使用通用列表组件 ProblemListPage( problemsToShow: controller.problems, viewType: ProblemCardViewType.buttons, ), ), ], ), // 历史问题列表 Tab Column( children: [ Container( padding: EdgeInsets.symmetric(horizontal: 17.w), child: Row( children: [ CustomDateRangeDropdown( selectedRange: controller.selectedDateRange, onChanged: (rangeValue) { controller.updateFiltersAndLoadProblems( newDateRange: rangeValue, ); }, ), CustomStringDropdown( selectedValue: controller.selectedUploadStatus, items: const ['全部', '未上传', '已上传'], onChanged: (uploadValue) { controller.updateFiltersAndLoadProblems( newUploadStatus: uploadValue, ); }, ), CustomStringDropdown( selectedValue: controller.selectedBindingStatus, items: const ['全部', '未绑定', '已绑定'], onChanged: (bindingValue) { controller.updateFiltersAndLoadProblems( newBindingStatus: bindingValue, ); }, ), ], ), ), Expanded( child: // 使用通用列表组件 ProblemListPage( problemsToShow: controller.problems, viewType: ProblemCardViewType.buttons, ), ), ], ), ], ), ), ], ), // floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, // floatingActionButton: Stack( // children: [ // Align( // alignment: Alignment.bottomCenter, // child: FloatingActionButton( // heroTag: "btn_add", // onPressed: () { // Get.to(() => ProblemFormPage()); // }, // shape: const CircleBorder(), // backgroundColor: Colors.blue[300], // foregroundColor: Colors.white, // child: const Icon(Icons.add), // ), // ), // Positioned( // right: controller.fabPosition.value.dx, //27.w, // bottom: controller.fabPosition.value.dy, //56.h, // child: Obx(() { // final bool isOnline = controller.isOnline.value; // return GestureDetector( // onPanUpdate: (details) { // // 调用控制器中的方法来更新位置 // controller.updatePosition(details.delta); // }, // child: 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, // ), // ), // ); // }), // ), // ], // ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, // 使用 Stack 统一管理所有浮动按钮 floatingActionButton: Stack( children: [ // 固定位置的 "添加" 按钮 // 使用 Align 和 Positioned Align( alignment: Alignment.bottomCenter, child: Padding( padding: EdgeInsets.only(bottom: 24.h), // 底部间距 child: FloatingActionButton( heroTag: "btn_add", onPressed: () { Get.to(() => ProblemFormPage()); }, shape: const CircleBorder(), backgroundColor: Colors.blue[300], foregroundColor: Colors.white, child: const Icon(Icons.add), ), ), ), // 可拖动的 "上传" 按钮 Obx(() { final isOnline = controller.isOnline.value; return Positioned( // 使用正确的坐标,left/right 对应 dx,top/bottom 对应 dy left: controller.fabUploadPosition.value.dx, top: controller.fabUploadPosition.value.dy, child: GestureDetector( onPanUpdate: (details) { // 调用控制器中的方法来更新位置 controller.updateFabUploadPosition(details.delta); }, onPanEnd: (details) { // 拖动结束后调用吸附方法 controller.snapToEdge(); }, child: 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, ), ), ), ); }), ], ), ), ); } }