充电逻辑修改初步定档

This commit is contained in:
2026-07-08 23:10:16 +08:00
parent c5e5280de7
commit afc83c16c3
4 changed files with 90 additions and 24 deletions
+34 -16
View File
@@ -11,22 +11,14 @@ class ChargeDetailPage extends StatelessWidget {
final int? wiredLevel;
const ChargeDetailPage({
super.key,
Key? key,
required this.chargeType,
required this.isWireless,
required this.power,
required this.volt,
required this.curr,
this.wiredLevel,
});
String _getDisplayPower() {
if (isWireless) {
return ChargeUtils.getDisplayPowerWireless(power);
} else {
return ChargeUtils.getDisplayPowerWired(power, wiredLevel, chargeType);
}
}
}) : super(key: key);
String _getProtocolDisplay() {
if (isWireless) return '无线充电($chargeType';
@@ -35,12 +27,26 @@ class ChargeDetailPage extends StatelessWidget {
return chargeType;
}
/// 🟢 1.5.0 标定档位显示
String _getRequestedDisplay() {
return ChargeUtils.getDetailRequestedPowerWired(
power,
wiredLevel,
chargeType,
);
}
/// 🟢 1.5.0 实际功率显示
String _getActualDisplay() {
return ChargeUtils.getDetailActualPowerWired(power, chargeType);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('充电详情'),
backgroundColor: const Color.fromARGB(0, 255, 255, 255),
backgroundColor: Colors.transparent,
elevation: 0,
foregroundColor: Colors.black,
iconTheme: const IconThemeData(color: Colors.black),
@@ -52,16 +58,28 @@ class ChargeDetailPage extends StatelessWidget {
children: [
_buildDetailRow('协议', _getProtocolDisplay()),
const Divider(),
_buildDetailRow('功率', _getDisplayPower()),
const Divider(),
// 🟢 1.5.0 有线充电:标定档位 + 实际功率 两行
if (!isWireless) ...[
_buildDetailRow('标定档位', _getRequestedDisplay()),
const Divider(),
_buildDetailRow('实际功率', _getActualDisplay()),
const Divider(),
] else ...[
// 无线充电:保持原样,只显示功率
_buildDetailRow('功率', ChargeUtils.getDisplayPowerWireless(power)),
const Divider(),
],
_buildDetailRow('电压', '${volt.toStringAsFixed(2)}V'),
const Divider(),
_buildDetailRow('电流', '${curr.toStringAsFixed(2)}A'),
const Divider(),
if (!isWireless && wiredLevel != null)
_buildDetailRow('档位', '$wiredLevel'),
if (!isWireless && wiredLevel == null) _buildDetailRow('档位', '自动'),
// 辅助信息
if (isWireless) _buildDetailRow('类型', '无线'),
if (!isWireless && wiredLevel == null) _buildDetailRow('档位', '自动'),
const Spacer(),
Center(
child: Text(