feat(mobile-app): add app version info section to profile page
Display detailed application and device information at the bottom of the profile page, below the "绑定邮箱" (Bind Email) menu item. Information displayed: - App version (e.g., v1.0.0) - Build number - Package name - Device model (brand + model for Android, model for iOS) - OS version (Android version with SDK / iOS version) - Platform (Android/iOS) - Copyright notice Uses package_info_plus and device_info_plus packages which are already dependencies in the project. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5d671bf5ec
commit
116a304431
|
|
@ -4,6 +4,8 @@ import 'package:flutter/services.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import '../../../../core/di/injection_container.dart';
|
||||
import '../../../../routes/route_paths.dart';
|
||||
import 'dart:async';
|
||||
|
|
@ -61,6 +63,14 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
Timer? _timer;
|
||||
int _remainingSeconds = 66942; // 18:35:42
|
||||
|
||||
// 应用版本信息
|
||||
String _appVersion = '--';
|
||||
String _buildNumber = '--';
|
||||
String _packageName = '--';
|
||||
String _deviceModel = '--';
|
||||
String _osVersion = '--';
|
||||
String _platform = '--';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -68,6 +78,46 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
// 先同步检查本地头像,再异步加载其他数据
|
||||
_checkLocalAvatarSync();
|
||||
_loadUserData();
|
||||
_loadAppInfo();
|
||||
}
|
||||
|
||||
/// 加载应用信息
|
||||
Future<void> _loadAppInfo() async {
|
||||
try {
|
||||
// 加载包信息
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
// 加载设备信息
|
||||
final deviceInfoPlugin = DeviceInfoPlugin();
|
||||
String deviceModel = '';
|
||||
String osVersion = '';
|
||||
String platform = '';
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
final androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
deviceModel = '${androidInfo.brand} ${androidInfo.model}';
|
||||
osVersion = 'Android ${androidInfo.version.release} (SDK ${androidInfo.version.sdkInt})';
|
||||
platform = 'Android';
|
||||
} else if (Platform.isIOS) {
|
||||
final iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
deviceModel = iosInfo.model;
|
||||
osVersion = '${iosInfo.systemName} ${iosInfo.systemVersion}';
|
||||
platform = 'iOS';
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_appVersion = packageInfo.version;
|
||||
_buildNumber = packageInfo.buildNumber;
|
||||
_packageName = packageInfo.packageName;
|
||||
_deviceModel = deviceModel;
|
||||
_osVersion = osVersion;
|
||||
_platform = platform;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('[ProfilePage] 加载应用信息失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
/// 同步检查本地头像文件(在 build 之前快速获取)
|
||||
|
|
@ -674,6 +724,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
const SizedBox(height: 16),
|
||||
// 设置菜单
|
||||
_buildSettingsMenu(),
|
||||
const SizedBox(height: 16),
|
||||
// 应用版本信息
|
||||
_buildAppVersionInfo(),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
@ -1434,4 +1487,108 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建应用版本信息
|
||||
Widget _buildAppVersionInfo() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFF5E6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: const Color(0x33D4AF37),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题
|
||||
const Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.info_outline,
|
||||
size: 20,
|
||||
color: Color(0xFF8B5A2B),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
'应用信息',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.5,
|
||||
color: Color(0xFF5D4037),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 版本信息列表
|
||||
_buildVersionInfoRow('应用版本', 'v$_appVersion'),
|
||||
const SizedBox(height: 8),
|
||||
_buildVersionInfoRow('构建号', _buildNumber),
|
||||
const SizedBox(height: 8),
|
||||
_buildVersionInfoRow('包名', _packageName),
|
||||
const Divider(
|
||||
height: 24,
|
||||
color: Color(0x33D4AF37),
|
||||
),
|
||||
// 设备信息
|
||||
_buildVersionInfoRow('设备型号', _deviceModel),
|
||||
const SizedBox(height: 8),
|
||||
_buildVersionInfoRow('系统版本', _osVersion),
|
||||
const SizedBox(height: 8),
|
||||
_buildVersionInfoRow('平台', _platform),
|
||||
const SizedBox(height: 12),
|
||||
// 版权信息
|
||||
Center(
|
||||
child: Text(
|
||||
'© ${DateTime.now().year} RWADurian. All rights reserved.',
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontFamily: 'Inter',
|
||||
height: 1.5,
|
||||
color: Color(0x995D4037),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建版本信息行
|
||||
Widget _buildVersionInfoRow(String label, String value) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'Inter',
|
||||
height: 1.5,
|
||||
color: Color(0xCC5D4037),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.5,
|
||||
color: Color(0xFF5D4037),
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue