stats_row.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import 'package:flutter/material.dart';
  2. import 'package:asr_client/models/user_profile.dart';
  3. import 'package:asr_client/theme/app_colors.dart';
  4. class StatsRow extends StatelessWidget {
  5. const StatsRow({super.key, required this.profile});
  6. final UserProfile profile;
  7. @override
  8. Widget build(BuildContext context) {
  9. return Padding(
  10. padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
  11. child: Row(
  12. children: [
  13. _StatCard(
  14. value: profile.monthlyCount.toString(),
  15. label: '本月检测',
  16. color: AppColors.app,
  17. ),
  18. const SizedBox(width: 10),
  19. _StatCard(value: profile.passRate, label: '合格率', color: AppColors.ok),
  20. const SizedBox(width: 10),
  21. _StatCard(
  22. value: profile.activeProjects.toString(),
  23. label: '进行中项目',
  24. color: AppColors.mid,
  25. ),
  26. ],
  27. ),
  28. );
  29. }
  30. }
  31. class _StatCard extends StatelessWidget {
  32. const _StatCard({
  33. required this.value,
  34. required this.label,
  35. required this.color,
  36. });
  37. final String value;
  38. final String label;
  39. final Color color;
  40. @override
  41. Widget build(BuildContext context) {
  42. return Expanded(
  43. child: Container(
  44. padding: const EdgeInsets.symmetric(vertical: 14),
  45. decoration: BoxDecoration(
  46. color: AppColors.card,
  47. borderRadius: BorderRadius.circular(12),
  48. border: Border.all(color: AppColors.line),
  49. ),
  50. child: Column(
  51. children: [
  52. Text(
  53. value,
  54. style: TextStyle(
  55. fontSize: 20,
  56. fontWeight: FontWeight.w800,
  57. color: color,
  58. ),
  59. ),
  60. const SizedBox(height: 2),
  61. Text(
  62. label,
  63. style: const TextStyle(fontSize: 11, color: AppColors.ink3),
  64. ),
  65. ],
  66. ),
  67. ),
  68. );
  69. }
  70. }