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) {
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,

View File

@ -40,7 +40,7 @@ class QuotedMessage extends Message {
);
var content = message["body"];
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) {
return MalformedBubble();
}

View File

@ -13,47 +13,39 @@ class MalformedBubble extends StatefulWidget {
class MalformedBubbleState extends State<MalformedBubble> {
@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,
))
])))));
}
}