深色模式代码第二轮补充
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import '../models/data_abnormal_type.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
|
||||
class BatteryInfoPanel extends StatelessWidget {
|
||||
final double batteryVolt;
|
||||
@@ -9,9 +10,8 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
final double minVolt;
|
||||
final double maxTemp;
|
||||
final double minTemp;
|
||||
final DataAbnormalType abnormalType;
|
||||
|
||||
final double tempAvg;
|
||||
final DataAbnormalType abnormalType;
|
||||
|
||||
const BatteryInfoPanel({
|
||||
super.key,
|
||||
@@ -27,19 +27,22 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = context.colors;
|
||||
final bool isVoltageAbnormal =
|
||||
abnormalType == DataAbnormalType.voltageAbnormal;
|
||||
final Color voltColor = isVoltageAbnormal ? Colors.red : Colors.black;
|
||||
final Color voltColor = isVoltageAbnormal ? c.healthRed : c.textPrimary;
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ---------- 电压列 ----------
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInfoItem(
|
||||
_buildIcon('voltage'),
|
||||
context,
|
||||
_buildIcon(context, 'voltage'),
|
||||
'电压',
|
||||
'${batteryVolt.toStringAsFixed(3)}V',
|
||||
textColor: voltColor,
|
||||
@@ -53,22 +56,17 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.red,
|
||||
color: c.voltUp,
|
||||
),
|
||||
children: [
|
||||
const TextSpan(
|
||||
TextSpan(
|
||||
text: '↑ ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'HarmonyOS_Sans_SC',
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${maxVolt.toStringAsFixed(3)}V',
|
||||
style: TextStyle(
|
||||
color: isVoltageAbnormal ? Colors.red : Colors.red,
|
||||
color: c.voltUp,
|
||||
),
|
||||
),
|
||||
TextSpan(text: '${maxVolt.toStringAsFixed(3)}V'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -79,22 +77,17 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.blue,
|
||||
color: c.voltDown,
|
||||
),
|
||||
children: [
|
||||
const TextSpan(
|
||||
TextSpan(
|
||||
text: '↓ ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'HarmonyOS_Sans_SC',
|
||||
color: Colors.blue,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${minVolt.toStringAsFixed(3)}V',
|
||||
style: TextStyle(
|
||||
color: isVoltageAbnormal ? Colors.red : Colors.blue,
|
||||
color: c.voltDown,
|
||||
),
|
||||
),
|
||||
TextSpan(text: '${minVolt.toStringAsFixed(3)}V'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -103,33 +96,34 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
// ---------- 温度列 ----------
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInfoItem(
|
||||
_buildIcon('temperature'),
|
||||
context,
|
||||
_buildIcon(context, 'temperature'),
|
||||
'温度',
|
||||
'${batteryTemp.toStringAsFixed(0)}℃',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// 🆕 一行显示:↑ max ↓ min [avg] avg
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.red,
|
||||
color: c.tempUp,
|
||||
),
|
||||
children: [
|
||||
const TextSpan(
|
||||
TextSpan(
|
||||
text: '↑ ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'HarmonyOS_Sans_SC',
|
||||
color: Colors.red,
|
||||
color: c.tempUp,
|
||||
),
|
||||
),
|
||||
TextSpan(text: '${maxTemp.toStringAsFixed(1)}℃'),
|
||||
@@ -139,18 +133,18 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
const SizedBox(width: 6),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.blue,
|
||||
color: c.tempDown,
|
||||
),
|
||||
children: [
|
||||
const TextSpan(
|
||||
TextSpan(
|
||||
text: '↓ ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'HarmonyOS_Sans_SC',
|
||||
color: Colors.blue,
|
||||
color: c.tempDown,
|
||||
),
|
||||
),
|
||||
TextSpan(text: '${minTemp.toStringAsFixed(1)}℃'),
|
||||
@@ -158,15 +152,15 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_buildIcon('avg', size: 14),
|
||||
_buildIcon(context, 'avg', size: 14),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
'${tempAvg.toStringAsFixed(1)}℃',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey,
|
||||
color: c.textTertiary,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -178,50 +172,54 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIcon(String type, {double size = 18}) {
|
||||
Widget _buildIcon(BuildContext context, String type, {double size = 18}) {
|
||||
final c = context.colors;
|
||||
final filter = ColorFilter.mode(c.textTertiary, BlendMode.srcIn);
|
||||
switch (type) {
|
||||
case 'voltage':
|
||||
return SvgPicture.asset(
|
||||
'assets/icons/si--lightning-fill.svg',
|
||||
width: size,
|
||||
height: size,
|
||||
colorFilter: const ColorFilter.mode(Colors.grey, BlendMode.srcIn),
|
||||
colorFilter: filter,
|
||||
);
|
||||
case 'temperature':
|
||||
return SvgPicture.asset(
|
||||
'assets/icons/mdi--temperature.svg',
|
||||
width: size,
|
||||
height: size,
|
||||
colorFilter: const ColorFilter.mode(Colors.grey, BlendMode.srcIn),
|
||||
colorFilter: filter,
|
||||
);
|
||||
case 'avg': // 🆕
|
||||
case 'avg':
|
||||
return SvgPicture.asset(
|
||||
'assets/icons/avg.svg',
|
||||
width: size,
|
||||
height: size,
|
||||
colorFilter: const ColorFilter.mode(Colors.grey, BlendMode.srcIn),
|
||||
colorFilter: filter,
|
||||
);
|
||||
default:
|
||||
return Icon(Icons.help_outline, size: size, color: Colors.grey);
|
||||
return Icon(Icons.help_outline, size: size, color: c.textTertiary);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildInfoItem(
|
||||
BuildContext context,
|
||||
Widget icon,
|
||||
String label,
|
||||
String value, {
|
||||
Color textColor = Colors.black,
|
||||
Color? textColor,
|
||||
}) {
|
||||
final c = context.colors;
|
||||
return Row(
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontFamily: 'HarmonyOS_Sans_SC',
|
||||
fontSize: 14,
|
||||
color: Colors.grey,
|
||||
color: c.textTertiary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
@@ -231,7 +229,7 @@ class BatteryInfoPanel extends StatelessWidget {
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: textColor,
|
||||
color: textColor ?? c.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user