list_card.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 (sub.isNotEmpty || (subAmount != null && subAmount!.isNotEmpty)) ...[
  71. const SizedBox(height: 4),
  72. Row(
  73. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  74. children: [
  75. if (sub.isNotEmpty)
  76. Flexible(
  77. child: Text(
  78. sub,
  79. maxLines: 1,
  80. overflow: TextOverflow.ellipsis,
  81. style: TextStyle(fontSize: 13, color: colors.textSecondary),
  82. ),
  83. ),
  84. if (subAmount != null && subAmount!.isNotEmpty)
  85. Text(
  86. subAmount!,
  87. maxLines: 1,
  88. overflow: TextOverflow.ellipsis,
  89. style: TextStyle(
  90. fontSize: 16,
  91. fontWeight: FontWeight.w700,
  92. color: Colors.green,
  93. ),
  94. ),
  95. ],
  96. ),
  97. ],
  98. if (desc.isNotEmpty) ...[
  99. const SizedBox(height: 4),
  100. Text(
  101. desc,
  102. maxLines: 2,
  103. overflow: TextOverflow.ellipsis,
  104. style: TextStyle(fontSize: 14, color: colors.textSecondary),
  105. ),
  106. ],
  107. const SizedBox(height: 8),
  108. Row(
  109. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  110. children: [
  111. Flexible(
  112. child: Text(
  113. date,
  114. maxLines: 1,
  115. overflow: TextOverflow.ellipsis,
  116. style: TextStyle(fontSize: 12, color: colors.textSecondary),
  117. ),
  118. ),
  119. const SizedBox(width: 8),
  120. ?statusTag,
  121. ],
  122. ),
  123. ],
  124. ),
  125. ),
  126. );
  127. }
  128. }