mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
51 lines
1.6 KiB
Dart
51 lines
1.6 KiB
Dart
// lib/dashbot/widgets/chat_bubble.dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'content_renderer.dart';
|
|
|
|
class ChatBubble extends StatelessWidget {
|
|
final String message;
|
|
final bool isUser;
|
|
|
|
const ChatBubble({super.key, required this.message, this.isUser = false});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Align(
|
|
alignment: isUser ? Alignment.centerRight : Alignment.centerLeft,
|
|
child: Container(
|
|
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: isUser
|
|
? Theme.of(context).colorScheme.primaryContainer
|
|
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Flexible(
|
|
child: renderContent(context, message),
|
|
),
|
|
if (!isUser) ...[
|
|
const SizedBox(width: 8),
|
|
IconButton(
|
|
icon: const Icon(Icons.copy, size: 20),
|
|
tooltip: 'Copy Response',
|
|
onPressed: () {
|
|
Clipboard.setData(ClipboardData(text: message));
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Copied to clipboard')),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|