Browse Source

update : 企业卡片

dev
徐振升 1 week ago
parent
commit
59850210c7
  1. 6
      lib/app/core/models/sync_status.dart
  2. 285
      lib/app/features/enterprise/presentation/pages/widgets/enterprise_card.dart
  3. 85
      lib/app/features/enterprise/presentation/pages/widgets/unified_enterprise_card.dart

6
lib/app/core/models/sync_status.dart

@ -25,11 +25,11 @@ extension SyncStatusExtension on SyncStatus {
case SyncStatus.synced: case SyncStatus.synced:
return '已同步'; return '已同步';
case SyncStatus.pendingCreate: case SyncStatus.pendingCreate:
return '未同步-待新建'; return '待新建';
case SyncStatus.pendingUpdate: case SyncStatus.pendingUpdate:
return '未同步-待更新'; return '待更新';
case SyncStatus.pendingDelete: case SyncStatus.pendingDelete:
return '未同步-待删除'; return '待删除';
case SyncStatus.untracked: case SyncStatus.untracked:
return '未跟踪'; return '未跟踪';
// default // default

285
lib/app/features/enterprise/presentation/pages/widgets/enterprise_card.dart

@ -1,285 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:problem_check_system/app/core/extensions/datetime_extension.dart';
import 'package:problem_check_system/app/core/models/sync_status.dart';
import 'package:problem_check_system/app/features/enterprise/domain/entities/enterprise_list_item.dart';
//
class EnterpriseCard extends StatelessWidget {
final EnterpriseListItem enterpriseListItem;
final bool isSelected;
final VoidCallback? onTap;
final Widget? trailing;
final Widget? bottomAction;
const EnterpriseCard({
super.key,
required this.enterpriseListItem,
this.isSelected = false,
this.onTap,
this.trailing,
this.bottomAction,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
// 1 Container padding
// padding: EdgeInsets.only(...), // <---
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12.r),
border: Border.all(color: Colors.grey.shade300, width: 1.w),
),
// 2使 Clip.antiAlias
clipBehavior: Clip.antiAlias,
child: Stack(
// Stack Container
children: [
// --- ---
// 3使 Padding Stack
Padding(
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
top: 16.h,
// padding
bottom: 0.h,
),
child: Column(
// Column
mainAxisSize: MainAxisSize.min,
children: [
_buildTopSection(),
SizedBox(height: 12.h),
_buildMiddleSection(),
SizedBox(height: 12.h),
_buildBottomSection(context),
],
),
),
Positioned(
bottom: 0, //
right: 0, //
child: Row(
children: [
// --- ---
TextButton.icon(
onPressed: () {},
icon: Icon(Icons.edit_outlined, size: 16.sp),
label: Text('修改信息', style: TextStyle(fontSize: 9.5.sp)),
style: TextButton.styleFrom(
foregroundColor: Colors.grey.shade600,
padding: EdgeInsets.symmetric(
horizontal: 16.w,
vertical: 8.h,
),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, 0),
),
),
// --- ---
ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF42A5F5),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12.r),
//
// bottomRight: Radius.circular(12.r),
),
),
padding: EdgeInsets.symmetric(
horizontal: 16.w,
vertical: 8.h,
),
// elevation: 0, //
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
minimumSize: const Size(0, 0),
),
child: Text(
"查看问题",
style: TextStyle(
fontSize: 13.sp,
fontWeight: FontWeight.w500,
),
),
),
],
),
),
],
),
),
);
}
///
Widget _buildTopSection() {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'企业名称',
style: TextStyle(
fontSize: 9.sp,
color: Colors.grey.shade500,
), // .sp
),
SizedBox(height: 4.h), // .h
Text(
enterpriseListItem.enterprise.name,
style: TextStyle(
fontSize: 12.5.sp,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'企业类型',
style: TextStyle(fontSize: 9.sp, color: Colors.grey.shade500),
),
SizedBox(height: 4.h),
Text(
enterpriseListItem.enterprise.type,
style: TextStyle(
fontSize: 12.5.sp,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
],
),
// SizedBox(width: 8.w),
Container(
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 3.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.r),
border: Border.all(color: Colors.red.shade400, width: 1.w),
),
child: Text(
enterpriseListItem.enterprise.syncStatus == SyncStatus.synced
? '信息已上传'
: '信息未上传',
style: TextStyle(fontSize: 7.sp, color: Colors.red.shade400),
),
),
],
);
}
///
Widget _buildMiddleSection() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.description_outlined, color: Colors.grey, size: 16.sp),
SizedBox(width: 4.w),
Text(
'问题总数: ',
style: TextStyle(fontSize: 12.sp, color: Colors.grey),
),
Text(
enterpriseListItem.totalProblems.toString(),
style: TextStyle(
fontSize: 12.5.sp,
color: Colors.black87,
fontWeight: FontWeight.w500,
),
),
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(Icons.access_time, color: Colors.grey, size: 16.sp),
Text(
'创建时间: ${enterpriseListItem.enterprise.creationTime.toDateTimeString()}',
style: TextStyle(fontSize: 12.sp, color: Colors.grey),
),
],
),
],
);
}
///
Widget _buildBottomSection(BuildContext context) {
return Row(
children: [
_buildTag(
text: '已上传 ${enterpriseListItem.uploadedProblems}',
textColor: Colors.blue.shade700,
backgroundColor: Colors.blue.shade50,
),
SizedBox(width: 8.w),
_buildTag(
text: '未上传 ${enterpriseListItem.pendingProblems}',
textColor: Colors.red.shade600,
backgroundColor: Colors.red.shade50,
),
const Spacer(),
// Theme(
// data: Theme.of(context).copyWith(
// checkboxTheme: CheckboxThemeData(
// // padding
// materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
// // ()
// visualDensity: VisualDensity.compact,
// ),
// ),
// child: Checkbox(
// value: isSelected,
// onChanged: onSelectionChanged,
// materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
// visualDensity: VisualDensity.compact,
// ),
// ),
],
);
}
///
Widget _buildTag({
required String text,
required Color textColor,
required Color backgroundColor,
}) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 6.w, vertical: 2.h),
decoration: BoxDecoration(
color: backgroundColor,
// borderRadius: BorderRadius.circular(4.r),
// border: Border.all(color: textColor.withAlpha(128), width: 1.w),
),
child: Text(
text,
style: TextStyle(
color: textColor,
fontSize: 10.sp,
fontWeight: FontWeight.w500,
),
),
);
}
}

