优化部分页面下UI显示问题

This commit is contained in:
2026-07-08 23:42:21 +08:00
parent 23d5c3b341
commit 9066b0f703
3 changed files with 59 additions and 44 deletions
+56 -42
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../utils/charge_utils.dart';
/// 充电详情页
@@ -11,14 +12,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';
@@ -27,7 +28,6 @@ class ChargeDetailPage extends StatelessWidget {
return chargeType;
}
/// 🟢 1.5.0 标定档位显示
String _getRequestedDisplay() {
return ChargeUtils.getDetailRequestedPowerWired(
power,
@@ -36,58 +36,72 @@ class ChargeDetailPage extends StatelessWidget {
);
}
/// 🟢 1.5.0 实际功率显示
String _getActualDisplay() {
return ChargeUtils.getDetailActualPowerWired(power, chargeType);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('充电详情'),
backgroundColor: Colors.transparent,
elevation: 0,
foregroundColor: Colors.black,
iconTheme: const IconThemeData(color: Colors.black),
return AnnotatedRegion<SystemUiOverlayStyle>(
// 🟢 1.5.0 与主界面统一状态栏样式
value: const SystemUiOverlayStyle(
statusBarColor: Color.fromRGBO(157, 212, 237, 0.5),
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.dark,
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildDetailRow('协议', _getProtocolDisplay()),
const Divider(),
// 🟢 1.5.0 有线充电:标定档位 + 实际功率 两行
if (!isWireless) ...[
_buildDetailRow('标定档位', _getRequestedDisplay()),
child: Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text('充电详情'),
backgroundColor: Colors.white, // 🟢 与主界面统一
elevation: 0,
scrolledUnderElevation: 0,
shadowColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
foregroundColor: Colors.black,
iconTheme: const IconThemeData(color: Colors.black),
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildDetailRow('协议', _getProtocolDisplay()),
const Divider(),
_buildDetailRow('实际功率', _getActualDisplay()),
// 有线充电:标定档位 + 实际功率
if (!isWireless) ...[
_buildDetailRow('标定档位', _getRequestedDisplay()),
const Divider(),
_buildDetailRow('实际功率', _getActualDisplay()),
const Divider(),
] else ...[
_buildDetailRow(
'功率',
ChargeUtils.getDisplayPowerWireless(power),
),
const Divider(),
],
_buildDetailRow('电压', '${volt.toStringAsFixed(2)}V'),
const Divider(),
] else ...[
// 无线充电:保持原样,只显示功率
_buildDetailRow('功率', ChargeUtils.getDisplayPowerWireless(power)),
_buildDetailRow('电流', '${curr.toStringAsFixed(2)}A'),
const Divider(),
],
_buildDetailRow('电压', '${volt.toStringAsFixed(2)}V'),
const Divider(),
_buildDetailRow('电流', '${curr.toStringAsFixed(2)}A'),
const Divider(),
// 辅助信息
if (isWireless) _buildDetailRow('类型', '无线'),
if (!isWireless && wiredLevel == null)
_buildDetailRow('档位', '自动'),
// 辅助信息
if (isWireless) _buildDetailRow('类型', '无线'),
if (!isWireless && wiredLevel == null) _buildDetailRow('档位', '自动'),
const Spacer(),
Center(
child: Text(
'数据来自 BMS 实时日志',
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
const Spacer(),
Center(
child: Text(
'数据来自 BMS 实时日志',
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
),
),
),
],
],
),
),
),
);