diff --git a/.gitignore b/.gitignore index 3820a95..a41a24b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,8 @@ migrate_working_dir/ .pub/ /build/ /coverage/ +/windows +/linux # Symbolication related app.*.symbols diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000..6aeba7e Binary files /dev/null and b/assets/logo.png differ diff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dart new file mode 100644 index 0000000..69d1b8c --- /dev/null +++ b/lib/pages/about_page.dart @@ -0,0 +1,173 @@ +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class AboutPage extends StatelessWidget { + const AboutPage({super.key}); + + @override + Widget build(BuildContext context) { + final isDark = Theme.of(context).brightness == Brightness.dark; + + return Scaffold( + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + appBar: AppBar( + title: const Text( + '关于', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontWeight: FontWeight.w500, + ), + ), + backgroundColor: Colors.transparent, + elevation: 0, + foregroundColor: Theme.of(context).iconTheme.color, + iconTheme: IconThemeData(color: Theme.of(context).iconTheme.color), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 40.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // 🟢 Logo 图片(替换之前的 Icon) + Container( + width: 120, + height: 120, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: isDark + ? Colors.grey.shade800 + : const Color(0xFFF0F4F8), + ), + child: ClipOval( + child: Image.asset( + 'assets/logo.png', + width: 120, + height: 120, + fit: BoxFit.contain, + ), + ), + ), + const SizedBox(height: 24), + // APP 名称 + const Text( + 'MEIZU Battery Healthy', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontSize: 24, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 8), + // 版本号 + Text( + '版本 1.7.0', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontSize: 14, + color: Colors.grey.shade500, + fontWeight: FontWeight.w400, + ), + ), + const SizedBox(height: 16), + // 分隔线 + Divider( + color: Colors.grey.shade300, + thickness: 0.5, + indent: 40, + endIndent: 40, + ), + const SizedBox(height: 16), + // 作者信息 + const Text( + '专机专配 · 仅针对魅族独家开发', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontSize: 14, + color: Colors.grey, + ), + ), + const SizedBox(height: 8), + Text( + '通过读取 BMS 日志直接获取电池真实数据', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontSize: 13, + color: Colors.grey.shade400, + ), + ), + const SizedBox(height: 24), + // Gitea 链接 + InkWell( + onTap: _launchUrl, + borderRadius: BorderRadius.circular(12), + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 20, + vertical: 12, + ), + decoration: BoxDecoration( + color: isDark + ? Colors.grey.shade800 + : const Color(0xFFF0F4F8), + borderRadius: BorderRadius.circular(12), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.code, + size: 18, + color: Theme.of(context).iconTheme.color, + ), + const SizedBox(width: 8), + Text( + '查看源码 / 反馈', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontSize: 14, + color: Theme.of(context).iconTheme.color, + ), + ), + const SizedBox(width: 4), + Icon( + Icons.open_in_new, + size: 14, + color: Colors.grey.shade500, + ), + ], + ), + ), + ), + const SizedBox(height: 40), + // 底部版本信息 + Text( + 'Made with ❤️ in Flyme · 2026', + style: TextStyle( + fontFamily: 'HarmonyOS_Sans_SC', + fontSize: 12, + color: Colors.grey.shade400, + ), + ), + ], + ), + ), + ), + ); + } + + Future _launchUrl() async { + const url = 'https://git.whitetop.xyz/lxh2875931338/MEIZU-Battery-Healthy'; + final uri = Uri.parse(url); + + try { + if (await canLaunchUrl(uri)) { + await launchUrl(uri, mode: LaunchMode.externalApplication); + } else { + debugPrint('无法打开链接: $url'); + } + } catch (e) { + debugPrint('打开链接失败: $e'); + } + } +} diff --git a/lib/pages/battery_health_page.dart b/lib/pages/battery_health_page.dart index 29570e7..b60515b 100644 --- a/lib/pages/battery_health_page.dart +++ b/lib/pages/battery_health_page.dart @@ -21,6 +21,7 @@ import '../widgets/charge_entry.dart'; import '../widgets/charge_detail_page.dart'; import '../widgets/trend_chart.dart'; import '../pages/changelog_page.dart'; +import '../pages/about_page.dart'; // --- 潘通色定义 --- const Color kHealthGreen = Color(0xFF00B140); @@ -668,23 +669,29 @@ class _BatteryHealthPageState extends State { ), ); break; - case 'dark_mode': + case 'about': // 🟢 新增 + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const AboutPage(), + ), + ); break; - case 'about': + case 'dark_mode': + // 夜间模式切换逻辑(1.7.0 再实现) break; } }, itemBuilder: (context) => [ const PopupMenuItem(value: 'changelog', child: Text('更新日志')), const PopupMenuItem( - value: 'dark_mode', - enabled: false, - child: Text('深色模式(开发中)'), + value: 'about', // 🟢 新增 + child: Text('关于'), ), const PopupMenuItem( - value: 'about', - enabled: false, - child: Text('关于(开发中)'), + value: 'dark_mode', + enabled: false, // 暂时灰显 + child: Text('夜间模式(开发中)'), ), ], ), diff --git a/pubspec.lock b/pubspec.lock index eced6ff..5310969 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -597,6 +597,70 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.4.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: b413d49b73867ac08dd2f9890efd3cc11f2a0e577618d50843440a1fb3776c32 + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.3.32" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.4.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.2.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.4.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.5" vector_graphics: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 576fea9..0fa0cab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,6 +39,7 @@ dependencies: flutter_svg: ^2.0.10+1 shared_preferences: ^2.2.0 flutter_markdown: ^0.7.0 + url_launcher: ^6.3.2 # The following adds the Cupertino Icons font to your application. @@ -82,6 +83,7 @@ flutter: assets: - assets/icons/ - assets/CHANGELOG.md + - assets/logo.png # To add assets to your application, add an assets section, like this: # assets: