Commit dc93e9c8 authored by Wilko Manger's avatar Wilko Manger

Put time and sent state on one line if possible

parent 7351135e
......@@ -74,7 +74,7 @@ class _ImageContentState extends State<ImageContent> {
),
),
),
if (bubble.isEndOfGroup) _MessageInfo(),
if (MessageInfo.necessary(context)) _MessageInfo(),
if (bubble.message.isMine && bubble.isStartOfGroup) _Sender(),
Positioned.fill(
child: Clickable(
......
......@@ -38,7 +38,7 @@ class RedactedContent extends StatelessWidget {
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
children: <Widget>[
Sender(),
if (Sender.necessary(context)) Sender(),
DefaultTextStyle(
style: TextStyle(
color: themed(
......@@ -51,8 +51,11 @@ class RedactedContent extends StatelessWidget {
),
child: Redacted(event: bubble.message.event),
),
SizedBox(height: 4),
MessageInfo()
if (MessageInfo.necessary(context))
Padding(
padding: EdgeInsets.only(top: 4),
child: MessageInfo(),
),
],
),
),
......
......@@ -52,14 +52,18 @@ class TextContent extends StatelessWidget {
padding: EdgeInsets.all(8).copyWith(
left: needsBorder ? _replyLeftPadding : null,
),
child: Column(
crossAxisAlignment: bubble.message.isMine
? CrossAxisAlignment.end
: CrossAxisAlignment.start,
child: Wrap(
runAlignment:
bubble.message.isMine ? WrapAlignment.end : WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.end,
spacing: 4,
runSpacing: 4,
children: <Widget>[
Sender(
padding: EdgeInsets.only(bottom: 4),
),
if (Sender.necessary(context))
Padding(
padding: EdgeInsets.only(bottom: 4),
child: Sender(),
),
// Only build the replied-to message if this itself
// is not a replied-to message (to prevent very long
// reply chains)
......@@ -72,8 +76,11 @@ class TextContent extends StatelessWidget {
child: Container() // TODO: REPLY
),
_Content(),
SizedBox(height: 4),
MessageInfo(),
if (MessageInfo.necessary(context))
Padding(
padding: EdgeInsets.only(top: 4),
child: MessageInfo(),
),
],
),
),
......@@ -119,7 +126,7 @@ class _Content extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Sender(),
if (Sender.necessary(context)) Sender(),
Flexible(
child: html,
)
......
......@@ -313,14 +313,16 @@ class Clickable extends StatelessWidget {
class MessageInfo extends StatelessWidget {
const MessageInfo({Key key}) : super(key: key);
static bool necessary(BuildContext context) {
final bubble = MessageBubble.of(context);
return bubble.isEndOfGroup;
}
@override
Widget build(BuildContext context) {
final bubble = MessageBubble.of(context);
if (!bubble.isEndOfGroup) {
return Container(width: 0, height: 0);
}
return Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
......@@ -355,36 +357,30 @@ class Sender extends StatelessWidget {
/// If true, the color of the sender will be based on their Matrix ID.
final bool personalizedColor;
final EdgeInsets padding;
const Sender({
Key key,
this.personalizedColor = true,
this.padding = EdgeInsets.zero,
}) : super(key: key);
@override
Widget build(BuildContext context) {
static bool necessary(BuildContext context) {
final bubble = MessageBubble.of(context);
final showSender = (bubble.isStartOfGroup ||
return (bubble.isStartOfGroup ||
(bubble.isReply != null && !bubble.message.isMine)) &&
!bubble.message.room.isDirect;
}
if (!showSender) {
return Container(width: 0, height: 0);
}
@override
Widget build(BuildContext context) {
final bubble = MessageBubble.of(context);
return Padding(
padding: padding,
child: Text(
bubble.message.event.sender.displayName,
style: TextStyle(
fontWeight: FontWeight.bold,
color: personalizedColor
? bubble.message.event.sender.getColor(context)
: null,
),
return Text(
bubble.message.event.sender.displayName,
style: TextStyle(
fontWeight: FontWeight.bold,
color: personalizedColor
? bubble.message.event.sender.getColor(context)
: null,
),
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment