fix(ui-kit): fix message widget long username overflow

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-03-31 16:58:24 +05:30
parent fec7cfa572
commit 8b58ac06ff
@@ -586,9 +586,7 @@ class _MessageWidgetState extends State<MessageWidget>
], ],
), ),
if (showBottomRow) if (showBottomRow)
SizedBox( SizedBox(height: context.textScaleFactor * 18.0),
height: context.textScaleFactor * 20.0,
),
], ],
), ),
if (showBottomRow) if (showBottomRow)
@@ -685,6 +683,8 @@ class _MessageWidgetState extends State<MessageWidget>
} }
}; };
const usernameKey = Key('username');
children.addAll([ children.addAll([
if (showInChannel || showThreadReplyIndicator) ...[ if (showInChannel || showThreadReplyIndicator) ...[
if (showThreadParticipants) if (showThreadParticipants)
@@ -700,7 +700,10 @@ class _MessageWidgetState extends State<MessageWidget>
if (showUsername) if (showUsername)
Text( Text(
widget.message.user.name, widget.message.user.name,
maxLines: 1,
key: usernameKey,
style: widget.messageTheme.messageAuthor, style: widget.messageTheme.messageAuthor,
overflow: TextOverflow.ellipsis,
), ),
if (showTimeStamp) if (showTimeStamp)
Text( Text(
@@ -713,18 +716,17 @@ class _MessageWidgetState extends State<MessageWidget>
final showThreadTail = !(hasUrlAttachments || isGiphy || isOnlyEmoji) && final showThreadTail = !(hasUrlAttachments || isGiphy || isOnlyEmoji) &&
(showThreadReplyIndicator || showInChannel); (showThreadReplyIndicator || showInChannel);
return Flex( return Row(
direction: Axis.horizontal,
clipBehavior: Clip.none,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
if (showThreadTail) if (showThreadTail)
Container( Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
bottom: widget.messageTheme.replies.fontSize / 2, bottom: context.textScaleFactor *
(widget.messageTheme.replies.fontSize / 2),
), ),
child: CustomPaint( child: CustomPaint(
size: const Size(16, 32), size: Size(16, 32) * context.textScaleFactor,
painter: _ThreadReplyPainter( painter: _ThreadReplyPainter(
context: context, context: context,
color: widget.messageTheme.messageBorderColor, color: widget.messageTheme.messageBorderColor,
@@ -732,16 +734,20 @@ class _MessageWidgetState extends State<MessageWidget>
), ),
), ),
...children.map( ...children.map(
(child) => Transform( (child) {
transform: Matrix4.rotationY(widget.reverse ? pi : 0), Widget mappedChild = Transform(
alignment: Alignment.center, transform: Matrix4.rotationY(widget.reverse ? pi : 0),
child: Container( alignment: Alignment.center,
height: context.textScaleFactor * 16, child: Container(
child: Center( height: context.textScaleFactor * 14,
child: child, child: child,
), ),
), );
), if (child.key == usernameKey) {
mappedChild = Flexible(child: mappedChild);
}
return mappedChild;
},
), ),
].insertBetween(const SizedBox(width: 8.0)), ].insertBetween(const SizedBox(width: 8.0)),
); );