细节优化
This commit is contained in:
@@ -117,88 +117,90 @@ class _ActiveSearchPageState extends State<ActiveSearchPage>
|
|||||||
children: [
|
children: [
|
||||||
// 自定义标题栏
|
// 自定义标题栏
|
||||||
if (isInTabBarView)
|
if (isInTabBarView)
|
||||||
Container(
|
SafeArea(
|
||||||
height: 56,
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
height: 56,
|
||||||
color: Colors.white,
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Row(
|
color: Colors.white,
|
||||||
children: [
|
child: Row(
|
||||||
// 返回按钮
|
children: [
|
||||||
//todo
|
// 返回按钮
|
||||||
IconButton(
|
//todo
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.black87),
|
IconButton(
|
||||||
onPressed: () {
|
icon: const Icon(Icons.arrow_back, color: Colors.black87),
|
||||||
// 检查是否可以返回,避免黑屏
|
onPressed: () {
|
||||||
if (Navigator.of(context).canPop()) {
|
// 检查是否可以返回,避免黑屏
|
||||||
Navigator.of(context).pop();
|
if (Navigator.of(context).canPop()) {
|
||||||
} else {
|
Navigator.of(context).pop();
|
||||||
// 如果无法返回(如在 TabBarView 中),跳转到主页
|
} else {
|
||||||
Navigator.of(context).pushReplacement(
|
// 如果无法返回(如在 TabBarView 中),跳转到主页
|
||||||
MaterialPageRoute(
|
Navigator.of(context).pushReplacement(
|
||||||
builder: (_) => const MainNavigation(),
|
MaterialPageRoute(
|
||||||
),
|
builder: (_) => const MainNavigation(),
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
},
|
}
|
||||||
tooltip: '返回上一页',
|
},
|
||||||
),
|
tooltip: '返回上一页',
|
||||||
// 标题
|
),
|
||||||
Expanded(
|
// 标题
|
||||||
child: Row(
|
Expanded(
|
||||||
children: [
|
child: Row(
|
||||||
const Icon(
|
children: [
|
||||||
Icons.travel_explore,
|
const Icon(
|
||||||
size: 20,
|
Icons.travel_explore,
|
||||||
color: Colors.black87,
|
size: 20,
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
const Text(
|
|
||||||
'诗词搜索',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Colors.black87,
|
color: Colors.black87,
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 8),
|
||||||
],
|
const Text(
|
||||||
),
|
'诗词搜索',
|
||||||
),
|
style: TextStyle(
|
||||||
// 更多按钮
|
fontSize: 18,
|
||||||
IconButton(
|
fontWeight: FontWeight.w600,
|
||||||
icon: const Icon(Icons.more_vert, color: Colors.black87),
|
color: Colors.black87,
|
||||||
onPressed: () {
|
),
|
||||||
// 更多按钮的点击事件
|
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => Container(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.history),
|
|
||||||
title: const Text('搜索历史'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
// 实现搜索历史功能
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.settings),
|
|
||||||
title: const Text('搜索设置'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
// 实现搜索设置功能
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
tooltip: '更多',
|
// 更多按钮
|
||||||
),
|
IconButton(
|
||||||
],
|
icon: const Icon(Icons.more_vert, color: Colors.black87),
|
||||||
|
onPressed: () {
|
||||||
|
// 更多按钮的点击事件
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.history),
|
||||||
|
title: const Text('搜索历史(开发中)'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
// 实现搜索历史功能
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.settings),
|
||||||
|
title: const Text('搜索设置(开发中)'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
// 实现搜索设置功能
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
tooltip: '更多',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 搜索内容区域
|
// 搜索内容区域
|
||||||
@@ -209,9 +211,9 @@ class _ActiveSearchPageState extends State<ActiveSearchPage>
|
|||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(
|
padding: EdgeInsets.fromLTRB(
|
||||||
AppConstants.pageHorizontalPadding,
|
AppConstants.pageHorizontalPadding,
|
||||||
isInTabBarView ? 16 : 8,
|
isInTabBarView ? 8 : 4,
|
||||||
AppConstants.pageHorizontalPadding,
|
AppConstants.pageHorizontalPadding,
|
||||||
8,
|
4,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
@@ -256,10 +258,9 @@ class _ActiveSearchPageState extends State<ActiveSearchPage>
|
|||||||
onChanged: (_) => setState(() {}),
|
onChanged: (_) => setState(() {}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
|
||||||
Wrap(
|
Wrap(
|
||||||
spacing: 8,
|
spacing: 4,
|
||||||
runSpacing: 8,
|
runSpacing: 4,
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Text('', style: TextStyle(fontSize: 13)),
|
const Text('', style: TextStyle(fontSize: 13)),
|
||||||
|
|||||||
@@ -141,8 +141,38 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
_buildTitleSection(),
|
_buildTitleSection(),
|
||||||
if (widget.poetryData.drtime.isNotEmpty) ...[
|
if (widget.poetryData.drtime.isNotEmpty) ...[
|
||||||
_buildContentSection(context),
|
_buildContentSection(context),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 3),
|
||||||
],
|
],
|
||||||
|
// 精选诗句标签 - 放在缝隙位置
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 2,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'精选诗句',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: AppConstants.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Icon(
|
||||||
|
Icons.format_quote,
|
||||||
|
color: AppConstants.primaryColor,
|
||||||
|
size: 14,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
_buildNameSection(),
|
_buildNameSection(),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
if (widget.keywordList.isNotEmpty) ...[
|
if (widget.keywordList.isNotEmpty) ...[
|
||||||
@@ -333,7 +363,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
margin: const EdgeInsets.only(bottom: 8),
|
margin: EdgeInsets.zero,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [
|
colors: [
|
||||||
@@ -359,27 +389,6 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.format_quote,
|
|
||||||
color: AppConstants.primaryColor,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'精选诗句',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: AppConstants.primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onLongPress: () =>
|
onLongPress: () =>
|
||||||
CopyUtils.showCopyDialog(context, widget.poetryData.name, '诗词'),
|
CopyUtils.showCopyDialog(context, widget.poetryData.name, '诗词'),
|
||||||
@@ -409,7 +418,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
widget.poetryData.name,
|
_formatPoetryText(widget.poetryData.name),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
@@ -424,6 +433,22 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _formatPoetryText(String text) {
|
||||||
|
// 检查文本长度(文字+符号)
|
||||||
|
if (text.length < 10) {
|
||||||
|
return text; // 小于10个字,不换行
|
||||||
|
}
|
||||||
|
|
||||||
|
// 找到第一个逗号的位置
|
||||||
|
final commaIndex = text.indexOf(',');
|
||||||
|
if (commaIndex != -1) {
|
||||||
|
// 在第一个逗号处添加换行
|
||||||
|
return text.replaceFirst(',', ',\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
return text; // 没有逗号,保持原样
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildKeywordSection() {
|
Widget _buildKeywordSection() {
|
||||||
final isLoading = widget.sectionLoadingStates?['keywords'] ?? false;
|
final isLoading = widget.sectionLoadingStates?['keywords'] ?? false;
|
||||||
|
|
||||||
@@ -441,7 +466,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 8,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
@@ -449,7 +474,7 @@ class _PoetryCardState extends State<PoetryCard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Text(
|
||||||
'关键词加载中...',
|
'关键词加载中...',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import '../../constants/app_constants.dart';
|
|||||||
import '../../services/network_listener_service.dart';
|
import '../../services/network_listener_service.dart';
|
||||||
import 'guide/tongji.dart';
|
import 'guide/tongji.dart';
|
||||||
|
|
||||||
/// 时间: 2026-03-25
|
/// 时间: 2026-03-31
|
||||||
/// 功能: 个人信息卡片组件
|
/// 功能: 个人信息卡片组件
|
||||||
/// 介绍: 可收起/张开的个人信息卡片,支持下拉张开,上滑收起
|
/// 介绍: 可收起/张开的个人信息卡片,支持下拉张开,上滑收起
|
||||||
/// 最新变化: 优化动画效果,添加毛玻璃背景,修复布局问题
|
/// 最新变化: 重新设计为苹果风格,优化动画效果,改进布局结构,提升用户体验
|
||||||
|
|
||||||
class PersonalCard extends StatefulWidget {
|
class PersonalCard extends StatefulWidget {
|
||||||
final Map<String, dynamic> userData;
|
final Map<String, dynamic> userData;
|
||||||
@@ -18,14 +18,16 @@ class PersonalCard extends StatefulWidget {
|
|||||||
final ValueChanged<bool>? onExpandChanged;
|
final ValueChanged<bool>? onExpandChanged;
|
||||||
final int currentPage;
|
final int currentPage;
|
||||||
final ValueChanged<int>? onPageChanged;
|
final ValueChanged<int>? onPageChanged;
|
||||||
|
final VoidCallback? onAvatarTap;
|
||||||
|
|
||||||
const PersonalCard({
|
const PersonalCard({
|
||||||
super.key,
|
super.key,
|
||||||
required this.userData,
|
required this.userData,
|
||||||
this.isExpanded,
|
this.isExpanded,
|
||||||
this.onExpandChanged,
|
this.onExpandChanged,
|
||||||
this.currentPage = 1,
|
this.currentPage = 0,
|
||||||
this.onPageChanged,
|
this.onPageChanged,
|
||||||
|
this.onAvatarTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -36,6 +38,8 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
late bool _isExpanded;
|
late bool _isExpanded;
|
||||||
late String _currentTip;
|
late String _currentTip;
|
||||||
bool _isOnline = true;
|
bool _isOnline = true;
|
||||||
|
bool _isEditingNickname = false;
|
||||||
|
late TextEditingController _nicknameController;
|
||||||
|
|
||||||
// 累计数据
|
// 累计数据
|
||||||
int _totalViews = 0;
|
int _totalViews = 0;
|
||||||
@@ -47,10 +51,19 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
_isExpanded = widget.isExpanded ?? false;
|
_isExpanded = widget.isExpanded ?? false;
|
||||||
_currentTip = _getRandomTip();
|
_currentTip = _getRandomTip();
|
||||||
|
_nicknameController = TextEditingController(
|
||||||
|
text: widget.userData['nickname'] ?? '诗词爱好者',
|
||||||
|
);
|
||||||
_loadOnlineStatus();
|
_loadOnlineStatus();
|
||||||
_loadTotalStats();
|
_loadTotalStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_nicknameController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _loadTotalStats() async {
|
Future<void> _loadTotalStats() async {
|
||||||
final views = await StatisticsManager().getTotalViews();
|
final views = await StatisticsManager().getTotalViews();
|
||||||
final likes = await StatisticsManager().getTotalLikes();
|
final likes = await StatisticsManager().getTotalLikes();
|
||||||
@@ -213,37 +226,54 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return Container(
|
||||||
behavior: HitTestBehavior.translucent,
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
child: Container(
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
borderRadius: BorderRadius.circular(20),
|
||||||
gradient: LinearGradient(
|
boxShadow: [
|
||||||
colors: [
|
BoxShadow(
|
||||||
AppConstants.primaryColor.withValues(alpha: 0.95),
|
color: Colors.black.withOpacity(0.1),
|
||||||
AppConstants.primaryColor.withValues(alpha: 0.9),
|
blurRadius: 10,
|
||||||
AppConstants.primaryColor.withValues(alpha: 0.85),
|
offset: const Offset(0, 2),
|
||||||
],
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
child: AnimatedContainer(
|
),
|
||||||
duration: const Duration(milliseconds: 400),
|
child: ClipRRect(
|
||||||
curve: Curves.easeInOut,
|
borderRadius: BorderRadius.circular(20),
|
||||||
padding: _isExpanded
|
child: Container(
|
||||||
? const EdgeInsets.all(16)
|
decoration: BoxDecoration(
|
||||||
: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
gradient: LinearGradient(
|
||||||
height: _isExpanded ? null : 72,
|
colors: [
|
||||||
child: Stack(
|
AppConstants.primaryColor.withOpacity(0.95),
|
||||||
children: [
|
AppConstants.primaryColor.withOpacity(0.85),
|
||||||
// 毛玻璃效果层(在文字按钮下层,背景色上层)
|
],
|
||||||
BackdropFilter(
|
begin: Alignment.topLeft,
|
||||||
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
end: Alignment.bottomRight,
|
||||||
child: Container(color: Colors.transparent),
|
),
|
||||||
|
),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _toggleExpand,
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: AppConstants.animationDurationMedium,
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
padding: _isExpanded
|
||||||
|
? const EdgeInsets.all(20)
|
||||||
|
: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
// 毛玻璃效果层
|
||||||
|
BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
|
||||||
|
child: Container(color: Colors.transparent),
|
||||||
|
),
|
||||||
|
// 内容层
|
||||||
|
_isExpanded
|
||||||
|
? _buildExpandedContent()
|
||||||
|
: _buildCollapsedContent(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
// 内容层(在毛玻璃效果上层)
|
),
|
||||||
_isExpanded ? _buildExpandedContent() : _buildCollapsedContent(),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -253,105 +283,168 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
Widget _buildCollapsedContent() {
|
Widget _buildCollapsedContent() {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
// 左侧区域:可点击展开/收起
|
// 头像
|
||||||
Expanded(
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: _toggleExpand,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
// 头像在左边
|
|
||||||
AnimatedContainer(
|
|
||||||
duration: const Duration(milliseconds: 400),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
CircleAvatar(
|
|
||||||
radius: 24,
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
child: Text(
|
|
||||||
widget.userData['avatar'] ?? '👤',
|
|
||||||
style: const TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Container(
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: _isOnline
|
|
||||||
? AppConstants.successColor
|
|
||||||
: Colors.red,
|
|
||||||
border: Border.all(color: Colors.white, width: 2),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
_isOnline ? Icons.check : Icons.close,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 10,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
// 名称和签名
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
widget.userData['nickname'] ?? '诗词爱好者',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
widget.userData['signature'] ?? '人生如诗,岁月如歌',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white70,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
// 右侧区域:标签栏,不可触发展开/收起
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
onTap: widget.onAvatarTap,
|
||||||
onTap: () {},
|
child: Stack(
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
_buildTabLabel(0, '卡片'),
|
Container(
|
||||||
_buildTabLabel(1, '设置'),
|
width: 48,
|
||||||
_buildTabLabel(2, '更多'),
|
height: 48,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.1),
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
widget.userData['avatar'] ?? '👤',
|
||||||
|
style: const TextStyle(fontSize: 32),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 在线状态指示器
|
||||||
|
Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Container(
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: _isOnline ? AppConstants.successColor : Colors.red,
|
||||||
|
border: Border.all(color: Colors.white, width: 2),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
// 名称和签名
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.userData['nickname'] ?? '诗词爱好者',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
widget.userData['signature'] ?? '人生如诗,岁月如歌',
|
||||||
|
style: const TextStyle(color: Colors.white70, fontSize: 14),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 页面切换提示
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
// 选项提示
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
_buildCollapsedTabLabel(0, '卡片'),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
_buildCollapsedTabLabel(1, '设置'),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
_buildCollapsedTabLabel(2, '更多'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 滑动指示箭头
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
AnimatedRotation(
|
||||||
|
turns: _isExpanded ? 0.5 : 0,
|
||||||
|
duration: AppConstants.animationDurationMedium,
|
||||||
|
child: const Icon(
|
||||||
|
Icons.keyboard_arrow_down,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
const Icon(Icons.swap_horiz, color: Colors.white70, size: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildExpandedContent() {
|
Widget _buildExpandedContent() {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
children: [
|
||||||
|
// 头部信息
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
// 头像
|
||||||
|
GestureDetector(
|
||||||
|
onTap: widget.onAvatarTap,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 64,
|
||||||
|
height: 64,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.1),
|
||||||
|
blurRadius: 6,
|
||||||
|
offset: const Offset(0, 3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
widget.userData['avatar'] ?? '👤',
|
||||||
|
style: const TextStyle(fontSize: 40),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// 在线状态指示器
|
||||||
|
Positioned(
|
||||||
|
bottom: 2,
|
||||||
|
right: 2,
|
||||||
|
child: Container(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: _isOnline
|
||||||
|
? AppConstants.successColor
|
||||||
|
: Colors.red,
|
||||||
|
border: Border.all(color: Colors.white, width: 2),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
// 个人信息
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -359,29 +452,84 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
// 昵称和等级
|
// 昵称和等级
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Expanded(
|
||||||
widget.userData['nickname'] ?? '诗词爱好者',
|
child: _isEditingNickname
|
||||||
style: const TextStyle(
|
? TextField(
|
||||||
color: Colors.white,
|
controller: _nicknameController,
|
||||||
fontSize: 16,
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
color: AppConstants.primaryColor,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
focusedBorder: InputBorder.none,
|
||||||
|
enabledBorder: InputBorder.none,
|
||||||
|
hintText: '输入昵称',
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
color: AppConstants.primaryColor,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (value) {
|
||||||
|
setState(() {
|
||||||
|
widget.userData['nickname'] = value;
|
||||||
|
_isEditingNickname = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
_isEditingNickname = true;
|
||||||
|
_nicknameController.text =
|
||||||
|
widget.userData['nickname'] ?? '诗词爱好者';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
widget.userData['nickname'] ?? '诗词爱好者',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
_isEditingNickname = !_isEditingNickname;
|
||||||
|
if (_isEditingNickname) {
|
||||||
|
_nicknameController.text =
|
||||||
|
widget.userData['nickname'] ?? '诗词爱好者';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
_isEditingNickname ? Icons.check : Icons.edit,
|
||||||
|
color: Colors.white70,
|
||||||
|
size: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 8),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 6,
|
horizontal: 8,
|
||||||
vertical: 2,
|
vertical: 2,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withValues(alpha: 0.2),
|
color: Colors.white.withOpacity(0.2),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.userData['level'] ?? 'Lv.1',
|
widget.userData['level'] ?? 'Lv.1',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 10,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -394,200 +542,139 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
widget.userData['signature'] ?? '人生如诗,岁月如歌',
|
widget.userData['signature'] ?? '人生如诗,岁月如歌',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white70,
|
color: Colors.white70,
|
||||||
fontSize: 12,
|
fontSize: 14,
|
||||||
height: 1.2,
|
height: 1.3,
|
||||||
),
|
),
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
|
||||||
// 累计统计卡片
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 12,
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white.withValues(alpha: 0.15),
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'累计',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white70,
|
|
||||||
fontSize: 11,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
_buildStatItem('浏览', _totalViews),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
_buildStatItem('点赞', _totalLikes),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
_buildStatItem('答题', _totalQuestions),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
],
|
||||||
// 头像在右边
|
),
|
||||||
AnimatedContainer(
|
const SizedBox(height: 10),
|
||||||
duration: const Duration(milliseconds: 400),
|
// 统计数据卡片
|
||||||
curve: Curves.easeInOut,
|
Container(
|
||||||
child: Stack(
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
_buildStatItem('浏览', _totalViews),
|
||||||
radius: 36,
|
Container(
|
||||||
backgroundColor: Colors.white,
|
width: 1,
|
||||||
child: Text(
|
height: 40,
|
||||||
widget.userData['avatar'] ?? '👤',
|
color: Colors.white.withOpacity(0.2),
|
||||||
style: const TextStyle(fontSize: 20),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Positioned(
|
_buildStatItem('点赞', _totalLikes),
|
||||||
bottom: 0,
|
Container(
|
||||||
right: 0,
|
width: 1,
|
||||||
child: Container(
|
height: 40,
|
||||||
width: 18,
|
color: Colors.white.withOpacity(0.2),
|
||||||
height: 18,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: _isOnline
|
|
||||||
? AppConstants.successColor
|
|
||||||
: Colors.red,
|
|
||||||
border: Border.all(color: Colors.white, width: 2),
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
_isOnline ? Icons.check : Icons.close,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 10,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
_buildStatItem('答题', _totalQuestions),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
// 祝福语卡片
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
|
_showRandomTip();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.1),
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'💡 $_currentTip',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: AppConstants.primaryColor,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
height: 1.3,
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
// 在线状态开关
|
||||||
|
Switch(
|
||||||
|
value: _isOnline,
|
||||||
|
onChanged: (value) {
|
||||||
|
_toggleOnlineStatus();
|
||||||
|
},
|
||||||
|
activeColor: AppConstants.primaryColor,
|
||||||
|
inactiveTrackColor: Colors.grey.shade300,
|
||||||
|
inactiveThumbColor: Colors.grey,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
// 页面标签
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_buildTabLabel(0, '卡片', Icons.credit_card),
|
||||||
|
const SizedBox(width: 32),
|
||||||
|
_buildTabLabel(1, '设置', Icons.settings),
|
||||||
|
const SizedBox(width: 32),
|
||||||
|
_buildTabLabel(2, '更多', Icons.more_horiz),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
// 操作按钮 - 文本祝福语
|
// 页面指示器
|
||||||
Row(
|
Container(
|
||||||
children: [
|
height: 3,
|
||||||
Expanded(
|
margin: const EdgeInsets.symmetric(horizontal: 40),
|
||||||
child: GestureDetector(
|
decoration: BoxDecoration(
|
||||||
onTap: () {
|
color: Colors.white.withOpacity(0.2),
|
||||||
HapticFeedback.lightImpact();
|
borderRadius: BorderRadius.circular(1.5),
|
||||||
_showRandomTip();
|
),
|
||||||
},
|
child: Stack(
|
||||||
child: Container(
|
children: [
|
||||||
padding: const EdgeInsets.symmetric(
|
AnimatedContainer(
|
||||||
horizontal: 16,
|
duration: AppConstants.animationDurationMedium,
|
||||||
vertical: 12,
|
curve: Curves.easeOut,
|
||||||
),
|
width: (MediaQuery.of(context).size.width - 160) / 3,
|
||||||
decoration: BoxDecoration(
|
height: 3,
|
||||||
color: Colors.white,
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(12),
|
color: Colors.white,
|
||||||
boxShadow: [
|
borderRadius: BorderRadius.circular(1.5),
|
||||||
BoxShadow(
|
),
|
||||||
color: Colors.black.withValues(alpha: 0.1),
|
margin: EdgeInsets.only(
|
||||||
blurRadius: 4,
|
left:
|
||||||
offset: const Offset(0, 2),
|
((MediaQuery.of(context).size.width - 160) / 3) *
|
||||||
),
|
widget.currentPage,
|
||||||
],
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'💡:$_currentTip',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: AppConstants.primaryColor,
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
maxLines: 3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
// 在线状态开关
|
|
||||||
Switch(
|
|
||||||
value: _isOnline,
|
|
||||||
onChanged: (value) {
|
|
||||||
_toggleOnlineStatus();
|
|
||||||
},
|
|
||||||
activeColor: AppConstants.primaryColor,
|
|
||||||
inactiveTrackColor: Colors.grey.shade300,
|
|
||||||
inactiveThumbColor: Colors.grey,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
// 标签栏
|
|
||||||
GestureDetector(
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
onTap: () {},
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
// 页面指示器
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
height: 3,
|
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white.withValues(alpha: 0.3),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
// 背景条
|
|
||||||
Container(
|
|
||||||
height: 3,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white.withValues(alpha: 0.3),
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// 滑动指示器
|
|
||||||
AnimatedContainer(
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
width: MediaQuery.of(context).size.width / 3 - 40,
|
|
||||||
height: 3,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(2),
|
|
||||||
),
|
|
||||||
margin: EdgeInsets.only(
|
|
||||||
left:
|
|
||||||
(MediaQuery.of(context).size.width / 3 - 40) *
|
|
||||||
widget.currentPage,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// 页面标签
|
|
||||||
_buildTabLabel(0, '卡片'),
|
|
||||||
_buildTabLabel(1, '设置'),
|
|
||||||
_buildTabLabel(2, '更多'),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -601,7 +688,7 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
value.toString(),
|
value.toString(),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 16,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -614,8 +701,34 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTabLabel(int index, String label) {
|
Widget _buildTabLabel(int index, String label, IconData icon) {
|
||||||
// === 单个页面标签:可点击切换到对应页面 ===
|
final isSelected = widget.currentPage == index;
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
widget.onPageChanged?.call(index);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
icon,
|
||||||
|
color: isSelected ? Colors.white : Colors.white70,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
color: isSelected ? Colors.white : Colors.white70,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCollapsedTabLabel(int index, String label) {
|
||||||
final isSelected = widget.currentPage == index;
|
final isSelected = widget.currentPage == index;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -623,28 +736,19 @@ class PersonalCardState extends State<PersonalCard> {
|
|||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
child: Column(
|
decoration: BoxDecoration(
|
||||||
mainAxisSize: MainAxisSize.min,
|
color: isSelected
|
||||||
children: [
|
? Colors.white.withOpacity(0.2)
|
||||||
Icon(
|
: Colors.transparent,
|
||||||
index == 0
|
borderRadius: BorderRadius.circular(12),
|
||||||
? Icons.credit_card
|
),
|
||||||
: index == 1
|
child: Text(
|
||||||
? Icons.settings
|
label,
|
||||||
: Icons.more_horiz,
|
style: TextStyle(
|
||||||
color: isSelected ? Colors.white : Colors.white70,
|
color: isSelected ? Colors.white : Colors.white70,
|
||||||
size: 16,
|
fontSize: 12,
|
||||||
),
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||||
const SizedBox(height: 2),
|
),
|
||||||
Text(
|
|
||||||
label,
|
|
||||||
style: TextStyle(
|
|
||||||
color: isSelected ? Colors.white : Colors.white70,
|
|
||||||
fontSize: 10,
|
|
||||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
/// 最新变化: 重新设计布局,实现朋友圈风格的个人页面
|
/// 最新变化: 重新设计布局,实现朋友圈风格的个人页面
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:math' show Random;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -66,6 +67,30 @@ class _ProfilePageState extends State<ProfilePage>
|
|||||||
int _todayQuestions = 0;
|
int _todayQuestions = 0;
|
||||||
int _todayLikes = 0;
|
int _todayLikes = 0;
|
||||||
|
|
||||||
|
// 可爱的emoji列表
|
||||||
|
final List<String> _avatars = [
|
||||||
|
'👤',
|
||||||
|
'😊',
|
||||||
|
'🎉',
|
||||||
|
'🌟',
|
||||||
|
'🔥',
|
||||||
|
'💎',
|
||||||
|
'🌈',
|
||||||
|
'🦋',
|
||||||
|
'🌸',
|
||||||
|
'🐱',
|
||||||
|
'🐶',
|
||||||
|
'🐼',
|
||||||
|
'🐨',
|
||||||
|
'🐵',
|
||||||
|
'🦄',
|
||||||
|
'🐸',
|
||||||
|
'🐹',
|
||||||
|
'🐰',
|
||||||
|
'🦊',
|
||||||
|
'🐻',
|
||||||
|
];
|
||||||
|
|
||||||
// 模拟用户数据
|
// 模拟用户数据
|
||||||
final Map<String, dynamic> _userData = {
|
final Map<String, dynamic> _userData = {
|
||||||
'avatar': '👤', // 使用emoji代替网络图片
|
'avatar': '👤', // 使用emoji代替网络图片
|
||||||
@@ -81,6 +106,14 @@ class _ProfilePageState extends State<ProfilePage>
|
|||||||
'views': 3560,
|
'views': 3560,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 更换头像
|
||||||
|
void _changeAvatar() {
|
||||||
|
final random = Random();
|
||||||
|
setState(() {
|
||||||
|
_userData['avatar'] = _avatars[random.nextInt(_avatars.length)];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.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),
|
const SizedBox(height: 16),
|
||||||
// === 互动统计卡片 ===
|
// === 互动统计卡片 ===
|
||||||
if (!_isStatsHidden)
|
Container(
|
||||||
Container(
|
width: double.infinity,
|
||||||
width: double.infinity,
|
padding: const EdgeInsets.all(20),
|
||||||
padding: const EdgeInsets.all(20),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: Colors.white,
|
||||||
color: Colors.white,
|
borderRadius: BorderRadius.circular(16),
|
||||||
borderRadius: BorderRadius.circular(16),
|
boxShadow: [
|
||||||
boxShadow: [
|
BoxShadow(
|
||||||
BoxShadow(
|
color: Colors.black.withValues(alpha: 0.08),
|
||||||
color: Colors.black.withValues(alpha: 0.08),
|
blurRadius: 10,
|
||||||
blurRadius: 10,
|
offset: const Offset(0, 2),
|
||||||
offset: const Offset(0, 2),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
children: [
|
Row(
|
||||||
Row(
|
children: [
|
||||||
children: [
|
Icon(
|
||||||
Icon(
|
Icons.analytics_outlined,
|
||||||
Icons.analytics_outlined,
|
color: AppConstants.primaryColor,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'诗词挑战',
|
||||||
|
style: TextStyle(
|
||||||
color: AppConstants.primaryColor,
|
color: AppConstants.primaryColor,
|
||||||
size: 20,
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
),
|
||||||
Text(
|
],
|
||||||
'诗词挑战',
|
),
|
||||||
style: TextStyle(
|
const SizedBox(height: 16),
|
||||||
color: AppConstants.primaryColor,
|
if (!_isStatsHidden)
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
@@ -439,35 +473,42 @@ class _ProfilePageState extends State<ProfilePage>
|
|||||||
_buildInteractionItem('本周答题', '$_weekQuestions'),
|
_buildInteractionItem('本周答题', '$_weekQuestions'),
|
||||||
_buildInteractionItem('答对次数', '$_correctAnswers'),
|
_buildInteractionItem('答对次数', '$_correctAnswers'),
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
const SizedBox(height: 16),
|
else
|
||||||
SizedBox(
|
Center(
|
||||||
width: double.infinity,
|
child: Padding(
|
||||||
child: ElevatedButton(
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
onPressed: () {
|
child: Text(
|
||||||
Navigator.push(
|
'数据已隐藏',
|
||||||
context,
|
style: TextStyle(color: Colors.grey[500], fontSize: 14),
|
||||||
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),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
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)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -371,9 +371,61 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
|
|||||||
),
|
),
|
||||||
trailing: Icon(Icons.chevron_right, color: Colors.grey[400]),
|
trailing: Icon(Icons.chevron_right, color: Colors.grey[400]),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
// 显示对话框提示鸿蒙设备设置方法
|
||||||
context,
|
showDialog(
|
||||||
MaterialPageRoute(builder: (context) => const WidgetsPage()),
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.info_outline, color: AppConstants.primaryColor),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
const Text('桌面卡片设置'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: const Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'鸿蒙设备请在桌面端设置:',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Text('1. 长按桌面空白处'),
|
||||||
|
Text('2. 选择「情景诗词」卡片'),
|
||||||
|
Text('3. 添加后点击桌面卡片即可设置'),
|
||||||
|
SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
'注意:该页面设置对鸿蒙设备不生效',
|
||||||
|
style: TextStyle(color: Colors.orange, fontSize: 12),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('取消'),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const WidgetsPage(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: AppConstants.primaryColor,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
child: const Text('仍要进入'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user