🐛 Bug fixes and optimize image display
This commit is contained in:
@ -44,12 +44,18 @@ class SnAttachmentProvider {
|
||||
'take': pendingFetch.length,
|
||||
'id': pendingFetch.join(','),
|
||||
});
|
||||
final out = resp.data['data'].map((e) => SnAttachment.fromJson(e)).toList();
|
||||
final out = resp.data['data']
|
||||
.where((e) => e['id'] != 0)
|
||||
.map((e) => SnAttachment.fromJson(e))
|
||||
.toList();
|
||||
|
||||
for (var i = 0; i < out.length; i++) {
|
||||
_cache[pendingFetch[i]] = out[i];
|
||||
}
|
||||
return rids.map((rid) => _cache[rid]!).toList();
|
||||
return rids
|
||||
.where((rid) => _cache.containsKey(rid))
|
||||
.map((rid) => _cache[rid]!)
|
||||
.toList();
|
||||
}
|
||||
|
||||
static Map<String, String> mimetypeOverrides = {
|
||||
|
@ -100,7 +100,7 @@ class SnNetworkProvider {
|
||||
}
|
||||
|
||||
String getAttachmentUrl(String ky) {
|
||||
if (ky.startsWith("http://")) return ky;
|
||||
if (ky.startsWith("http")) return ky;
|
||||
return '${client.options.baseUrl}/cgi/uc/attachments/$ky';
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
onTicket: (p0) => setState(() {
|
||||
_currentTicket = p0;
|
||||
}),
|
||||
onNext: (p0) => setState(() {
|
||||
onNext: () => setState(() {
|
||||
_period = 1;
|
||||
}),
|
||||
),
|
||||
|
@ -30,67 +30,21 @@ class UniversalImage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
final double? resizeHeight =
|
||||
cacheHeight != null ? (cacheHeight! * devicePixelRatio) : null;
|
||||
final double? resizeWidth =
|
||||
cacheWidth != null ? (cacheWidth! * devicePixelRatio) : null;
|
||||
|
||||
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS || Platform.isMacOS)) {
|
||||
return CachedNetworkImage(
|
||||
imageUrl: url,
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
memCacheHeight: cacheHeight != null
|
||||
? (cacheHeight! * devicePixelRatio).round()
|
||||
: null,
|
||||
memCacheWidth: cacheWidth != null
|
||||
? (cacheWidth! * devicePixelRatio).round()
|
||||
: null,
|
||||
progressIndicatorBuilder: noProgressIndicator
|
||||
? null
|
||||
: (context, url, downloadProgress) => Center(
|
||||
child: TweenAnimationBuilder(
|
||||
tween: Tween(
|
||||
begin: 0,
|
||||
end: downloadProgress.progress ?? 0,
|
||||
),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
builder: (context, value, _) => CircularProgressIndicator(
|
||||
value: downloadProgress.progress != null
|
||||
? value.toDouble()
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
errorWidget: noErrorWidget
|
||||
? null
|
||||
: (context, url, error) {
|
||||
return Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
constraints: const BoxConstraints(maxWidth: 280),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimateWidgetExtensions(Icon(Symbols.close, size: 24))
|
||||
.animate(onPlay: (e) => e.repeat(reverse: true))
|
||||
.fade(duration: 500.ms),
|
||||
Text(
|
||||
error.toString(),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
).center(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Image.network(
|
||||
url,
|
||||
return Image(
|
||||
image: ResizeImage(
|
||||
UniversalImage.provider(url),
|
||||
width: resizeWidth?.round(),
|
||||
height: resizeHeight?.round(),
|
||||
policy: ResizeImagePolicy.fit,
|
||||
),
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
cacheHeight: cacheHeight != null
|
||||
? (cacheHeight! * devicePixelRatio).round()
|
||||
: null,
|
||||
cacheWidth:
|
||||
cacheWidth != null ? (cacheWidth! * devicePixelRatio).round() : null,
|
||||
loadingBuilder: noProgressIndicator
|
||||
? null
|
||||
: (BuildContext context, Widget child,
|
||||
|
Reference in New Issue
Block a user