From 659c7fe75e047ea8a2c09f6c809028359ea58096 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Thu, 8 Feb 2024 14:10:43 -0800 Subject: [PATCH] Fixup Malformed Sizes + Preview Contraints --- lib/models/messages/filemessage.dart | 4 +- lib/models/messages/quotedmessage.dart | 2 +- lib/widgets/malformedbubble.dart | 76 ++++++++++++-------------- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/lib/models/messages/filemessage.dart b/lib/models/messages/filemessage.dart index 26cf60a4..2c7b4726 100644 --- a/lib/models/messages/filemessage.dart +++ b/lib/models/messages/filemessage.dart @@ -55,14 +55,14 @@ class FileMessage extends Message { builder: (bcontext, child) { dynamic shareObj = jsonDecode(this.content); if (shareObj == null) { - return MessageRow(MalformedBubble(), 0); + return MalformedBubble(); } String nameSuggestion = shareObj['f'] as String; String rootHash = shareObj['h'] as String; String nonce = shareObj['n'] as String; int fileSize = shareObj['s'] as int; if (!validHash(rootHash, nonce)) { - return MessageRow(MalformedBubble(), 0); + return MalformedBubble(); } return Container( alignment: Alignment.center, diff --git a/lib/models/messages/quotedmessage.dart b/lib/models/messages/quotedmessage.dart index 0564dcad..95b1db5d 100644 --- a/lib/models/messages/quotedmessage.dart +++ b/lib/models/messages/quotedmessage.dart @@ -40,7 +40,7 @@ class QuotedMessage extends Message { ); var content = message["body"]; var formatMessages = Provider.of(bcontext).isExperimentEnabled(FormattingExperiment); - return compileMessageContentWidget(context, constraints ?? BoxConstraints.expand(), false, content, FocusNode(), formatMessages, false); + return compileMessageContentWidget(context, constraints ?? BoxConstraints.loose(MediaQuery.sizeOf(context)), false, content, FocusNode(), formatMessages, false); } catch (e) { return MalformedBubble(); } diff --git a/lib/widgets/malformedbubble.dart b/lib/widgets/malformedbubble.dart index 7a9ad6e3..0a6c1c27 100644 --- a/lib/widgets/malformedbubble.dart +++ b/lib/widgets/malformedbubble.dart @@ -13,47 +13,39 @@ class MalformedBubble extends StatefulWidget { class MalformedBubbleState extends State { @override Widget build(BuildContext context) { - return LayoutBuilder(builder: (context, constraints) { - return Center( - widthFactor: 1.0, - child: Container( - decoration: BoxDecoration( - color: malformedColor, - border: Border.all(color: malformedColor, width: 1), - borderRadius: BorderRadius.only( - topLeft: Radius.zero, - topRight: Radius.zero, - bottomLeft: Radius.zero, - bottomRight: Radius.zero, - ), - ), - child: Center( - widthFactor: 1.0, - child: Padding( - padding: EdgeInsets.all(9.0), - child: Row(mainAxisSize: MainAxisSize.min, children: [ - Center( - widthFactor: 1, - child: Padding( - padding: EdgeInsets.all(4), - child: Icon( - CwtchIcons.favorite_black_24dp_broken, - size: 24, - ))), - Center( - widthFactor: 1.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - AppLocalizations.of(context)!.malformedMessage, - overflow: TextOverflow.ellipsis, - ) - ], - )) - ]))))); - }); + return Container( + decoration: BoxDecoration( + color: malformedColor, + border: Border.all(color: malformedColor, width: 1), + borderRadius: BorderRadius.only( + topLeft: Radius.zero, + topRight: Radius.zero, + bottomLeft: Radius.zero, + bottomRight: Radius.zero, + ), + ), + child: FittedBox( + fit: BoxFit.contain, + child: Center( + widthFactor: 1.0, + child: Padding( + padding: EdgeInsets.all(9.0), + child: Row(mainAxisSize: MainAxisSize.min, children: [ + Center( + widthFactor: 1, + child: Padding( + padding: EdgeInsets.all(4), + child: Icon( + CwtchIcons.favorite_black_24dp_broken, + size: 24, + ))), + Center( + widthFactor: 1.0, + child: Text( + AppLocalizations.of(context)!.malformedMessage, + overflow: TextOverflow.ellipsis, + textWidthBasis: TextWidthBasis.longestLine, + )) + ]))))); } }