|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:problem_check_system/app/core/domain/entities/sync_status.dart'; |
|
|
|
|
import 'package:problem_check_system/app/core/extensions/datetime_extension.dart'; |
|
|
|
|
import 'package:problem_check_system/app/features/enterprise/domain/entities/enterprise_list_item.dart'; |
|
|
|
|
import 'package:tdesign_flutter/tdesign_flutter.dart'; |
|
|
|
|
@ -22,6 +23,8 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
final bool isDeleted = |
|
|
|
|
enterpriseListItem.enterprise.syncStatus == SyncStatus.pendingDelete; |
|
|
|
|
return Card( |
|
|
|
|
elevation: isSelected ? 4.0 : .2, |
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
@ -33,6 +36,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
// [关键 1] 必须剪裁,才能让按钮的形状与卡片边缘完美融合 |
|
|
|
|
clipBehavior: Clip.antiAlias, |
|
|
|
|
margin: EdgeInsets.zero, |
|
|
|
|
color: isDeleted ? Colors.grey[200] : Theme.of(context).cardColor, |
|
|
|
|
child: InkWell( |
|
|
|
|
onTap: onTap, |
|
|
|
|
// [关键 2] 使用 Column 作为主布局 |
|
|
|
|
@ -48,9 +52,9 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
_buildTopSection(), |
|
|
|
|
_buildTopSection(isDeleted), |
|
|
|
|
SizedBox(height: 12.h), |
|
|
|
|
_buildMiddleSection(), |
|
|
|
|
_buildMiddleSection(isDeleted), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
@ -60,7 +64,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
// --- 区域 2: 底部的操作栏 --- |
|
|
|
|
// [关键 3] 这一行是整个布局的核心 |
|
|
|
|
if (actions != null) _buildBottomActionRow(), |
|
|
|
|
if (actions != null) _buildBottomActionRow(isDeleted), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
@ -68,7 +72,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// 构建顶部区域:企业名称、类型和状态 |
|
|
|
|
Widget _buildTopSection() { |
|
|
|
|
Widget _buildTopSection(bool isDeleted) { |
|
|
|
|
return Row( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
@ -90,7 +94,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.5.sp, |
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
color: Colors.black87, |
|
|
|
|
color: isDeleted ? Colors.grey : Colors.black87, |
|
|
|
|
), |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
), |
|
|
|
|
@ -113,7 +117,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.5.sp, |
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
color: Colors.black87, |
|
|
|
|
color: isDeleted ? Colors.grey : Colors.black87, |
|
|
|
|
), |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
), |
|
|
|
|
@ -145,7 +149,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// 构建中间区域:问题总数和创建时间 |
|
|
|
|
Widget _buildMiddleSection() { |
|
|
|
|
Widget _buildMiddleSection(bool isDeleted) { |
|
|
|
|
return Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
|
children: [ |
|
|
|
|
@ -162,8 +166,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
enterpriseListItem.totalProblems.toString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.5.sp, |
|
|
|
|
color: Colors.black87, |
|
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
|
color: isDeleted ? Colors.grey : Colors.black87, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
@ -173,9 +176,16 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
children: [ |
|
|
|
|
Icon(Icons.access_time, color: Colors.grey, size: 16.sp), |
|
|
|
|
Text( |
|
|
|
|
'创建时间: ${enterpriseListItem.enterprise.creationTime.toDateTimeString()}', |
|
|
|
|
'创建时间:', |
|
|
|
|
style: TextStyle(fontSize: 12.sp, color: Colors.grey), |
|
|
|
|
), |
|
|
|
|
Text( |
|
|
|
|
enterpriseListItem.enterprise.creationTime.toDateTimeString(), |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: isDeleted ? Colors.grey : Colors.black87, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
@ -183,7 +193,7 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// 构建底部的“标签+操作”行 |
|
|
|
|
Widget _buildBottomActionRow() { |
|
|
|
|
Widget _buildBottomActionRow(bool isDeleted) { |
|
|
|
|
return Row( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end, |
|
|
|
|
children: [ |
|
|
|
|
@ -194,14 +204,18 @@ class UnifiedEnterpriseCard extends StatelessWidget {
|
|
|
|
|
children: [ |
|
|
|
|
TDTag( |
|
|
|
|
'已上传 ${enterpriseListItem.uploadedProblems}', |
|
|
|
|
textColor: Colors.blue, |
|
|
|
|
backgroundColor: Colors.blue.withAlpha(20), |
|
|
|
|
textColor: isDeleted ? Colors.grey : Colors.blue, |
|
|
|
|
backgroundColor: isDeleted |
|
|
|
|
? Colors.grey.withAlpha(20) |
|
|
|
|
: Colors.blue.withAlpha(20), |
|
|
|
|
), |
|
|
|
|
SizedBox(width: 8.w), |
|
|
|
|
TDTag( |
|
|
|
|
'未上传 ${enterpriseListItem.pendingProblems}', |
|
|
|
|
textColor: Colors.red, |
|
|
|
|
backgroundColor: Colors.red.withAlpha(20), |
|
|
|
|
textColor: isDeleted ? Colors.grey : Colors.red, |
|
|
|
|
backgroundColor: isDeleted |
|
|
|
|
? Colors.grey.withAlpha(20) |
|
|
|
|
: Colors.red.withAlpha(20), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
|