细节优化

This commit is contained in:
Developer
2026-03-31 20:15:16 +08:00
parent e3ca7db3cc
commit c897f50817
5 changed files with 725 additions and 502 deletions

View File

@@ -4,6 +4,7 @@
/// 最新变化: 重新设计布局,实现朋友圈风格的个人页面
import 'dart:convert';
import 'dart:math' show Random;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -66,6 +67,30 @@ class _ProfilePageState extends State<ProfilePage>
int _todayQuestions = 0;
int _todayLikes = 0;
// 可爱的emoji列表
final List<String> _avatars = [
'👤',
'😊',
'🎉',
'🌟',
'🔥',
'💎',
'🌈',
'🦋',
'🌸',
'🐱',
'🐶',
'🐼',
'🐨',
'🐵',
'🦄',
'🐸',
'🐹',
'🐰',
'🦊',
'🐻',
];
// 模拟用户数据
final Map<String, dynamic> _userData = {
'avatar': '👤', // 使用emoji代替网络图片
@@ -81,6 +106,14 @@ class _ProfilePageState extends State<ProfilePage>
'views': 3560,
};
// 更换头像
void _changeAvatar() {
final random = Random();
setState(() {
_userData['avatar'] = _avatars[random.nextInt(_avatars.length)];
});
}
@override
void initState() {
super.initState();
@@ -307,6 +340,7 @@ class _ProfilePageState extends State<ProfilePage>
);
}
},
onAvatarTap: _changeAvatar,
);
}
@@ -395,43 +429,43 @@ class _ProfilePageState extends State<ProfilePage>
),
const SizedBox(height: 16),
// === 互动统计卡片 ===
if (!_isStatsHidden)
Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.analytics_outlined,
Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.analytics_outlined,
color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
Text(
'诗词挑战',
style: TextStyle(
color: AppConstants.primaryColor,
size: 20,
fontSize: 16,
fontWeight: FontWeight.bold,
),
const SizedBox(width: 8),
Text(
'诗词挑战',
style: TextStyle(
color: AppConstants.primaryColor,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16),
),
],
),
const SizedBox(height: 16),
if (!_isStatsHidden)
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
@@ -439,35 +473,42 @@ class _ProfilePageState extends State<ProfilePage>
_buildInteractionItem('本周答题', '$_weekQuestions'),
_buildInteractionItem('答对次数', '$_correctAnswers'),
],
),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const PoetryLevelPage(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppConstants.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text(
'开始诗词答题',
style: TextStyle(fontSize: 16),
)
else
Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(
'数据已隐藏',
style: TextStyle(color: Colors.grey[500], fontSize: 14),
),
),
),
],
),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const PoetryLevelPage(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: AppConstants.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text('开始诗词答题', style: TextStyle(fontSize: 16)),
),
),
],
),
),
],
),
);