深色模式代码第二轮补充

This commit is contained in:
2026-10-11 16:03:06 +08:00
parent 1d033670f7
commit 7989495521
10 changed files with 198 additions and 209 deletions
+13 -15
View File
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../models/data_abnormal_type.dart';
import '../theme/app_colors.dart';
class BatterySummary extends StatelessWidget {
final double healthPercent;
@@ -19,25 +20,23 @@ class BatterySummary extends StatelessWidget {
@override
Widget build(BuildContext context) {
final c = context.colors;
final bool isAbnormal = abnormalType != DataAbnormalType.none;
final bool isCapacityAbnormal =
abnormalType == DataAbnormalType.capacityTooLow ||
abnormalType == DataAbnormalType.capacityTooHigh;
// 健康度颜色:异常时红色,否则按阈值
final Color healthColor = isAbnormal
? Colors.red
: (healthPercent < 70 ? Colors.red : Colors.black);
? c.healthRed
: (healthPercent < 70 ? c.healthRed : c.textPrimary);
// 容量颜色:异常时红色,否则灰色
final Color capacityColor = isCapacityAbnormal
? Colors.red
: const Color(0xFF5F5F5F);
? c.healthRed
: c.textSecondary;
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// 健康度大数字
Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
@@ -60,34 +59,33 @@ class BatterySummary extends StatelessWidget {
fontSize: 20,
fontWeight: FontWeight.w300,
height: 1.0,
color: healthColor == Colors.red
? Colors.red
: Colors.grey.shade600,
color: healthColor == c.healthRed
? c.healthRed
: c.textSecondary,
),
),
],
),
const Spacer(),
// cycles + mAh
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
RichText(
text: TextSpan(
style: const TextStyle(
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1.2,
color: Colors.black,
color: c.textPrimary,
),
children: [
TextSpan(text: '$cycleCount'),
const TextSpan(
TextSpan(
text: ' cycles',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
color: Colors.black,
color: c.textPrimary,
),
),
],