init
This commit is contained in:
576
client/lib/features/profile/widgets/about_dialog.dart
Normal file
576
client/lib/features/profile/widgets/about_dialog.dart
Normal file
@@ -0,0 +1,576 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import '../../../core/theme/app_colors.dart';
|
||||
|
||||
/// 关于应用对话框
|
||||
class AboutAppDialog extends StatefulWidget {
|
||||
const AboutAppDialog({super.key});
|
||||
|
||||
@override
|
||||
State<AboutAppDialog> createState() => _AboutAppDialogState();
|
||||
}
|
||||
|
||||
class _AboutAppDialogState extends State<AboutAppDialog> {
|
||||
PackageInfo? _packageInfo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadPackageInfo();
|
||||
}
|
||||
|
||||
Future<void> _loadPackageInfo() async {
|
||||
try {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_packageInfo = packageInfo;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// 如果获取包信息失败,使用默认值
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_packageInfo = PackageInfo(
|
||||
appName: 'AI英语学习',
|
||||
packageName: 'com.example.ai_english_learning',
|
||||
version: '1.0.0',
|
||||
buildNumber: '1',
|
||||
buildSignature: '',
|
||||
installerStore: null,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// 应用图标和名称
|
||||
_buildAppHeader(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 版本信息
|
||||
_buildVersionInfo(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 应用描述
|
||||
_buildAppDescription(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 开发团队信息
|
||||
_buildTeamInfo(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 联系方式
|
||||
_buildContactInfo(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 法律信息
|
||||
_buildLegalInfo(),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 关闭按钮
|
||||
_buildCloseButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建应用头部
|
||||
Widget _buildAppHeader() {
|
||||
return Column(
|
||||
children: [
|
||||
// 应用图标
|
||||
Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.3),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.school,
|
||||
color: Colors.white,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 应用名称
|
||||
Text(
|
||||
_packageInfo?.appName ?? 'AI英语学习',
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// 应用标语
|
||||
Text(
|
||||
'智能化英语学习助手',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建版本信息
|
||||
Widget _buildVersionInfo() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColors.outline.withOpacity(0.2),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildInfoRow(
|
||||
'版本号',
|
||||
_packageInfo?.version ?? '1.0.0',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildInfoRow(
|
||||
'构建号',
|
||||
_packageInfo?.buildNumber ?? '1',
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildInfoRow(
|
||||
'发布日期',
|
||||
'2024年1月',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建应用描述
|
||||
Widget _buildAppDescription() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'应用介绍',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'AI英语学习是一款基于人工智能技术的英语学习应用,提供个性化的学习方案,包括单词记忆、语法练习、听力训练、口语练习等功能,帮助用户高效提升英语水平。',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建团队信息
|
||||
Widget _buildTeamInfo() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'开发团队',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildTeamMember('产品经理', 'Alice Wang'),
|
||||
_buildTeamMember('技术负责人', 'Bob Chen'),
|
||||
_buildTeamMember('UI/UX设计师', 'Carol Li'),
|
||||
_buildTeamMember('前端开发', 'David Zhang'),
|
||||
_buildTeamMember('后端开发', 'Eva Liu'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建团队成员信息
|
||||
Widget _buildTeamMember(String role, String name) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
role,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
name,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建联系信息
|
||||
Widget _buildContactInfo() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'联系我们',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildContactItem(
|
||||
Icons.email,
|
||||
'邮箱',
|
||||
'support@aienglish.com',
|
||||
() => _copyToClipboard('support@aienglish.com', '邮箱地址已复制'),
|
||||
),
|
||||
_buildContactItem(
|
||||
Icons.language,
|
||||
'官网',
|
||||
'www.aienglish.com',
|
||||
() => _copyToClipboard('www.aienglish.com', '网址已复制'),
|
||||
),
|
||||
_buildContactItem(
|
||||
Icons.phone,
|
||||
'客服电话',
|
||||
'400-123-4567',
|
||||
() => _copyToClipboard('400-123-4567', '电话号码已复制'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建联系项目
|
||||
Widget _buildContactItem(
|
||||
IconData icon,
|
||||
String label,
|
||||
String value,
|
||||
VoidCallback onTap,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 16,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'$label: ',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.primary,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.copy,
|
||||
size: 16,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建法律信息
|
||||
Widget _buildLegalInfo() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'法律信息',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildLegalLink('用户协议', () => _showLegalDocument('用户协议')),
|
||||
_buildLegalLink('隐私政策', () => _showLegalDocument('隐私政策')),
|
||||
_buildLegalLink('开源许可', () => _showLicenses()),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'© 2024 AI英语学习团队. 保留所有权利.',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建法律链接
|
||||
Widget _buildLegalLink(String text, VoidCallback onTap) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.primary,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建信息行
|
||||
Widget _buildInfoRow(String label, String value) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.onSurface,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建关闭按钮
|
||||
Widget _buildCloseButton() {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'关闭',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 复制到剪贴板
|
||||
void _copyToClipboard(String text, String message) {
|
||||
Clipboard.setData(ClipboardData(text: text));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示法律文档
|
||||
void _showLegalDocument(String title) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: SingleChildScrollView(
|
||||
child: Text(
|
||||
title == '用户协议'
|
||||
? _getUserAgreementText()
|
||||
: _getPrivacyPolicyText(),
|
||||
style: const TextStyle(fontSize: 14, height: 1.5),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('关闭'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示开源许可
|
||||
void _showLicenses() {
|
||||
showLicensePage(
|
||||
context: context,
|
||||
applicationName: _packageInfo?.appName ?? 'AI英语学习',
|
||||
applicationVersion: _packageInfo?.version ?? '1.0.0',
|
||||
applicationIcon: Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
AppColors.primary,
|
||||
AppColors.primary.withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.school,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取用户协议文本
|
||||
String _getUserAgreementText() {
|
||||
return '''
|
||||
欢迎使用AI英语学习应用!
|
||||
|
||||
1. 服务条款
|
||||
本应用为用户提供英语学习服务,包括但不限于单词学习、语法练习、听力训练等功能。
|
||||
|
||||
2. 用户责任
|
||||
用户应当合法使用本应用,不得进行任何违法违规行为。
|
||||
|
||||
3. 隐私保护
|
||||
我们重视用户隐私,详细信息请查看隐私政策。
|
||||
|
||||
4. 知识产权
|
||||
本应用的所有内容均受知识产权法保护。
|
||||
|
||||
5. 免责声明
|
||||
本应用仅供学习参考,不承担任何学习效果保证责任。
|
||||
|
||||
6. 协议修改
|
||||
我们保留随时修改本协议的权利,修改后的协议将在应用内公布。
|
||||
|
||||
如有疑问,请联系客服:support@aienglish.com
|
||||
''';
|
||||
}
|
||||
|
||||
/// 获取隐私政策文本
|
||||
String _getPrivacyPolicyText() {
|
||||
return '''
|
||||
AI英语学习隐私政策
|
||||
|
||||
1. 信息收集
|
||||
我们可能收集以下信息:
|
||||
- 账户信息(用户名、邮箱等)
|
||||
- 学习数据(学习进度、成绩等)
|
||||
- 设备信息(设备型号、操作系统等)
|
||||
|
||||
2. 信息使用
|
||||
收集的信息用于:
|
||||
- 提供个性化学习服务
|
||||
- 改进应用功能
|
||||
- 发送重要通知
|
||||
|
||||
3. 信息保护
|
||||
我们采用行业标准的安全措施保护用户信息。
|
||||
|
||||
4. 信息共享
|
||||
除法律要求外,我们不会与第三方共享用户个人信息。
|
||||
|
||||
5. Cookie使用
|
||||
我们可能使用Cookie来改善用户体验。
|
||||
|
||||
6. 政策更新
|
||||
本隐私政策可能会定期更新,请关注最新版本。
|
||||
|
||||
联系我们:support@aienglish.com
|
||||
''';
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示关于应用对话框的便捷方法
|
||||
void showAboutAppDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => const AboutAppDialog(),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user