ui细节优化

This commit is contained in:
Developer
2026-04-01 04:45:33 +08:00
parent 6517a78c7e
commit 79f7269319
23 changed files with 3299 additions and 885 deletions

View File

@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:platform_info/platform_info.dart';
import 'package:flutter_udid/flutter_udid.dart';
import '../../../constants/app_constants.dart';
import '../../../controllers/shared_preferences_storage_controller.dart';
/// 时间: 2026-03-26
/// 功能: 应用信息页面
@@ -21,11 +22,15 @@ class AppInfoPage extends StatefulWidget {
class _AppInfoPageState extends State<AppInfoPage> {
String _udid = '获取中...';
bool _isDeveloperMode = false;
int _tapCount = 0;
DateTime? _lastTapTime;
@override
void initState() {
super.initState();
_loadUdid();
_loadDeveloperMode();
}
Future<void> _loadUdid() async {
@@ -45,6 +50,50 @@ class _AppInfoPageState extends State<AppInfoPage> {
}
}
Future<void> _loadDeveloperMode() async {
final isEnabled = await SharedPreferencesStorageController.getBool(
'developer_mode_enabled',
defaultValue: false,
);
if (mounted) {
setState(() {
_isDeveloperMode = isEnabled;
});
}
}
Future<void> _saveDeveloperMode(bool enabled) async {
await SharedPreferencesStorageController.setBool(
'developer_mode_enabled',
enabled,
);
}
void _onFrameworkTap() {
final now = DateTime.now();
if (_lastTapTime != null && now.difference(_lastTapTime!).inSeconds > 2) {
_tapCount = 0;
}
_lastTapTime = now;
_tapCount++;
if (_tapCount >= 5 && !_isDeveloperMode) {
setState(() {
_isDeveloperMode = true;
});
_saveDeveloperMode(true);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('开发者模式激活'),
duration: Duration(seconds: 2),
),
);
}
_tapCount = 0;
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -64,6 +113,20 @@ class _AppInfoPageState extends State<AppInfoPage> {
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
actions: [
if (_isDeveloperMode)
IconButton(
icon: const Icon(Icons.bug_report, color: Colors.green),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('调试信息已激活'),
duration: Duration(seconds: 2),
),
);
},
),
],
),
body: ListView(
padding: const EdgeInsets.all(16),
@@ -177,9 +240,15 @@ class _AppInfoPageState extends State<AppInfoPage> {
color: Colors.white.withValues(alpha: 0.9),
),
const SizedBox(width: 6),
const Text(
'框架 1.3',
style: TextStyle(fontSize: 12, color: Colors.white),
GestureDetector(
onTap: _onFrameworkTap,
child: const Text(
'框架 1.3',
style: TextStyle(
fontSize: 12,
color: Colors.white,
),
),
),
const SizedBox(width: 8),
Container(
@@ -188,14 +257,21 @@ class _AppInfoPageState extends State<AppInfoPage> {
vertical: 2,
),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.2),
color: _isDeveloperMode
? Colors.green.withValues(alpha: 0.3)
: Colors.white.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(4),
),
child: const Text(
child: Text(
'软件版本 1.5',
style: TextStyle(
fontSize: 10,
color: Colors.white,
color: _isDeveloperMode
? Colors.green
: Colors.white,
fontWeight: _isDeveloperMode
? FontWeight.bold
: FontWeight.normal,
),
),
),