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,47 +13,39 @@ 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( decoration: BoxDecoration(
widthFactor: 1.0, color: malformedColor,
child: Container( border: Border.all(color: malformedColor, width: 1),
decoration: BoxDecoration( borderRadius: BorderRadius.only(
color: malformedColor, topLeft: Radius.zero,
border: Border.all(color: malformedColor, width: 1), topRight: Radius.zero,
borderRadius: BorderRadius.only( bottomLeft: Radius.zero,
topLeft: Radius.zero, bottomRight: Radius.zero,
topRight: Radius.zero, ),
bottomLeft: Radius.zero, ),
bottomRight: Radius.zero, child: FittedBox(
), fit: BoxFit.contain,
), child: Center(
child: Center( widthFactor: 1.0,
widthFactor: 1.0, child: Padding(
child: Padding( padding: EdgeInsets.all(9.0),
padding: EdgeInsets.all(9.0), child: Row(mainAxisSize: MainAxisSize.min, children: [
child: Row(mainAxisSize: MainAxisSize.min, children: [ Center(
Center( widthFactor: 1,
widthFactor: 1, child: Padding(
child: Padding( padding: EdgeInsets.all(4),
padding: EdgeInsets.all(4), child: Icon(
child: Icon( CwtchIcons.favorite_black_24dp_broken,
CwtchIcons.favorite_black_24dp_broken, size: 24,
size: 24, ))),
))), Center(
Center( widthFactor: 1.0,
widthFactor: 1.0, child: Text(
child: Column( AppLocalizations.of(context)!.malformedMessage,
crossAxisAlignment: CrossAxisAlignment.start, overflow: TextOverflow.ellipsis,
mainAxisAlignment: MainAxisAlignment.start, textWidthBasis: TextWidthBasis.longestLine,
mainAxisSize: MainAxisSize.min, ))
children: [ ])))));
Text(
AppLocalizations.of(context)!.malformedMessage,
overflow: TextOverflow.ellipsis,
)
],
))
])))));
});
} }
} }