新批次的夜间模式适配代码
This commit is contained in:
@@ -19,20 +19,20 @@ class BatterySummary extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
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);
|
||||
|
||||
// 容量颜色:异常时红色,否则灰色
|
||||
// 🟢 颜色完全动态
|
||||
final Color defaultTextColor = Theme.of(context).colorScheme.onSurface;
|
||||
final Color mutedTextColor = isDark
|
||||
? Colors.grey.shade400
|
||||
: const Color(0xFF5F5F5F);
|
||||
final Color capacityColor = isCapacityAbnormal
|
||||
? Colors.red
|
||||
: const Color(0xFF5F5F5F);
|
||||
: mutedTextColor;
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
@@ -49,7 +49,7 @@ class BatterySummary extends StatelessWidget {
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.0,
|
||||
color: healthColor,
|
||||
color: isAbnormal ? Colors.red : defaultTextColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
@@ -60,9 +60,7 @@ class BatterySummary extends StatelessWidget {
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w300,
|
||||
height: 1.0,
|
||||
color: healthColor == Colors.red
|
||||
? Colors.red
|
||||
: Colors.grey.shade600,
|
||||
color: isAbnormal ? Colors.red : Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -74,21 +72,18 @@ class BatterySummary extends StatelessWidget {
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontFamily: 'Flyme',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.2,
|
||||
color: Colors.black,
|
||||
color: defaultTextColor,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: '$cycleCount'),
|
||||
const TextSpan(
|
||||
TextSpan(
|
||||
text: ' cycles',
|
||||
style: TextStyle(
|
||||
fontFamily: 'HarmonyOS_Sans_SC',
|
||||
color: Colors.black,
|
||||
),
|
||||
style: const TextStyle(fontFamily: 'HarmonyOS_Sans_SC'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user