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