fix: Do display error image widget

onboarding
Krille Fear 4 years ago
parent 672e51a779
commit d9260a4785

@ -190,30 +190,26 @@ class _ImageBubbleState extends State<ImageBubble> {
final String filename = widget.event.content.containsKey('filename') final String filename = widget.event.content.containsKey('filename')
? widget.event.content['filename'] ? widget.event.content['filename']
: widget.event.body; : widget.event.body;
return Center( return getPlaceholderWidget(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
ElevatedButton( OutlinedButton.icon(
style: ElevatedButton.styleFrom( style: OutlinedButton.styleFrom(
primary: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
onPrimary: Theme.of(context).textTheme.bodyText1.color, primary: Theme.of(context).textTheme.bodyText1.color,
), ),
icon: const Icon(Icons.download_outlined),
onPressed: () => widget.event.saveFile(context), onPressed: () => widget.event.saveFile(context),
child: Row( label: Text(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.download_outlined),
const SizedBox(width: 8),
Text(
filename, filename,
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
softWrap: false, softWrap: false,
maxLines: 1, maxLines: 1,
), ),
],
),
), ),
const SizedBox(height: 8),
if (widget.event.sizeString != null) Text(widget.event.sizeString), if (widget.event.sizeString != null) Text(widget.event.sizeString),
const SizedBox(height: 8), const SizedBox(height: 8),
Text((error ?? _error).toString()), Text((error ?? _error).toString()),
@ -357,10 +353,10 @@ class _ImageBubbleState extends State<ImageBubble> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
ElevatedButton( OutlinedButton(
style: ElevatedButton.styleFrom( style: OutlinedButton.styleFrom(
primary: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
onPrimary: Theme.of(context).textTheme.bodyText1.color, primary: Theme.of(context).textTheme.bodyText1.color,
), ),
onPressed: () => onTap(context), onPressed: () => onTap(context),
child: Text( child: Text(
@ -370,8 +366,10 @@ class _ImageBubbleState extends State<ImageBubble> {
maxLines: 1, maxLines: 1,
), ),
), ),
if (widget.event.sizeString != null) if (widget.event.sizeString != null) ...[
const SizedBox(height: 8),
Text(widget.event.sizeString), Text(widget.event.sizeString),
]
], ],
)); ));
} }

@ -83,20 +83,14 @@ class MessageContent extends StatelessWidget {
case EventTypes.Sticker: case EventTypes.Sticker:
switch (event.messageType) { switch (event.messageType) {
case MessageTypes.Image: case MessageTypes.Image:
if (event.showThumbnail) {
return ImageBubble( return ImageBubble(
event, event,
width: 400, width: 400,
height: 300, height: 300,
fit: BoxFit.cover, fit: BoxFit.cover,
); );
}
return MessageDownloadContent(event, textColor);
case MessageTypes.Sticker: case MessageTypes.Sticker:
if (event.showThumbnail) {
return Sticker(event); return Sticker(event);
}
return MessageDownloadContent(event, textColor);
case MessageTypes.Audio: case MessageTypes.Audio:
if (PlatformInfos.isMobile) { if (PlatformInfos.isMobile) {
return AudioPlayerWidget( return AudioPlayerWidget(

Loading…
Cancel
Save