message bubble in chat view
This commit is contained in:
parent
19d429d739
commit
46e292193c
57
packages/simplex_app/lib/widgets/message_bubble.dart
Normal file
57
packages/simplex_app/lib/widgets/message_bubble.dart
Normal file
@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:simplex_chat/constants.dart';
|
||||
|
||||
class MessageBubble extends StatefulWidget {
|
||||
const MessageBubble({
|
||||
Key? key,
|
||||
this.sender,
|
||||
this.text,
|
||||
this.isUser,
|
||||
}) : super(key: key);
|
||||
final String? sender;
|
||||
final String? text;
|
||||
final bool? isUser;
|
||||
|
||||
@override
|
||||
_MessageBubbleState createState() => _MessageBubbleState();
|
||||
}
|
||||
|
||||
class _MessageBubbleState extends State<MessageBubble> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
widget.isUser! ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
widget.sender!,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 2.0),
|
||||
Material(
|
||||
borderRadius: widget.isUser!
|
||||
? const BorderRadius.only(
|
||||
topLeft: Radius.circular(10),
|
||||
bottomLeft: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10))
|
||||
: const BorderRadius.only(
|
||||
topRight: Radius.circular(10),
|
||||
bottomLeft: Radius.circular(10),
|
||||
bottomRight: Radius.circular(10)),
|
||||
elevation: 1.0,
|
||||
color: widget.isUser! ? Colors.teal : kPrimaryColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
|
||||
child: Text(
|
||||
widget.text!,
|
||||
style: const TextStyle(fontSize: 15, color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user