Files
feature-next-arch/lib/features/v2/my/presentation/widgets/user_profile_card.dart
Songzex 7c01229b9e 1:修复远程遥控控制状态显示不正确的问题
2:更换端口映射为测试服的8081-59003,9001-59004
2026-08-26 14:23:20 +08:00

121 lines
3.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:maibu_satabot_v2/core/utils/image_url_util.dart';
import 'package:maibu_satabot_v2/features/v2/my/presentation/constants/my_constants.dart';
/// 用户信息卡片组件(100% 还原设计稿)
class UserProfileCard extends StatelessWidget {
const UserProfileCard({
super.key,
required this.name,
required this.role,
this.avatar,
this.onTap,
});
final String name;
final String role;
final String? avatar;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(20, 70, 20, 50),
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF165DFF),
Color(0xFF0E42CC),
],
),
),
child: Row(
children: [
// 头像
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.white,
width: 2,
),
),
child: ClipOval(
child: _buildAvatar(),
),
),
const SizedBox(width: 14),
// 用户信息
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
letterSpacing: 0.5,
),
),
const SizedBox(height: 6),
Text(
role,
style: TextStyle(
fontSize: 13,
color: Colors.white.withOpacity(0.85),
letterSpacing: 0.3,
),
),
],
),
),
// 箭头
Icon(
Icons.chevron_right,
color: Colors.white.withOpacity(0.9),
size: 24,
),
],
),
),
);
}
Widget _buildAvatar() {
// 后端可能返回相对路径,先补全为完整服务器地址
final url = ImageUrlUtil.resolve(avatar);
// 如果有头像 URL,显示网络图片
if (url != null && url.isNotEmpty) {
return Image.network(
url,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return _buildDefaultAvatar();
},
);
}
// 否则显示默认头像
return _buildDefaultAvatar();
}
Widget _buildDefaultAvatar() {
return Container(
color: Colors.white,
child: Icon(
Icons.person,
size: 32,
color: const Color(0xFF165DFF),
),
);
}
}