177 lines
5.9 KiB
Dart
177 lines
5.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.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
|
|
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),
|
|
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),
|
|
// 源码链接按钮
|
|
InkWell(
|
|
onTap: () => _launchUrl(context), // 注意这里传入了 context
|
|
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<void> _launchUrl(BuildContext context) async {
|
|
const url = 'https://git.whitetop.xyz/lxh2875931338/MEIZU-Battery-Healthy';
|
|
final uri = Uri.parse(url);
|
|
|
|
try {
|
|
// ✅ 直接尝试打开,不再检查 canLaunchUrl
|
|
await launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
} catch (e) {
|
|
// 如果打开失败,复制链接并提示
|
|
debugPrint('打开链接失败: $e');
|
|
await Clipboard.setData(ClipboardData(text: url));
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text('无法自动打开浏览器,链接已复制到剪贴板。'),
|
|
duration: Duration(seconds: 3),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|