list_card.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import 'package:flutter/material.dart';
  2. import '../../core/theme/app_colors_extension.dart';
  3. /// Pencil Component/ListCard — 列表卡片(报销申请列表等)
  4. class ListCard extends StatelessWidget {
  5. final String cardNo;
  6. final String? applicant;
  7. final String? description;
  8. final String amount;
  9. final Color? amountColor;
  10. final String? subAmount;
  11. final String date;
  12. final Widget? statusTag;
  13. final VoidCallback? onTap;
  14. const ListCard({
  15. super.key,
  16. required this.cardNo,
  17. this.applicant,
  18. this.description,
  19. required this.amount,
  20. this.amountColor,
  21. this.subAmount,
  22. required this.date,
  23. this.statusTag,
  24. this.onTap,
  25. });
  26. @override
  27. Widget build(BuildContext context) {
  28. final colors = Theme.of(context).extension<AppColorsExtension>()!;
  29. final desc = description ?? '';
  30. final sub = applicant ?? '';
  31. return GestureDetector(
  32. onTap: onTap,
  33. child: Container(
  34. padding: const EdgeInsets.all(12),
  35. decoration: BoxDecoration(
  36. color: colors.bgCard,
  37. borderRadius: BorderRadius.circular(8),
  38. ),
  39. child: Column(
  40. crossAxisAlignment: CrossAxisAlignment.start,
  41. children: [
  42. Row(
  43. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  44. children: [
  45. Flexible(
  46. child: Text(
  47. cardNo,
  48. maxLines: 1,
  49. overflow: TextOverflow.ellipsis,
  50. style: TextStyle(
  51. fontSize: 14,
  52. fontWeight: FontWeight.w600,
  53. color: colors.textPrimary,
  54. ),
  55. ),
  56. ),
  57. const SizedBox(width: 12),
  58. Text(
  59. amount,
  60. maxLines: 1,
  61. overflow: TextOverflow.ellipsis,
  62. style: TextStyle(
  63. fontSize: 16,
  64. fontWeight: FontWeight.w700,
  65. color: amountColor ?? colors.amountPrimary,
  66. ),
  67. ),
  68. ],
  69. ),
  70. if (subAmount != null && subAmount!.isNotEmpty) ...[
  71. const SizedBox(height: 2),
  72. Align(
  73. alignment: Alignment.centerRight,
  74. child: Text(
  75. subAmount!,
  76. maxLines: 1,
  77. overflow: TextOverflow.ellipsis,
  78. style: TextStyle(
  79. fontSize: 16,
  80. fontWeight: FontWeight.w700,
  81. color: Colors.green,
  82. ),
  83. ),
  84. ),
  85. ],
  86. if (sub.isNotEmpty) ...[
  87. const SizedBox(height: 4),
  88. Text(
  89. sub,
  90. maxLines: 1,
  91. overflow: TextOverflow.ellipsis,
  92. style: TextStyle(fontSize: 13, color: colors.textSecondary),
  93. ),
  94. ],
  95. if (desc.isNotEmpty) ...[
  96. const SizedBox(height: 4),
  97. Text(
  98. desc,
  99. maxLines: 2,
  100. overflow: TextOverflow.ellipsis,
  101. style: TextStyle(fontSize: 14, color: colors.textSecondary),
  102. ),
  103. ],
  104. const SizedBox(height: 8),
  105. Row(
  106. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  107. children: [
  108. Flexible(
  109. child: Text(
  110. date,
  111. maxLines: 1,
  112. overflow: TextOverflow.ellipsis,
  113. style: TextStyle(fontSize: 12, color: colors.textSecondary),
  114. ),
  115. ),
  116. const SizedBox(width: 8),
  117. ?statusTag,
  118. ],
  119. ),
  120. ],
  121. ),
  122. ),
  123. );
  124. }
  125. }