🐛 Fix attachment loading
This commit is contained in:
parent
468d1377af
commit
b9ad6d4fd0
@ -49,9 +49,10 @@ class SnAttachmentProvider {
|
||||
.map((e) => SnAttachment.fromJson(e))
|
||||
.toList();
|
||||
|
||||
for (var i = 0; i < out.length; i++) {
|
||||
_cache[pendingFetch[i]] = out[i];
|
||||
for (final item in out) {
|
||||
_cache[item.rid] = item;
|
||||
}
|
||||
|
||||
return rids
|
||||
.where((rid) => _cache.containsKey(rid))
|
||||
.map((rid) => _cache[rid]!)
|
||||
|
@ -232,7 +232,7 @@ class _ProfileEditScreenState extends State<ProfileEditScreen> {
|
||||
color:
|
||||
Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
child: _banner != null
|
||||
? UniversalImage(
|
||||
? AutoResizeUniversalImage(
|
||||
sn.getAttachmentUrl(_banner!),
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
|
@ -210,7 +210,7 @@ class _AccountPublisherEditScreenState
|
||||
.colorScheme
|
||||
.surfaceContainerHigh,
|
||||
child: _banner != null
|
||||
? UniversalImage(
|
||||
? AutoResizeUniversalImage(
|
||||
sn.getAttachmentUrl(_banner!),
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
|
@ -100,3 +100,37 @@ class UniversalImage extends StatelessWidget {
|
||||
return NetworkImage(url);
|
||||
}
|
||||
}
|
||||
|
||||
class AutoResizeUniversalImage extends StatelessWidget {
|
||||
final String url;
|
||||
final double? width, height;
|
||||
final BoxFit? fit;
|
||||
final bool noProgressIndicator;
|
||||
final bool noErrorWidget;
|
||||
|
||||
const AutoResizeUniversalImage(
|
||||
this.url, {
|
||||
super.key,
|
||||
this.width,
|
||||
this.height,
|
||||
this.fit,
|
||||
this.noProgressIndicator = false,
|
||||
this.noErrorWidget = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return UniversalImage(
|
||||
url,
|
||||
fit: fit,
|
||||
width: width,
|
||||
height: height,
|
||||
noProgressIndicator: noProgressIndicator,
|
||||
noErrorWidget: noErrorWidget,
|
||||
cacheHeight: constraints.maxHeight,
|
||||
cacheWidth: constraints.maxWidth,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user