2.优化修改了tcp重连机制,具体操作:断开重连时候不再建立新链接 而是将旧链接重置,并重新发送数据。 3.大面积的给项目中的各个页面 手动接入了多语言的支持。同时也调整了相应带来的问题英文长度较大影响原有的样式的问题,已解决了对应的样式不和谐问题。保证了外观的统一性。 4.给项目中的主要操作加了几个核心的操作比如远程遥控和路径规划添加了双层的保护,设置里安全模式,即在此期间对服务器推送的重复登录操作后的自动退出登录做一个拦截 保证操作的安全性。
251 lines
7.1 KiB
Dart
251 lines
7.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:maibu_satabot_v2/core/localization/app_localizations.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.8,
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
mainAxisSpacing: 8,
|
|
crossAxisSpacing: 8,
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
_buildStatCard(
|
|
title: AppLocalizations.of(
|
|
context,
|
|
).translate('home_v2.today_generation'),
|
|
value: _formatNumber(data.todayGeneration),
|
|
unit: 'kWh',
|
|
valueColor: const Color(0xFF00B42A),
|
|
showArrow: false,
|
|
),
|
|
_buildStatCard(
|
|
title: AppLocalizations.of(
|
|
context,
|
|
).translate('home_v2.equivalent_hours'),
|
|
value: data.equivalentHours.toStringAsFixed(1),
|
|
unit: 'h',
|
|
valueColor: const Color(0xFF165DFF),
|
|
showArrow: false,
|
|
),
|
|
_buildAlarmCard(context, data.alarmCount),
|
|
_buildWorkOrderCard(context, data.pendingWorkOrders),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildStatCard({
|
|
required String title,
|
|
required String value,
|
|
required String unit,
|
|
required Color valueColor,
|
|
bool showArrow = false,
|
|
}) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(8),
|
|
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: [
|
|
if (showArrow)
|
|
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),
|
|
),
|
|
],
|
|
)
|
|
else
|
|
Text(
|
|
title,
|
|
style: const TextStyle(color: Color(0xFF4E5969), fontSize: 14),
|
|
),
|
|
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(BuildContext context, int count) {
|
|
return Container(
|
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
|
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: [
|
|
Text(
|
|
AppLocalizations.of(context).translate('home_v2.alarm_count'),
|
|
style: const TextStyle(
|
|
color: Color(0xFFF53F3F),
|
|
fontSize: 13,
|
|
),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
count.toString(),
|
|
style: const TextStyle(
|
|
color: Color(0xFFF53F3F),
|
|
fontSize: 28,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: 44,
|
|
height: 44,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFFFE8E8),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.notifications_none,
|
|
size: 24,
|
|
color: Color(0xFFF53F3F),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildWorkOrderCard(BuildContext context, int count) {
|
|
return Container(
|
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
|
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: [
|
|
Text(
|
|
AppLocalizations.of(
|
|
context,
|
|
).translate('home_v2.pending_work_order'),
|
|
style: const TextStyle(
|
|
color: Color(0xFF4E5969),
|
|
fontSize: 13,
|
|
),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
count.toString(),
|
|
style: const TextStyle(
|
|
color: Color(0xFF1D2129),
|
|
fontSize: 28,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: 44,
|
|
height: 44,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFE8F3FF),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.content_paste,
|
|
size: 24,
|
|
color: Color(0xFF165DFF),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String _formatNumber(double number) {
|
|
final formatted = number.toStringAsFixed(0);
|
|
final parts = formatted.split('.');
|
|
final intPart = parts[0];
|
|
final buffer = StringBuffer();
|
|
for (int i = 0; i < intPart.length; i++) {
|
|
if (i > 0 && (intPart.length - i) % 3 == 0) {
|
|
buffer.write(',');
|
|
}
|
|
buffer.write(intPart[i]);
|
|
}
|
|
return buffer.toString();
|
|
}
|
|
}
|