告警中心的二级详情页面+信息中心的页面+对接机器人接口
This commit is contained in:
279
lib/features/v2/my/presentation/pages/profile_detail_page.dart
Normal file
279
lib/features/v2/my/presentation/pages/profile_detail_page.dart
Normal file
@@ -0,0 +1,279 @@
|
||||
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';
|
||||
|
||||
/// 个人信息详情页
|
||||
class ProfileDetailPage extends StatelessWidget {
|
||||
const ProfileDetailPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F7FA),
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Color(0xFF1D2129)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: const Text(
|
||||
'个人信息',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
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: [
|
||||
// 头像卡片
|
||||
_buildAvatarCard(user),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 信息列表
|
||||
_buildInfoCard(user),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 操作按钮
|
||||
_buildActionButtons(context),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 头像卡片
|
||||
Widget _buildAvatarCard(UserEntity user) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 32),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x0D000000),
|
||||
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,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// 用户名
|
||||
Text(
|
||||
'@${user.username}',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: const Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 构建头像
|
||||
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),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 信息卡片
|
||||
Widget _buildInfoCard(UserEntity user) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildInfoItem(
|
||||
icon: Icons.person_outline,
|
||||
label: '用户ID',
|
||||
value: user.userId,
|
||||
showDivider: true,
|
||||
),
|
||||
_buildInfoItem(
|
||||
icon: Icons.account_circle_outlined,
|
||||
label: '用户名',
|
||||
value: user.username,
|
||||
showDivider: true,
|
||||
),
|
||||
_buildInfoItem(
|
||||
icon: Icons.badge_outlined,
|
||||
label: '昵称',
|
||||
value: user.nickname,
|
||||
showDivider: user.email != null || user.phone != null,
|
||||
),
|
||||
if (user.email != null)
|
||||
_buildInfoItem(
|
||||
icon: Icons.email_outlined,
|
||||
label: '邮箱',
|
||||
value: user.email!,
|
||||
showDivider: user.phone != null,
|
||||
),
|
||||
if (user.phone != null)
|
||||
_buildInfoItem(
|
||||
icon: Icons.phone_outlined,
|
||||
label: '手机号',
|
||||
value: user.phone!,
|
||||
showDivider: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 信息项
|
||||
Widget _buildInfoItem({
|
||||
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: [
|
||||
Icon(icon, size: 22, color: const Color(0xFF86909C)),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
color: Color(0xFF1D2129),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (showDivider)
|
||||
Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
color: const Color(0xFFF2F3F5),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 操作按钮
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user