fix wrapping issues on event previews

This commit is contained in:
Henry Hiles 2026-10-05 11:16:11 -04:00
commit 66cfb0e2c6
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
5 changed files with 237 additions and 115 deletions

View file

@ -11,6 +11,7 @@ class const MessageDisplayname(
final Event event, {
final TextStyle? style,
final bool clickable = true,
final bool shouldWrap = true,
super.key,
}) extends ConsumerWidget {
@override
@ -27,27 +28,34 @@ class const MessageDisplayname(
roomId: event.roomId,
)
: null,
child: Wrap(
spacing: 4,
crossAxisAlignment: .center,
children: [
child: switch ([
Text(
value?.displayName ?? event.sender.localpart,
style:
style ?? .new(color: event.sender.colorHash, fontWeight: .bold),
maxLines: 1,
overflow: .ellipsis,
),
if (event.pmp != null)
Text(
value?.displayName ?? event.sender.localpart,
style:
style ?? .new(color: event.sender.colorHash, fontWeight: .bold),
"(via ${event.sender})",
style: Theme.of(context).textTheme.labelSmall
?.copyWith(color: event.sender.colorHash, fontWeight: .bold),
maxLines: 1,
overflow: .ellipsis,
),
if (event.pmp != null)
Text(
"(via ${event.sender})",
style: Theme.of(context).textTheme.labelSmall
?.copyWith(color: event.sender.colorHash, fontWeight: .bold),
maxLines: 1,
overflow: .ellipsis,
),
],
),
]) {
final children when shouldWrap => Wrap(
spacing: 4,
crossAxisAlignment: .center,
children: children,
),
final children => Row(
spacing: 4,
mainAxisSize: .min,
children: [for (final child in children) Flexible(child: child)],
),
},
),
};
}