尝试针对魅族20系设计新的计算逻辑

This commit is contained in:
2026-07-05 23:23:30 +08:00
parent 14416be48e
commit 20e29f3043
13 changed files with 1423 additions and 1036 deletions
+101
View File
@@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
/// 电池健康度摘要组件(健康度 + cycles + mAh
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(
fontSize: 40,
fontWeight: FontWeight.w500,
height: 1.0,
color: healthPercent < 70 ? Colors.red : Colors.black,
),
),
const SizedBox(width: 2),
Text(
'%',
style: TextStyle(
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: [
Text(
'$cycleCount cycles', // ✅ 修正:去掉下划线,使用 cycleCount
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1.2,
),
),
const SizedBox(height: 4),
Text.rich(
TextSpan(
children: [
TextSpan(
text: currentCap.toStringAsFixed(0),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w300,
),
),
TextSpan(
text: ' / ',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w300,
color: Colors.grey.shade500,
),
),
TextSpan(
text: '${designCap}mAh',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w300,
),
),
],
),
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w300,
height: 1.0,
),
),
],
),
],
);
}
}