Fixup Malformed Sizes + Preview Contraints

This commit is contained in:
Sarah Jamie Lewis 2024-02-08 14:10:43 -08:00
parent abd32293eb
commit 659c7fe75e
3 changed files with 37 additions and 45 deletions

View File

@ -55,14 +55,14 @@ class FileMessage extends Message {
builder: (bcontext, child) { builder: (bcontext, child) {
dynamic shareObj = jsonDecode(this.content); dynamic shareObj = jsonDecode(this.content);
if (shareObj == null) { if (shareObj == null) {
return MessageRow(MalformedBubble(), 0); return MalformedBubble();
} }
String nameSuggestion = shareObj['f'] as String; String nameSuggestion = shareObj['f'] as String;
String rootHash = shareObj['h'] as String; String rootHash = shareObj['h'] as String;
String nonce = shareObj['n'] as String; String nonce = shareObj['n'] as String;
int fileSize = shareObj['s'] as int; int fileSize = shareObj['s'] as int;
if (!validHash(rootHash, nonce)) { if (!validHash(rootHash, nonce)) {
return MessageRow(MalformedBubble(), 0); return MalformedBubble();
} }
return Container( return Container(
alignment: Alignment.center, alignment: Alignment.center,

View File

@ -40,7 +40,7 @@ class QuotedMessage extends Message {
); );
var content = message["body"]; var content = message["body"];
var formatMessages = Provider.of<Settings>(bcontext).isExperimentEnabled(FormattingExperiment); var formatMessages = Provider.of<Settings>(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) { } catch (e) {
return MalformedBubble(); return MalformedBubble();
} }

View File

@ -13,10 +13,7 @@ class MalformedBubble extends StatefulWidget {
class MalformedBubbleState extends State<MalformedBubble> { class MalformedBubbleState extends State<MalformedBubble> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) { return Container(
return Center(
widthFactor: 1.0,
child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: malformedColor, color: malformedColor,
border: Border.all(color: malformedColor, width: 1), border: Border.all(color: malformedColor, width: 1),
@ -27,6 +24,8 @@ class MalformedBubbleState extends State<MalformedBubble> {
bottomRight: Radius.zero, bottomRight: Radius.zero,
), ),
), ),
child: FittedBox(
fit: BoxFit.contain,
child: Center( child: Center(
widthFactor: 1.0, widthFactor: 1.0,
child: Padding( child: Padding(
@ -42,18 +41,11 @@ class MalformedBubbleState extends State<MalformedBubble> {
))), ))),
Center( Center(
widthFactor: 1.0, widthFactor: 1.0,
child: Column( child: Text(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
AppLocalizations.of(context)!.malformedMessage, AppLocalizations.of(context)!.malformedMessage,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
) textWidthBasis: TextWidthBasis.longestLine,
],
)) ))
]))))); ])))));
});
} }
} }