85
lib/app/features/enterprise/presentation/pages/widgets/unified_enterprise_card.dart

@ -73,50 +73,57 @@ class UnifiedEnterpriseCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Column( Expanded(
crossAxisAlignment: CrossAxisAlignment.start, child: Column(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Text( children: [
'企业名称', Text(
style: TextStyle( '企业名称',
fontSize: 9.sp, style: TextStyle(
color: Colors.grey.shade500, fontSize: 9.sp,
), // .sp color: Colors.grey.shade500,
), ), // .sp
SizedBox(height: 4.h), // .h
Text(
enterpriseListItem.enterprise.name,
style: TextStyle(
fontSize: 12.5.sp,
fontWeight: FontWeight.w500,
color: Colors.black87,
), ),
overflow: TextOverflow.ellipsis, SizedBox(height: 4.h), // .h
), Text(
], enterpriseListItem.enterprise.name,
style: TextStyle(
fontSize: 12.5.sp,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
],
),
), ),
SizedBox(width: 8.w),
Column( SizedBox(
crossAxisAlignment: CrossAxisAlignment.start, width: 64.w,
children: [ child: Column(
Text( crossAxisAlignment: CrossAxisAlignment.start,
'企业类型', children: [
style: TextStyle(fontSize: 9.sp, color: Colors.grey.shade500), Text(
), '企业类型',
SizedBox(height: 4.h), style: TextStyle(fontSize: 9.sp, color: Colors.grey.shade500),
Text(
enterpriseListItem.enterprise.type,
style: TextStyle(
fontSize: 12.5.sp,
fontWeight: FontWeight.w500,
color: Colors.black87,
), ),
overflow: TextOverflow.ellipsis, SizedBox(height: 4.h),
), Text(
], enterpriseListItem.enterprise.type,
style: TextStyle(
fontSize: 12.5.sp,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
overflow: TextOverflow.ellipsis,
),
],
),
), ),
// SizedBox(width: 8.w),
SizedBox(width: 16.w),
Container( Container(
// width: 30.w,
padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 3.h), padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 3.h),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.r), borderRadius: BorderRadius.circular(8.r),

Loading…
Cancel
Save