stop event preview resizing itself on load

Fixes #109
This commit is contained in:
Henry Hiles 2026-10-03 13:50:46 -04:00
commit 0a3ec830a3
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 43 additions and 27 deletions

View file

@ -18,18 +18,21 @@ class const EventPreview(final Event event, {super.key})
if (event.content is MessageContent) MessageAvatar(event), if (event.content is MessageContent) MessageAvatar(event),
Flexible( Flexible(
child: Wrap( child: Row(
crossAxisAlignment: .center, crossAxisAlignment: .center,
mainAxisSize: .min,
spacing: 8, spacing: 8,
runSpacing: 2,
children: [ children: [
if (event.content is MessageContent) MessageDisplayname(event), if (event.content is MessageContent)
EventRenderer( Flexible(child: MessageDisplayname(event)),
Flexible(
child: EventRenderer(
event.rowId, event.rowId,
roomId: event.roomId, roomId: event.roomId,
textOnly: true, textOnly: true,
maxLines: 1, maxLines: 1,
), ),
),
], ],
), ),
), ),

View file

@ -1,11 +1,15 @@
import "package:material_ui/material_ui.dart"; import "package:material_ui/material_ui.dart";
class const Loading({super.key, final double? height}) extends StatelessWidget { class const Loading({super.key, final double? dimension})
extends StatelessWidget {
@override @override
Widget build(BuildContext context) => Center( Widget build(BuildContext context) => Center(
child: Padding( child: Padding(
padding: .all(16), padding: .all(16),
child: SizedBox(height: height, child: CircularProgressIndicator()), child: SizedBox.square(
dimension: dimension,
child: CircularProgressIndicator(),
),
), ),
); );
} }

View file

@ -13,6 +13,7 @@ import "package:nexus/widgets/html/html.dart";
import "package:nexus/widgets/lazy_loading/message_avatar.dart"; import "package:nexus/widgets/lazy_loading/message_avatar.dart";
import "package:nexus/widgets/lazy_loading/message_displayname.dart"; import "package:nexus/widgets/lazy_loading/message_displayname.dart";
import "package:nexus/widgets/linkified_text.dart"; import "package:nexus/widgets/linkified_text.dart";
import "package:nexus/widgets/loading.dart";
import "package:nexus/widgets/message_image.dart"; import "package:nexus/widgets/message_image.dart";
import "package:nexus/widgets/reaction_row.dart"; import "package:nexus/widgets/reaction_row.dart";
import "package:nexus/widgets/timestamp.dart"; import "package:nexus/widgets/timestamp.dart";
@ -197,6 +198,12 @@ class const MessageRenderer(
onTap: onTapReply, onTap: onTapReply,
child: Padding( child: Padding(
padding: .symmetric(vertical: 8, horizontal: 12), padding: .symmetric(vertical: 8, horizontal: 12),
child: SizedBox(
height: 32,
child: OverflowBox(
alignment: .centerLeft,
minHeight: 0,
maxHeight: .infinity,
child: switch (ref.watch( child: switch (ref.watch(
EventController.provider( EventController.provider(
.new( .new(
@ -213,11 +220,13 @@ class const MessageRenderer(
"An error occurred while fetching the reply", "An error occurred while fetching the reply",
style: errorStyle, style: errorStyle,
), ),
_ => Text("Fetching event..."), _ => Loading(dimension: 12),
}, },
), ),
), ),
), ),
),
),
rendered, rendered,
if (!textOnly) ReactionRow(event), if (!textOnly) ReactionRow(event),
], ],