首次提交
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/charge_utils.dart';
|
||||
|
||||
/// 充电详情页
|
||||
class ChargeDetailPage extends StatelessWidget {
|
||||
final String chargeType;
|
||||
final bool isWireless;
|
||||
final double power;
|
||||
final double volt;
|
||||
final double curr;
|
||||
final int? wiredLevel;
|
||||
|
||||
const ChargeDetailPage({
|
||||
Key? key,
|
||||
required this.chargeType,
|
||||
required this.isWireless,
|
||||
required this.power,
|
||||
required this.volt,
|
||||
required this.curr,
|
||||
this.wiredLevel,
|
||||
}) : super(key: key);
|
||||
|
||||
String _getDisplayPower() {
|
||||
if (isWireless) {
|
||||
return ChargeUtils.getDisplayPowerWireless(power);
|
||||
} else {
|
||||
return ChargeUtils.getDisplayPowerWired(power, wiredLevel, chargeType);
|
||||
}
|
||||
}
|
||||
|
||||
String _getProtocolDisplay() {
|
||||
if (isWireless) return '无线充电($chargeType)';
|
||||
if (chargeType == 'PPS') return 'PPS 快充';
|
||||
if (chargeType == 'SDP') return 'USB 充电'; // 🟢 改成和主页面一致
|
||||
return chargeType;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('充电详情'),
|
||||
backgroundColor: const Color.fromARGB(0, 255, 255, 255),
|
||||
elevation: 0,
|
||||
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('功率', _getDisplayPower()),
|
||||
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('类型', '无线'),
|
||||
const Spacer(),
|
||||
Center(
|
||||
child: Text(
|
||||
'数据来自 BMS 实时日志',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user