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; 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 _getProtocolDisplay() { if (isWireless) return '无线充电($chargeType)'; if (chargeType == 'PPS') return 'PPS 快充'; if (chargeType == 'SDP') return 'USB 充电'; return chargeType; } String _getRequestedDisplay() { return ChargeUtils.getDetailRequestedPowerWired( power, wiredLevel, chargeType, ); } String _getActualDisplay() { return ChargeUtils.getDetailActualPowerWired(power, chargeType); } @override Widget build(BuildContext context) { return AnnotatedRegion( // 🟢 1.5.0 与主界面统一状态栏样式 value: const SystemUiOverlayStyle( statusBarColor: Color.fromRGBO(157, 212, 237, 0.5), statusBarIconBrightness: Brightness.dark, statusBarBrightness: Brightness.dark, ), 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(), // 有线充电:标定档位 + 实际功率 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) _buildDetailRow('类型', '无线'), if (!isWireless && wiredLevel == null) _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, ), ), ], ), ); } }