import 'package:flutter/material.dart'; class BatterySummary extends StatelessWidget { final double healthPercent; final int cycleCount; final double currentCap; final int designCap; const BatterySummary({ super.key, required this.healthPercent, required this.cycleCount, required this.currentCap, required this.designCap, }); @override Widget build(BuildContext context) { return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ // 健康度大数字 Row( crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ Text( healthPercent.toStringAsFixed(1), style: TextStyle( fontFamily: 'Flyme', fontSize: 40, fontWeight: FontWeight.w500, height: 1.0, color: healthPercent < 70 ? Colors.red : Colors.black, ), ), const SizedBox(width: 2), Text( '%', style: TextStyle( fontFamily: 'HarmonyOS_Sans_SC', fontSize: 20, fontWeight: FontWeight.w300, height: 1.0, color: healthPercent < 70 ? Colors.red : Colors.grey.shade600, ), ), ], ), const Spacer(), // cycles + mAh Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ RichText( text: TextSpan( style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w500, height: 1.2, color: Colors.black, ), children: [ TextSpan( text: '$cycleCount', style: const TextStyle( fontFamily: 'Flyme', color: Colors.black, ), ), const TextSpan( text: ' cycles', style: TextStyle( fontFamily: 'HarmonyOS_Sans_SC', color: Colors.black, ), ), ], ), ), const SizedBox(height: 4), RichText( text: TextSpan( style: const TextStyle( fontSize: 20, fontWeight: FontWeight.w300, height: 1.0, color: Colors.black, ), children: [ TextSpan( text: currentCap.toStringAsFixed(0), style: const TextStyle( fontFamily: 'Flyme', color: Colors.black, ), ), TextSpan( text: ' / ', style: TextStyle( fontFamily: 'HarmonyOS_Sans_SC', color: Colors.grey.shade500, ), ), // 🟢 设计容量数字用 Flyme,单位用 Harmony TextSpan( text: designCap.toString(), style: const TextStyle( fontFamily: 'Flyme', color: Colors.black, ), ), TextSpan( text: 'mAh', style: const TextStyle( fontFamily: 'HarmonyOS_Sans_SC', color: Colors.black, ), ), ], ), ), ], ), ], ); } }