116 lines
3.4 KiB
Dart
116 lines
3.4 KiB
Dart
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) {
|
|
final bool isLowHealth = healthPercent < 70;
|
|
|
|
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: isLowHealth ? Colors.red : Colors.black,
|
|
),
|
|
),
|
|
const SizedBox(width: 2),
|
|
Text(
|
|
'%',
|
|
style: TextStyle(
|
|
fontFamily: 'Flyme',
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w300,
|
|
height: 1.0,
|
|
color: isLowHealth ? Colors.red : Colors.grey.shade600,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const Spacer(),
|
|
// cycles + mAh
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
RichText(
|
|
text: TextSpan(
|
|
style: TextStyle(
|
|
fontFamily: 'Flyme',
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
height: 1.2,
|
|
color: Colors.black,
|
|
),
|
|
children: [
|
|
TextSpan(text: '$cycleCount'),
|
|
TextSpan(
|
|
text: ' cycles',
|
|
style: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
RichText(
|
|
text: TextSpan(
|
|
style: TextStyle(
|
|
fontFamily: 'Flyme',
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w300,
|
|
height: 1.0,
|
|
color: const Color(0xFF5F5F5F),
|
|
),
|
|
children: [
|
|
TextSpan(text: currentCap.toStringAsFixed(0)),
|
|
TextSpan(
|
|
text: ' / ',
|
|
style: TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
color: const Color(0xFF5F5F5F).withValues(alpha: 0.5),
|
|
),
|
|
),
|
|
TextSpan(text: designCap.toString()),
|
|
TextSpan(
|
|
text: ' mAh',
|
|
style: const TextStyle(
|
|
fontFamily: 'HarmonyOS_Sans_SC',
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Color(0xFF5F5F5F),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|