10 Commits

12 changed files with 276 additions and 100 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
{
"cmake.ignoreCMakeListsMissing": true
"cmake.ignoreCMakeListsMissing": true,
"gitlens.codeLens.enabled": false
}
+13 -3
View File
@@ -25,15 +25,25 @@
| 版本 | 主题 | 状态 |
| :--- | :--- | :--- |
| 1.5.0 | 功率计算优化 | ✅ 已发布 |
| 2.0.0 | 数据看板扩展(月/季/年趋势) | 📋 远景 |
| 1.5.2 | 部分场景字体替换 | ✅ 已发布 |
| 1.6.0 | 更新日志独立页面 | 📋近期开发 |
| 1.7.0 | 适配夜间模式 | 📋近期开发 |
| 2.0.0 | 数据看板扩展等系列更新 | 📋 远景 |
| 3.0.0 | 搭配PC上位机记录充电信息等 | 📋 远景 |
---
## 环境要求
- Flutter SDK: ^3.9.2
- Android: 8.0+ (API 26+)
- 仅支持魅族手机(15 系列 ~ 22 系列)
---
## 机型匹配情况
目前据群友反馈已知:
- 魅族22无mbattery_charger目录生成,无法实时计算相应百分比,因此已在最近版本去除相关匹配信息
- 魅族18在后续的版本中关闭了mbattery_log生成,疑似无效,老版本可能支持
- 最完美的支持版本至少可覆盖魅族20/21系机型(20inf已确认,机型匹配ID已更新)
---
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
description: This file stores settings for Dart & Flutter DevTools.
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
extensions:
+37 -2
View File
@@ -5,7 +5,6 @@ import 'services/saf_storage_service.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 🟢 初始化 SAF 服务
await SafStorageService().init();
runApp(const MyApp());
@@ -19,9 +18,45 @@ class MyApp extends StatelessWidget {
return MaterialApp(
title: '电池健康度',
theme: ThemeData(
// 🟢 中文用 HarmonyOS Sans SC
fontFamily: 'HarmonyOS_Sans_SC',
// 🟢 数字回退到 FlymeFont
fontFamilyFallback: const ['Flyme'],
// 🟢 统一文字颜色为黑色
colorScheme: ColorScheme.fromSeed(
seedColor: const Color.fromARGB(255, 255, 255, 255),
seedColor: const Color(0xFFFFFFFF),
).copyWith(onSurface: Colors.black),
textTheme: const TextTheme(
// 大标题/数字(健康度、容量等)
displayMedium: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontFamilyFallback: ['Flyme'],
color: Colors.black,
),
// 标题(如“容量百分比变动趋势”)
headlineMedium: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontFamilyFallback: ['Flyme'],
color: Colors.black,
),
// 正文(电压、温度、循环次数等)
bodyMedium: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontFamilyFallback: ['Flyme'],
color: Colors.black,
),
// 小字(日期、辅助信息)
bodySmall: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontFamilyFallback: ['Flyme'],
color: Colors.black87,
),
// 数字专用(大号数字,如健康度百分比)
displayLarge: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontFamilyFallback: ['Flyme'],
color: Colors.black,
),
),
useMaterial3: true,
),
+2 -4
View File
@@ -2,11 +2,10 @@
class DeviceMatching {
/// 根据机型返回设计容量(mAh)
static int getDesignCapacity(String model) {
if (model.contains('22')) return 5510;
if (model.contains('21 Pro')) return 5050;
if (model.contains('21')) return 4800;
if (model.contains('20 Pro')) return 5000;
if (model.contains('20 INFINITY')) return 4800;
if (model.contains('20 Inf')) return 4800;
if (model.contains('20')) return 4700;
if (model.contains('18s Pro')) return 4500;
if (model.contains('18s')) return 4000;
@@ -29,11 +28,10 @@ class DeviceMatching {
/// 根据机型返回显示名称
static String getModelName(String model) {
if (model.contains('22')) return '魅族22';
if (model.contains('21 Pro')) return '魅族21 Pro';
if (model.contains('21')) return '魅族21';
if (model.contains('20 Pro')) return '魅族20 Pro';
if (model.contains('20 INFINITY')) return '魅族20 INFINITY';
if (model.contains('20 Inf')) return '魅族20 Infinity';
if (model.contains('20')) return '魅族20';
if (model.contains('18s Pro')) return '魅族18s Pro';
if (model.contains('18s')) return '魅族18s';
+79 -20
View File
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
/// 电池信息面板(电压 + 温度 + 极值)
class BatteryInfoPanel extends StatelessWidget {
final double batteryVolt;
final double batteryTemp;
@@ -37,21 +36,45 @@ class BatteryInfoPanel extends StatelessWidget {
const SizedBox(height: 8),
Row(
children: [
Text(
'${maxVolt.toStringAsFixed(3)}V',
style: const TextStyle(
color: Colors.red,
RichText(
text: TextSpan(
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.red,
),
children: [
const TextSpan(
text: '',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
color: Colors.red,
),
),
TextSpan(text: '${maxVolt.toStringAsFixed(3)}V'),
],
),
),
const SizedBox(width: 12),
Text(
'${minVolt.toStringAsFixed(3)}V',
style: const TextStyle(
color: Colors.blue,
RichText(
text: TextSpan(
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.blue,
),
children: [
const TextSpan(
text: '',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
color: Colors.blue,
),
),
TextSpan(text: '${minVolt.toStringAsFixed(3)}V'),
],
),
),
],
@@ -66,26 +89,50 @@ class BatteryInfoPanel extends StatelessWidget {
_buildInfoItem(
_buildIcon('temperature'),
'温度',
'${batteryTemp.toStringAsFixed(0)}°C',
'${batteryTemp.toStringAsFixed(0)}',
),
const SizedBox(height: 8),
Row(
children: [
Text(
'${maxTemp.toStringAsFixed(0)}°C',
style: const TextStyle(
color: Colors.red,
RichText(
text: TextSpan(
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.red,
),
children: [
const TextSpan(
text: '',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
color: Colors.red,
),
),
TextSpan(text: '${maxTemp.toStringAsFixed(0)}'),
],
),
),
const SizedBox(width: 12),
Text(
'${minTemp.toStringAsFixed(0)}°C',
style: const TextStyle(
color: Colors.blue,
RichText(
text: TextSpan(
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.blue,
),
children: [
const TextSpan(
text: '',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
color: Colors.blue,
),
),
TextSpan(text: '${minTemp.toStringAsFixed(0)}'),
],
),
),
],
@@ -123,11 +170,23 @@ class BatteryInfoPanel extends StatelessWidget {
children: [
icon,
const SizedBox(width: 6),
Text(label, style: const TextStyle(fontSize: 14, color: Colors.grey)),
Text(
label,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 14,
color: Colors.grey,
),
),
const SizedBox(width: 6),
Text(
value,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
style: const TextStyle(
fontFamily: 'Flyme',
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black,
),
),
],
);
+43 -29
View File
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
/// 电池健康度摘要组件(健康度 + cycles + mAh
class BatterySummary extends StatelessWidget {
final double healthPercent;
final int cycleCount;
@@ -17,6 +16,8 @@ class BatterySummary extends StatelessWidget {
@override
Widget build(BuildContext context) {
final bool isLowHealth = healthPercent < 70;
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
@@ -28,20 +29,22 @@ class BatterySummary extends StatelessWidget {
Text(
healthPercent.toStringAsFixed(1),
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 40,
fontWeight: FontWeight.w500,
height: 1.0,
color: healthPercent < 70 ? Colors.red : Colors.black,
color: isLowHealth ? Colors.red : Colors.black,
),
),
const SizedBox(width: 2),
Text(
'%',
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 20,
fontWeight: FontWeight.w300,
height: 1.0,
color: healthPercent < 70 ? Colors.red : Colors.grey.shade600,
color: isLowHealth ? Colors.red : Colors.grey.shade600,
),
),
],
@@ -51,46 +54,57 @@ class BatterySummary extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
'$cycleCount cycles', // ✅ 修正:去掉下划线,使用 cycleCount
style: const TextStyle(
RichText(
text: TextSpan(
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1.2,
color: Colors.black,
),
),
const SizedBox(height: 4),
Text.rich(
TextSpan(
children: [
TextSpan(text: '$cycleCount'),
TextSpan(
text: currentCap.toStringAsFixed(0),
text: ' cycles',
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,
fontFamily: 'HarmonyOS_Sans_SC',
color: Colors.black,
),
),
],
),
style: const TextStyle(
),
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),
),
),
],
),
),
],
+61 -22
View File
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../utils/charge_utils.dart';
/// 充电详情页
class ChargeDetailPage extends StatelessWidget {
final String chargeType;
final bool isWireless;
@@ -12,14 +11,14 @@ class ChargeDetailPage extends StatelessWidget {
final int? wiredLevel;
const ChargeDetailPage({
Key? key,
super.key,
required this.chargeType,
required this.isWireless,
required this.power,
required this.volt,
required this.curr,
this.wiredLevel,
}) : super(key: key);
});
String _getProtocolDisplay() {
if (isWireless) return '无线充电($chargeType';
@@ -43,9 +42,8 @@ class ChargeDetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
// 🟢 1.5.0 与主界面统一状态栏样式
value: const SystemUiOverlayStyle(
statusBarColor: Color.fromRGBO(157, 212, 237, 0.5),
statusBarColor: Color.fromRGBO(157, 212, 237, 0.1),
statusBarIconBrightness: Brightness.dark,
statusBarBrightness: Brightness.dark,
),
@@ -53,7 +51,7 @@ class ChargeDetailPage extends StatelessWidget {
backgroundColor: Colors.white,
appBar: AppBar(
title: const Text('充电详情'),
backgroundColor: Colors.white, // 🟢 与主界面统一
backgroundColor: Colors.white,
elevation: 0,
scrolledUnderElevation: 0,
shadowColor: Colors.transparent,
@@ -66,38 +64,36 @@ class ChargeDetailPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildDetailRow('协议', _getProtocolDisplay()),
_buildTextRow('协议', _getProtocolDisplay()),
const Divider(),
// 有线充电:标定档位 + 实际功率
if (!isWireless) ...[
_buildDetailRow('标定档位', _getRequestedDisplay()),
_buildTextRow('标定档位', _getRequestedDisplay()),
const Divider(),
_buildDetailRow('实际功率', _getActualDisplay()),
_buildTextRow('实际功率', _getActualDisplay()),
const Divider(),
] else ...[
_buildDetailRow(
'功率',
ChargeUtils.getDisplayPowerWireless(power),
),
_buildTextRow('功率', ChargeUtils.getDisplayPowerWireless(power)),
const Divider(),
],
_buildDetailRow('电压', '${volt.toStringAsFixed(2)}V'),
_buildDetailRow('电压', volt, 'V'),
const Divider(),
_buildDetailRow('电流', '${curr.toStringAsFixed(2)}A'),
_buildDetailRow('电流', curr, 'A'),
const Divider(),
// 辅助信息
if (isWireless) _buildDetailRow('类型', '无线'),
if (!isWireless && wiredLevel == null)
_buildDetailRow('档位', '自动'),
if (isWireless) _buildTextRow('类型', '无线'),
if (!isWireless && wiredLevel == null) _buildTextRow('档位', '自动'),
const Spacer(),
Center(
child: Text(
'数据来自 BMS 实时日志',
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 12,
color: Colors.grey.shade500,
),
),
),
],
@@ -107,7 +103,8 @@ class ChargeDetailPage extends StatelessWidget {
);
}
Widget _buildDetailRow(String label, String value) {
/// 纯文本行(协议、功率、档位等)
Widget _buildTextRow(String label, String value) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
@@ -116,6 +113,7 @@ class ChargeDetailPage extends StatelessWidget {
Text(
label,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.grey,
@@ -124,6 +122,7 @@ class ChargeDetailPage extends StatelessWidget {
Text(
value,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC', // 复杂字符串保持 Harmony
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
@@ -133,4 +132,44 @@ class ChargeDetailPage extends StatelessWidget {
),
);
}
/// 数值行(电压/电流,数字用 Flyme,单位用 Harmony
Widget _buildDetailRow(String label, double value, String unit) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
label,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.grey,
),
),
RichText(
text: TextSpan(
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
children: [
TextSpan(
text: value.toStringAsFixed(2),
style: const TextStyle(fontFamily: 'Flyme'), // 🟢 数字用 Flyme
),
TextSpan(
text: unit,
style: const TextStyle(fontFamily: 'HarmonyOS_Sans_SC'),
),
],
),
),
],
),
);
}
}
+3 -1
View File
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
/// 充电入口行(显示充电状态 + 点击进入详情)
class ChargeEntry extends StatelessWidget {
final String summary;
final bool isCharging;
@@ -23,6 +22,7 @@ class ChargeEntry extends StatelessWidget {
Text(
summary,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC', // 🟢 混合文本用 Harmony
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
@@ -33,6 +33,7 @@ class ChargeEntry extends StatelessWidget {
Text(
'充电信息',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.grey.shade700,
@@ -42,6 +43,7 @@ class ChargeEntry extends StatelessWidget {
Text(
'>',
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.grey.shade700,
+14 -2
View File
@@ -50,7 +50,11 @@ class TrendChart extends StatelessWidget {
children: [
const Text(
'容量百分比变动趋势(近15天)',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
Row(
@@ -64,6 +68,7 @@ class TrendChart extends StatelessWidget {
Text(
'100',
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 10,
color: Colors.grey,
height: 1.0,
@@ -72,6 +77,7 @@ class TrendChart extends StatelessWidget {
Text(
'70',
style: TextStyle(
fontFamily: 'Flyme',
fontSize: 10,
color: Colors.grey,
height: 1.0,
@@ -139,6 +145,7 @@ class TrendChart extends StatelessWidget {
child: Text(
sevenDaysAgoDate,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 9,
color: Colors.grey,
height: 1.0,
@@ -152,6 +159,7 @@ class TrendChart extends StatelessWidget {
child: Text(
todayDate,
style: const TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 9,
color: Colors.black,
height: 1.0,
@@ -172,7 +180,11 @@ class TrendChart extends StatelessWidget {
padding: EdgeInsets.only(top: 8.0),
child: Text(
'暂无历史数据,请点击刷新按钮更新',
style: TextStyle(fontSize: 12, color: Colors.grey),
style: TextStyle(
fontFamily: 'HarmonyOS_Sans_SC',
fontSize: 12,
color: Colors.grey,
),
),
),
],
+4 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.5.0
version: 1.5.3
environment:
sdk: ^3.9.2
@@ -75,6 +75,9 @@ flutter:
weight: 400
- asset: assets/fonts/HarmonyOS_Sans_SC_Medium.ttf
weight: 500
- family: Flyme
fonts:
- asset: assets/fonts/flymeFont.ttf
assets:
- assets/icons/