import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:problem_check_system/app/routes/app_routes.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/widgets/current_filter_bar.dart'; import 'package:problem_check_system/modules/problem/views/widgets/history_filter_bar.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(0xfff7f7f7), 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: Color(0xfff7f7f7), ), ), Expanded( child: TabBarView( controller: controller.tabController, children: [ // 问题列表 Tab DecoratedBox( decoration: BoxDecoration(color: Color(0xfff7f7f7)), child: Column( children: [ CurrentFilterBar(), Expanded( child: // 使用通用列表组件 ProblemListPage( problemsToShow: controller.problems, viewType: ProblemCardViewType.buttons, ), ), ], ), ), // 历史问题列表 Tab DecoratedBox( decoration: BoxDecoration(color: Color(0xfff7f7f7)), child: Column( children: [ HistoryFilterBar(), Expanded( child: // 使用通用列表组件 ProblemListPage( problemsToShow: controller.historyProblems, viewType: ProblemCardViewType.buttons, ), ), ], ), ), ], ), ), ], ), 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: controller.toProblemFormPageAndRefresh, 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.showUploadPage() : null, foregroundColor: Colors.white, backgroundColor: isOnline ? Colors.red[300] : Colors.grey[400], child: Icon( isOnline ? Icons.file_upload_outlined : Icons.cloud_off_outlined, ), ), ), ); }), ], ), ), ); } }