The-Agency/lib/ui/widgets/chat/bubbles/user_bubble.dart

61 lines
1.7 KiB
Dart

import "dart:typed_data";
import "package:shadcn_flutter/shadcn_flutter.dart";
import "../../../models/attachment.dart";
import "../attachment_preview.dart";
import "../../../../src/session/session_types.dart";
class UserBubble extends StatelessWidget {
const UserBubble({
super.key,
required this.content,
this.attachments,
});
final String content;
final List<MessageAttachment>? attachments;
@override
Widget build(BuildContext context) {
final atts = attachments;
return Align(
alignment: Alignment.centerRight,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (atts != null && atts.isNotEmpty) ...[
SingleChildScrollView(
scrollDirection: Axis.horizontal,
reverse: true,
child: Row(
children: [
for (final att in atts)
Padding(
padding: const EdgeInsets.only(left: 8),
child: AttachmentItem(
attachment: Attachment(
name: att.name,
mimeType: att.mimeType,
data: Uint8List.fromList(att.data),
),
onRemove: () {},
),
),
],
),
),
const Gap(6),
],
OutlinedContainer(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
backgroundColor: Theme.of(context).colorScheme.border,
child: SelectableText(content),
),
],
),
);
}
}