更新一个字体

This commit is contained in:
2026-07-14 21:51:44 +08:00
parent 804b992ee4
commit adc49fa1a5
8 changed files with 298 additions and 76 deletions
+61 -22
View File
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../utils/charge_utils.dart';
/// 充电详情页
class ChargeDetailPage extends StatelessWidget {
final String chargeType;
final bool isWireless;
@@ -12,14 +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,
});
}) : super(key: key);
String _getProtocolDisplay() {
if (isWireless) return '无线充电($chargeType';
@@ -43,9 +42,8 @@ class ChargeDetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
// 🟢 1.5.0 与主界面统一状态栏样式
value: const SystemUiOverlayStyle(
statusBarColor: Color.fromRGBO(157, 212, 237, 0.5),
statusBarColor: Color.fromRGBO(157, 212, 237, 0.1),
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.dark,
),
@@ -53,7 +51,7 @@ class ChargeDetailPage extends StatelessWidget {
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text('充电详情'),
backgroundColor: Colors.white, // 🟢 与主界面统一
backgroundColor: Colors.white,
elevation: 0,
scrolledUnderElevation: 0,
shadowColor: Colors.transparent,
@@ -66,38 +64,36 @@ class ChargeDetailPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildDetailRow('协议', _getProtocolDisplay()),
_buildTextRow('协议', _getProtocolDisplay()),
const Divider(),
// 有线充电:标定档位 + 实际功率
if (!isWireless) ...[
_buildDetailRow('标定档位', _getRequestedDisplay()),
_buildTextRow('标定档位', _getRequestedDisplay()),
const Divider(),
_buildDetailRow('实际功率', _getActualDisplay()),
_buildTextRow('实际功率', _getActualDisplay()),
const Divider(),
] else ...[
_buildDetailRow(
'功率',
ChargeUtils.getDisplayPowerWireless(power),
),
_buildTextRow('功率', ChargeUtils.getDisplayPowerWireless(power)),
const Divider(),
],
_buildDetailRow('电压', '${volt.toStringAsFixed(2)}V'),
_buildDetailRow('电压', volt, 'V'),
const Divider(),
_buildDetailRow('电流', '${curr.toStringAsFixed(2)}A'),
_buildDetailRow('电流', curr, 'A'),
const Divider(),
// 辅助信息
if (isWireless) _buildDetailRow('类型', '无线'),
if (!isWireless && wiredLevel == null)
_buildDetailRow('档位', '自动'),
if (isWireless) _buildTextRow('类型', '无线'),
if (!isWireless && wiredLevel == null) _buildTextRow('档位', '自动'),
const Spacer(),
Center(
child: Text(
'数据来自 BMS 实时日志',
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 12,
color: Colors.grey.shade500,
),
),
),
],
@@ -107,7 +103,8 @@ class ChargeDetailPage extends StatelessWidget {
);
}
Widget _buildDetailRow(String label, String value) {
/// 纯文本行(协议、功率、档位等)
Widget _buildTextRow(String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
@@ -116,6 +113,7 @@ class ChargeDetailPage extends StatelessWidget {
Text(
label,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.grey,
@@ -124,6 +122,7 @@ class ChargeDetailPage extends StatelessWidget {
Text(
value,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC', // 复杂字符串保持 Harmony
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
@@ -133,4 +132,44 @@ class ChargeDetailPage extends StatelessWidget {
),
);
}
/// 数值行(电压/电流,数字用 Flyme,单位用 Harmony
Widget _buildDetailRow(String label, double value, String unit) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
label,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.grey,
),
),
RichText(
text: TextSpan(
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
children: [
TextSpan(
text: value.toStringAsFixed(2),
style: const TextStyle(fontFamily: 'Flyme'), // 🟢 数字用 Flyme
),
TextSpan(
text: unit,
style: const TextStyle(fontFamily: 'HarmonyOS_Sans_SC'),
),
],
),
),
],
),
);
}
}