Browse Source

refactor(agent): - 重构时间戳显示为行布局并添加AI生成标识

weicu
lxm 1 year ago
parent
commit
bb6812643f
  1. 104
      lib/modules/agent/views/message_bubble.dart

104
lib/modules/agent/views/message_bubble.dart

@ -46,8 +46,6 @@ class MessageBubble extends GetView<AgentController> {
isUser ? MainAxisAlignment.end : MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//if (!isUser) _buildAvatar(isUser, context),
//const SizedBox(width: 8),
Flexible(
child: Column(
crossAxisAlignment:
@ -90,21 +88,42 @@ class MessageBubble extends GetView<AgentController> {
const SizedBox(height: 4),
// 识别中的消息不显示时间
if (!isRecognizing)
Text(
timeFormat.format(timestamp),
style: TextStyle(
fontSize: 10,
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[400]
: Colors.grey[500],
fontWeight: FontWeight.w400,
),
Row(
mainAxisAlignment: isUser
? MainAxisAlignment.end
: MainAxisAlignment.start,
children: [
// 时间戳(左对齐或右对齐)
Text(
timeFormat.format(timestamp),
style: TextStyle(
fontSize: 10,
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[400]
: Colors.grey[500],
fontWeight: FontWeight.w400,
),
),
const Spacer(),
// AI标识(仅在AI消息时显示)
if (!isUser)
Padding(
padding: const EdgeInsets.only(left: 8),
child: Text(
"由AI生成".tr,
style: TextStyle(
fontSize: 8,
color: Colors.blue[600],
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
),
),
),
],
),
],
),
),
//const SizedBox(width: 8),
//if (isUser) _buildAvatar(isUser, context),
],
),
);
@ -125,65 +144,6 @@ class MessageBubble extends GetView<AgentController> {
}
}
/// 构建头像
// Widget _buildAvatar(bool isUser, BuildContext context) {
// if (isUser) {
// final storage = GetStorage();
// final localAvatarPath = storage.read<String>('local_avatar') ?? '';
// return Container(
// width: 36,
// height: 36,
// decoration: BoxDecoration(
// color: localAvatarPath.isEmpty ? Colors.grey[300] : null,
// borderRadius: BorderRadius.circular(18),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withOpacity(0.05),
// blurRadius: 2,
// offset: const Offset(0, 1),
// ),
// ],
// ),
// child: localAvatarPath.isNotEmpty
// ? ClipRRect(
// borderRadius: BorderRadius.circular(18),
// child: Image.file(
// File(localAvatarPath),
// fit: BoxFit.cover,
// ),
// )
// : Icon(
// Icons.person,
// color: Colors.grey[700],
// size: 20,
// ),
// );
// } else {
// // AI头像保持不变
// return Container(
// width: 36,
// height: 36,
// decoration: BoxDecoration(
// color: Theme.of(context).primaryColor,
// borderRadius: BorderRadius.circular(18),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withOpacity(0.05),
// blurRadius: 2,
// offset: const Offset(0, 1),
// ),
// ],
// ),
// child: Icon(
// Icons.smart_toy_outlined,
// color: Colors.white,
// size: 20,
// ),
// );
// }
// }
/// 构建消息内容
Widget _buildMessageContent(BuildContext context) {
// 如果是识别中的消息,添加特殊样式

Loading…
Cancel
Save