219 lines
5.8 KiB
Dart
219 lines
5.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:maibu_satabot_v2/features/v2/home/domain/entities/home_entity.dart';
|
|
|
|
class StatsGrid extends StatelessWidget {
|
|
final HomeEntity data;
|
|
|
|
const StatsGrid({super.key, required this.data});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GridView.count(
|
|
crossAxisCount: 2,
|
|
childAspectRatio: 1.5,
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
mainAxisSpacing: 12,
|
|
crossAxisSpacing: 12,
|
|
children: [
|
|
_buildStatCard(
|
|
title: '今日发电量',
|
|
value: data.todayGeneration.toStringAsFixed(0),
|
|
unit: 'kWh',
|
|
valueColor: const Color(0xFF00B42A),
|
|
),
|
|
_buildStatCard(
|
|
title: '等效小时数',
|
|
value: data.equivalentHours.toStringAsFixed(1),
|
|
unit: 'h',
|
|
valueColor: const Color(0xFF165DFF),
|
|
),
|
|
_buildAlarmCard(data.alarmCount),
|
|
_buildWorkOrderCard(data.pendingWorkOrders),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildStatCard({
|
|
required String title,
|
|
required String value,
|
|
required String unit,
|
|
required Color valueColor,
|
|
}) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Color(0x0D000000),
|
|
blurRadius: 4,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
color: Color(0xFF4E5969),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
const Icon(
|
|
Icons.arrow_forward_ios,
|
|
size: 14,
|
|
color: Color(0xFF86909C),
|
|
),
|
|
],
|
|
),
|
|
const Spacer(),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
value,
|
|
style: TextStyle(
|
|
color: valueColor,
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
unit,
|
|
style: const TextStyle(
|
|
color: Color(0xFF4E5969),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildAlarmCard(int count) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFFFF0F0),
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Color(0x0D000000),
|
|
blurRadius: 4,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Text(
|
|
'告警数',
|
|
style: TextStyle(
|
|
color: Color(0xFFF53F3F),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
count.toString(),
|
|
style: const TextStyle(
|
|
color: Color(0xFFF53F3F),
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: 48,
|
|
height: 48,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFFFE8E8),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.notifications_active,
|
|
size: 28,
|
|
color: Color(0xFFF53F3F),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildWorkOrderCard(int count) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: const [
|
|
BoxShadow(
|
|
color: Color(0x0D000000),
|
|
blurRadius: 4,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Text(
|
|
'待办工单',
|
|
style: TextStyle(
|
|
color: Color(0xFF4E5969),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
count.toString(),
|
|
style: const TextStyle(
|
|
color: Color(0xFF1D2129),
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: 48,
|
|
height: 48,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFE8F3FF),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.assignment,
|
|
size: 28,
|
|
color: Color(0xFF165DFF),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|