智慧水务管理系统 - 精河县供水工程综合管理平台

revenue_page.dart 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flutter/material.dart';
  2. import 'package:water_management_system/utils/constants.dart';
  3. import 'package:water_management_system/widgets/custom_card.dart';
  4. class RevenuePage extends StatefulWidget {
  5. const RevenuePage({super.key});
  6. @override State<RevenuePage> createState() => _RevenuePageState();
  7. }
  8. class _RevenuePageState extends State<RevenuePage> {
  9. final List<Map<String, dynamic>> _bills = [
  10. {'id': 'R001', 'type': '抄表', 'address': '幸福路12号', 'amount': 56.30, 'status': '未缴费'},
  11. {'id': 'R002', 'type': '账单', 'address': '人民路8号', 'amount': 128.00, 'status': '已缴费'},
  12. {'id': 'R003', 'type': '抄表', 'address': '建设路3号', 'amount': 42.10, 'status': '逾期'},
  13. ];
  14. Color _statusColor(String s) {
  15. if (s == '已缴费') return AppConstants.successColor;
  16. if (s == '逾期') return AppConstants.errorColor;
  17. return AppConstants.warningColor;
  18. }
  19. @override
  20. Widget build(BuildContext context) {
  21. final total = _bills.fold(0.0, (sum, b) => sum + (b['amount'] as double));
  22. final unpaid = _bills.where((b) => b['status'] != '已缴费').length;
  23. return Scaffold(
  24. body: Column(children: [
  25. Container(padding: const EdgeInsets.all(16), child: Row(children: [
  26. Expanded(child: CustomCard(title: '总金额', value: '¥${total.toStringAsFixed(2)}', color: AppConstants.primaryColor, icon: Icons.account_balance_wallet)),
  27. const SizedBox(width: 8),
  28. Expanded(child: CustomCard(title: '未缴费', value: unpaid.toString(), color: AppConstants.warningColor, icon: Icons.pending)),
  29. const SizedBox(width: 8),
  30. Expanded(child: CustomCard(title: '已缴费', value: (_bills.length - unpaid).toString(), color: AppConstants.successColor, icon: Icons.check_circle)),
  31. ])),
  32. Expanded(child: ListView.builder(padding: const EdgeInsets.all(16), itemCount: _bills.length, itemBuilder: (ctx, i) {
  33. final b = _bills[i];
  34. return Card(margin: const EdgeInsets.symmetric(vertical: 6), child: ListTile(
  35. leading: CircleAvatar(backgroundColor: _statusColor(b['status'] as String), child: Text((b['type'] as String)[0], style: const TextStyle(color: Colors.white))),
  36. title: Text(b['address'] as String, style: const TextStyle(fontWeight: FontWeight.bold)),
  37. subtitle: Text('金额: ¥${(b['amount'] as double).toStringAsFixed(2)} | 类型: ${b['type']}'),
  38. ));
  39. })),
  40. ]),
  41. );
  42. }
  43. }