2026-06-02 08:40:50 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
|
|
|
|
import 'package:maibu_satabot_v2/core/app/app_user_state.dart';
|
|
|
|
|
import 'package:maibu_satabot_v2/core/domain/entities/user_entity.dart';
|
2026-08-18 08:52:33 +08:00
|
|
|
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
2026-06-02 08:40:50 +08:00
|
|
|
|
|
|
|
|
/// 个人信息详情页
|
|
|
|
|
class ProfileDetailPage extends StatelessWidget {
|
|
|
|
|
const ProfileDetailPage({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
2026-08-18 08:52:33 +08:00
|
|
|
backgroundColor: context.appColors.pageBackground,
|
2026-06-02 08:40:50 +08:00
|
|
|
appBar: AppBar(
|
|
|
|
|
elevation: 0,
|
|
|
|
|
leading: IconButton(
|
2026-08-18 08:52:33 +08:00
|
|
|
icon: Icon(Icons.arrow_back, color: context.appColors.textPrimary),
|
2026-06-02 08:40:50 +08:00
|
|
|
onPressed: () => Navigator.pop(context),
|
|
|
|
|
),
|
|
|
|
|
title: const Text(
|
|
|
|
|
'个人信息',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
),
|
|
|
|
|
body: BlocBuilder<AppUserCubit, AppUserState>(
|
|
|
|
|
builder: (context, state) {
|
|
|
|
|
final user = state.user;
|
|
|
|
|
|
|
|
|
|
if (user == null) {
|
|
|
|
|
return const Center(
|
|
|
|
|
child: Text('未登录'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
children: [
|
|
|
|
|
// 头像卡片
|
2026-08-18 08:52:33 +08:00
|
|
|
_buildAvatarCard(context, user),
|
2026-06-02 08:40:50 +08:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
|
|
|
|
// 信息列表
|
2026-08-18 08:52:33 +08:00
|
|
|
_buildInfoCard(context, user),
|
2026-06-02 08:40:50 +08:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
|
|
|
|
|
// 操作按钮
|
|
|
|
|
_buildActionButtons(context),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 头像卡片
|
2026-08-18 08:52:33 +08:00
|
|
|
Widget _buildAvatarCard(BuildContext context, UserEntity user) {
|
2026-06-02 08:40:50 +08:00
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 32),
|
|
|
|
|
decoration: BoxDecoration(
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.cardBackground,
|
2026-06-02 08:40:50 +08:00
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.cardShadow,
|
2026-06-02 08:40:50 +08:00
|
|
|
blurRadius: 8,
|
|
|
|
|
offset: const Offset(0, 2),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
// 头像
|
|
|
|
|
Container(
|
|
|
|
|
width: 100,
|
|
|
|
|
height: 100,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: const Color(0xFF165DFF),
|
|
|
|
|
width: 3,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: ClipOval(
|
|
|
|
|
child: _buildAvatar(user.avatar),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
// 昵称
|
|
|
|
|
Text(
|
|
|
|
|
user.nickname,
|
2026-08-18 08:52:33 +08:00
|
|
|
style: TextStyle(
|
2026-06-02 08:40:50 +08:00
|
|
|
fontSize: 20,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.textPrimary,
|
2026-06-02 08:40:50 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
// 用户名
|
|
|
|
|
Text(
|
|
|
|
|
'@${user.username}',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.textTertiary,
|
2026-06-02 08:40:50 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 构建头像
|
|
|
|
|
Widget _buildAvatar(String? avatarUrl) {
|
|
|
|
|
if (avatarUrl != null && avatarUrl.isNotEmpty) {
|
|
|
|
|
return Image.network(
|
|
|
|
|
avatarUrl,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
errorBuilder: (context, error, stackTrace) {
|
|
|
|
|
return _buildDefaultAvatar();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return _buildDefaultAvatar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 默认头像
|
|
|
|
|
Widget _buildDefaultAvatar() {
|
|
|
|
|
return Container(
|
|
|
|
|
color: const Color(0xFFF5F7FA),
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.person,
|
|
|
|
|
size: 50,
|
|
|
|
|
color: Color(0xFF165DFF),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 信息卡片
|
2026-08-18 08:52:33 +08:00
|
|
|
Widget _buildInfoCard(BuildContext context, UserEntity user) {
|
2026-06-02 08:40:50 +08:00
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.cardBackground,
|
2026-06-02 08:40:50 +08:00
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.cardShadow,
|
2026-06-02 08:40:50 +08:00
|
|
|
blurRadius: 8,
|
|
|
|
|
offset: const Offset(0, 2),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
_buildInfoItem(
|
2026-08-18 08:52:33 +08:00
|
|
|
context,
|
2026-06-02 08:40:50 +08:00
|
|
|
icon: Icons.person_outline,
|
|
|
|
|
label: '用户ID',
|
|
|
|
|
value: user.userId,
|
|
|
|
|
showDivider: true,
|
|
|
|
|
),
|
|
|
|
|
_buildInfoItem(
|
2026-08-18 08:52:33 +08:00
|
|
|
context,
|
2026-06-02 08:40:50 +08:00
|
|
|
icon: Icons.account_circle_outlined,
|
|
|
|
|
label: '用户名',
|
|
|
|
|
value: user.username,
|
|
|
|
|
showDivider: true,
|
|
|
|
|
),
|
|
|
|
|
_buildInfoItem(
|
2026-08-18 08:52:33 +08:00
|
|
|
context,
|
2026-06-02 08:40:50 +08:00
|
|
|
icon: Icons.badge_outlined,
|
|
|
|
|
label: '昵称',
|
|
|
|
|
value: user.nickname,
|
|
|
|
|
showDivider: user.email != null || user.phone != null,
|
|
|
|
|
),
|
|
|
|
|
if (user.email != null)
|
|
|
|
|
_buildInfoItem(
|
2026-08-18 08:52:33 +08:00
|
|
|
context,
|
2026-06-02 08:40:50 +08:00
|
|
|
icon: Icons.email_outlined,
|
|
|
|
|
label: '邮箱',
|
|
|
|
|
value: user.email!,
|
|
|
|
|
showDivider: user.phone != null,
|
|
|
|
|
),
|
|
|
|
|
if (user.phone != null)
|
|
|
|
|
_buildInfoItem(
|
2026-08-18 08:52:33 +08:00
|
|
|
context,
|
2026-06-02 08:40:50 +08:00
|
|
|
icon: Icons.phone_outlined,
|
|
|
|
|
label: '手机号',
|
|
|
|
|
value: user.phone!,
|
|
|
|
|
showDivider: false,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 信息项
|
2026-08-18 08:52:33 +08:00
|
|
|
Widget _buildInfoItem(
|
|
|
|
|
BuildContext context, {
|
2026-06-02 08:40:50 +08:00
|
|
|
required IconData icon,
|
|
|
|
|
required String label,
|
|
|
|
|
required String value,
|
|
|
|
|
required bool showDivider,
|
|
|
|
|
}) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
2026-08-18 08:52:33 +08:00
|
|
|
Icon(icon, size: 22, color: context.appColors.textTertiary),
|
2026-06-02 08:40:50 +08:00
|
|
|
const SizedBox(width: 12),
|
|
|
|
|
Text(
|
|
|
|
|
label,
|
2026-08-18 08:52:33 +08:00
|
|
|
style: TextStyle(
|
2026-06-02 08:40:50 +08:00
|
|
|
fontSize: 15,
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.textTertiary,
|
2026-06-02 08:40:50 +08:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 2,
|
|
|
|
|
child: Text(
|
|
|
|
|
value,
|
2026-08-18 08:52:33 +08:00
|
|
|
style: TextStyle(
|
2026-06-02 08:40:50 +08:00
|
|
|
fontSize: 15,
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.textPrimary,
|
2026-06-02 08:40:50 +08:00
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (showDivider)
|
|
|
|
|
Divider(
|
|
|
|
|
height: 1,
|
|
|
|
|
thickness: 1,
|
2026-08-18 08:52:33 +08:00
|
|
|
color: context.appColors.divider,
|
2026-06-02 08:40:50 +08:00
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 操作按钮
|
|
|
|
|
Widget _buildActionButtons(BuildContext context) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
// 编辑资料按钮(预留)
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 48,
|
|
|
|
|
child: ElevatedButton.icon(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// TODO: 跳转到编辑资料页面
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
const SnackBar(content: Text('编辑功能开发中...')),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
icon: const Icon(Icons.edit, size: 20),
|
|
|
|
|
label: const Text(
|
|
|
|
|
'编辑资料',
|
|
|
|
|
style: TextStyle(fontSize: 16),
|
|
|
|
|
),
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF165DFF),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
elevation: 0,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|