import 'package:flutter/material.dart'; class MessageBubble extends StatelessWidget { final String message; final DateTime time; final bool isMe; const MessageBubble({ super.key, required this.message, required this.time, required this.isMe, }); @override Widget build(BuildContext context) { return Align( // Выравниваем вправо, если это мое сообщение, и влево — если чужое alignment: isMe ? Alignment.centerRight : Alignment.centerLeft, child: Container( margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14), constraints: BoxConstraints( // Чтобы баббл не растягивался на весь экран, если текста мало maxWidth: MediaQuery.of(context).size.width * 0.75, ), decoration: BoxDecoration( color: isMe ? Theme.of(context).colorScheme.primary : Colors.grey[300], borderRadius: BorderRadius.only( topLeft: const Radius.circular(16), topRight: const Radius.circular(16), // Скругляем углы по-разному для "хвостика" сообщения bottomLeft: Radius.circular(isMe ? 16 : 0), bottomRight: Radius.circular(isMe ? 0 : 16), ), ), child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( message, style: TextStyle( color: isMe ? Colors.white : Colors.black87, fontSize: 16, ), ), const SizedBox(height: 4), Text( time.toIso8601String(), style: TextStyle( color: isMe ? Colors.white70 : Colors.black54, fontSize: 10, ), ), ], ), ), ); } }