331 lines
11 KiB
Dart
331 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../components/appbar.dart';
|
|
import '../../../services/update_service.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import '../../../services/update_dialog_service.dart';
|
|
import 'dart:developer' as developer;
|
|
import 'user_manual.dart';
|
|
import 'privacy_policy.dart';
|
|
|
|
class AboutUsPage extends StatefulWidget {
|
|
const AboutUsPage({super.key});
|
|
|
|
@override
|
|
State<AboutUsPage> createState() => _AboutUsPageState();
|
|
}
|
|
|
|
class _AboutUsPageState extends State<AboutUsPage> {
|
|
final UpdateDialogService _updateDialogService = UpdateDialogService();
|
|
bool _checking = false;
|
|
String _currentVersion = '';
|
|
bool _hasUpdate = false; // 是否有可用更新
|
|
String _updateStatus = ''; // 更新状态文本
|
|
dynamic _versionInfo; // 保存版本信息
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_getCurrentVersion();
|
|
// 页面加载时自动检查更新,但不弹出对话框
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
_silentCheckUpdate();
|
|
});
|
|
}
|
|
|
|
// 获取当前版本号
|
|
Future<void> _getCurrentVersion() async {
|
|
final packageInfo = await PackageInfo.fromPlatform();
|
|
setState(() {
|
|
_currentVersion = 'V${packageInfo.version}';
|
|
});
|
|
}
|
|
|
|
// 静默检查更新(不弹窗)
|
|
Future<void> _silentCheckUpdate() async {
|
|
try {
|
|
setState(() {
|
|
_checking = true;
|
|
});
|
|
|
|
final versionInfo = await _updateDialogService.checkForUpdate();
|
|
|
|
if (mounted) {
|
|
setState(() {
|
|
_checking = false;
|
|
_hasUpdate = versionInfo != null;
|
|
_updateStatus = _hasUpdate ? '发现新版本' : '已是最新版本';
|
|
_versionInfo = versionInfo; // 保存版本信息以供后续使用
|
|
});
|
|
}
|
|
} catch (e) {
|
|
if (mounted) {
|
|
setState(() {
|
|
_checking = false;
|
|
_updateStatus = '检查失败';
|
|
});
|
|
}
|
|
developer.log('静默检查更新失败: $e');
|
|
}
|
|
}
|
|
|
|
// 手动检查更新
|
|
Future<void> _checkUpdate() async {
|
|
if (_checking) return;
|
|
|
|
if (_hasUpdate && _versionInfo != null) {
|
|
// 如果已经检测到有更新,直接显示更新对话框
|
|
_updateDialogService.showUpdateDialog(context, _versionInfo);
|
|
} else {
|
|
// 重新检查更新
|
|
final versionInfo = await _updateDialogService.checkForUpdate(
|
|
showLoading: true,
|
|
updateCheckingState: (checking) {
|
|
if (mounted) setState(() => _checking = checking);
|
|
},
|
|
|
|
);
|
|
|
|
if (mounted) {
|
|
setState(() {
|
|
_hasUpdate = versionInfo != null;
|
|
_updateStatus = _hasUpdate ? '发现新版本' : '已是最新版本';
|
|
_versionInfo = versionInfo; // 更新保存的版本信息
|
|
});
|
|
|
|
// 如果有更新,显示更新对话框
|
|
if (versionInfo != null) {
|
|
_updateDialogService.showUpdateDialog(context, versionInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 导航到用户手册页面
|
|
void _navigateToUserManual() {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const UserManualPage()),
|
|
);
|
|
}
|
|
|
|
// 导航到隐私政策页面
|
|
void _navigateToPrivacyPolicy() {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => const PrivacyPolicyPage()),
|
|
);
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
appBar: const CustomAppBar(title: '关于我们'),
|
|
body: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xff0C0C16),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Center(
|
|
child: Column(
|
|
children: [
|
|
const CircleAvatar(
|
|
radius: 45,
|
|
backgroundImage: AssetImage('images/logo.png'),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'版本号 $_currentVersion',
|
|
style: const TextStyle(fontSize: 14, color: Color(0xffC1C1C1)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 50),
|
|
|
|
// 检测更新
|
|
_buildInfoBox(
|
|
leftText: '检测更新',
|
|
rightWidget: _buildUpdateStatus(),
|
|
onTap: _checkUpdate,
|
|
),
|
|
const SizedBox(height: 10),
|
|
|
|
// 第二行 - 版权信息
|
|
_buildInfoBox(
|
|
leftText: '版权所有',
|
|
rightText: '东霓信息科技(济南)有限公司',
|
|
),
|
|
const SizedBox(height: 10),
|
|
|
|
// 第四行 - 用户手册
|
|
_buildInfoBox(
|
|
leftText: '用户手册',
|
|
rightIcon: 'images/right_arraw.png',
|
|
onTap: _navigateToUserManual,
|
|
),
|
|
const SizedBox(height: 10),
|
|
|
|
// 第五行 - 隐私政策
|
|
_buildInfoBox(
|
|
leftText: '隐私政策',
|
|
rightIcon: 'images/right_arraw.png',
|
|
onTap: _navigateToPrivacyPolicy,
|
|
),
|
|
// const SizedBox(height: 20),
|
|
// 添加团队信息
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
child: const Center(
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// 左列
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('发起人', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('投资人', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('技术总监', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('产品经理', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('UI设计师', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('引擎开发', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('前端开发', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('后端开发', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('动画师', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('建模师', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('DEMO', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
],
|
|
),
|
|
SizedBox(width: 8), // 添加间距
|
|
// 右列
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('Seanan', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('老浣先生', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('sladro', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('Ariel', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('雨婷', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('CH', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('辣辣', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('昊天', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('ffa245', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('小王', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
Text('红猪', style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0)),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 16),
|
|
// 底部公司信息
|
|
Column(
|
|
children: [
|
|
Text(
|
|
'东霓信息科技(济南)有限公司出品',
|
|
style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0),
|
|
),
|
|
SizedBox(height: 4),
|
|
Text(
|
|
'鲁ICP备2021036050号-6A',
|
|
style: TextStyle(fontSize: 13, color: Color(0xffC1C1C1), height: 1.0),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// 构建更新状态指示器
|
|
Widget _buildUpdateStatus() {
|
|
return Row(
|
|
children: [
|
|
if (_hasUpdate)
|
|
Container(
|
|
width: 8,
|
|
height: 8,
|
|
margin: const EdgeInsets.only(right: 5),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.red,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
Text(
|
|
_checking
|
|
? '检查中...'
|
|
: (_updateStatus.isEmpty ? '点击检查' : _updateStatus),
|
|
style: TextStyle(
|
|
color: _hasUpdate
|
|
? const Color(0xFFFF5252) // 有更新时使用红色
|
|
: const Color(0xffC1C1C1), // 默认颜色
|
|
fontSize: 14,
|
|
fontWeight: _hasUpdate ? FontWeight.bold : FontWeight.normal,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildInfoBox({
|
|
required String leftText,
|
|
String? rightText,
|
|
String? rightIcon,
|
|
Widget? rightWidget,
|
|
VoidCallback? onTap,
|
|
}) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
height: 61,
|
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
|
|
width: 345,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF1F212E),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
leftText,
|
|
style: const TextStyle(color: Color(0xffC1C1C1), fontSize: 16),
|
|
),
|
|
if (rightWidget != null)
|
|
rightWidget
|
|
else if (rightText != null)
|
|
Text(
|
|
rightText,
|
|
style: const TextStyle(color: Color(0xffC1C1C1), fontSize: 14),
|
|
)
|
|
else if (rightIcon != null)
|
|
Image.asset(
|
|
rightIcon,
|
|
width: 8,
|
|
height: 16,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|