|
|
|
@ -26,6 +26,7 @@ class MxcImage extends StatefulWidget {
|
|
|
|
|
final Widget Function(BuildContext context)? placeholder;
|
|
|
|
|
final String? cacheKey;
|
|
|
|
|
final Client? client;
|
|
|
|
|
final BorderRadius borderRadius;
|
|
|
|
|
|
|
|
|
|
const MxcImage({
|
|
|
|
|
this.uri,
|
|
|
|
@ -42,6 +43,7 @@ class MxcImage extends StatefulWidget {
|
|
|
|
|
this.thumbnailMethod = ThumbnailMethod.scale,
|
|
|
|
|
this.cacheKey,
|
|
|
|
|
this.client,
|
|
|
|
|
this.borderRadius = BorderRadius.zero,
|
|
|
|
|
super.key,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -141,30 +143,34 @@ class _MxcImageState extends State<MxcImage> {
|
|
|
|
|
final hasData = data != null && data.isNotEmpty;
|
|
|
|
|
|
|
|
|
|
return AnimatedSwitcher(
|
|
|
|
|
duration: const Duration(milliseconds: 128),
|
|
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
|
child: hasData
|
|
|
|
|
? Image.memory(
|
|
|
|
|
data,
|
|
|
|
|
width: widget.width,
|
|
|
|
|
height: widget.height,
|
|
|
|
|
fit: widget.fit,
|
|
|
|
|
filterQuality:
|
|
|
|
|
widget.isThumbnail ? FilterQuality.low : FilterQuality.medium,
|
|
|
|
|
errorBuilder: (context, e, s) {
|
|
|
|
|
Logs().d('Unable to render mxc image', e, s);
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: widget.width,
|
|
|
|
|
height: widget.height,
|
|
|
|
|
child: Material(
|
|
|
|
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.broken_image_outlined,
|
|
|
|
|
size: min(widget.height ?? 64, 64),
|
|
|
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
|
|
|
? ClipRRect(
|
|
|
|
|
borderRadius: widget.borderRadius,
|
|
|
|
|
child: Image.memory(
|
|
|
|
|
data,
|
|
|
|
|
width: widget.width,
|
|
|
|
|
height: widget.height,
|
|
|
|
|
fit: widget.fit,
|
|
|
|
|
filterQuality: widget.isThumbnail
|
|
|
|
|
? FilterQuality.low
|
|
|
|
|
: FilterQuality.medium,
|
|
|
|
|
errorBuilder: (context, e, s) {
|
|
|
|
|
Logs().d('Unable to render mxc image', e, s);
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: widget.width,
|
|
|
|
|
height: widget.height,
|
|
|
|
|
child: Material(
|
|
|
|
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.broken_image_outlined,
|
|
|
|
|
size: min(widget.height ?? 64, 64),
|
|
|
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: placeholder(context),
|
|
|
|
|
);
|
|
|
|
|