import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:problem_check_system/modules/problem/custom_button.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart'; class ProblemCard extends StatelessWidget { final bool initialBound; final bool initialUploaded; final ProblemCardController controller; ProblemCard({ super.key, required this.initialBound, required this.initialUploaded, }) : controller = ProblemCardController( initialBound: initialBound, initialUploaded: initialUploaded, ); @override Widget build(BuildContext context) { return Card( margin: EdgeInsets.symmetric(vertical: 5.h, horizontal: 9.w), child: Column( mainAxisSize: MainAxisSize.min, children: [ ListTile( leading: Image.asset( 'assets/images/problem_preview.png', fit: BoxFit.contain, // 防止图片拉伸 ), title: Text( '问题描述', style: TextStyle(fontSize: 16.sp), // 动态文字大小 ), subtitle: LayoutBuilder( builder: (context, constraints) { return Text( '硫磺库内南侧地面上存放了阀门、消防水带等物品;12#库存放了脱模剂、愈合成催化剂省略字省略字省略字省略字...', maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14.sp), // 适配设备 ); }, ), ), SizedBox(height: 8.h), Row( children: [ SizedBox(width: 16.w), Row( children: [ Icon(Icons.location_on, color: Colors.grey, size: 16.h), SizedBox(width: 8.w), Text( '汽车机厂房作业区1-C', // 替换为实际文本 style: TextStyle(fontSize: 12.sp), ), ], ), SizedBox(width: 16.w), Row( children: [ Icon(Icons.access_time, color: Colors.grey, size: 16.h), SizedBox(width: 8.w), Text( '2025-07-31 15:30:29', // 替换为实际时间文本 style: TextStyle(fontSize: 12.sp), ), ], ), ], ), SizedBox(height: 8.h), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox(width: 16.w), Obx( () => Wrap( spacing: 8, children: [ controller.isUploaded.value ? TDTag('已上传', isLight: true, theme: TDTagTheme.success) : TDTag('未上传', isLight: true, theme: TDTagTheme.danger), controller.isBound.value ? TDTag('已绑定', isLight: true, theme: TDTagTheme.primary) : TDTag( '未绑定', isLight: true, theme: TDTagTheme.warning, ), ], ), ), SizedBox(width: 100.w), Row( children: [ CustomButton( text: '修改', // 按钮上的文字 onTap: () { // 点击事件逻辑 print('点击修改按钮'); }, ), SizedBox(width: 8.w), CustomButton( text: '查看', // 按钮上的文字 onTap: () { // 点击事件逻辑 print('点击查看按钮'); }, ), ], ), ], ), ], ), ); } } class ProblemCardController extends GetxController { // 是否绑定 var isBound = false.obs; // 是否上传 var isUploaded = false.obs; // 构造函数传入参数 ProblemCardController({ bool initialBound = false, bool initialUploaded = false, }) { isBound.value = initialBound; isUploaded.value = initialUploaded; } }