mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: 评论区图片拉伸
This commit is contained in:
@@ -35,29 +35,16 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
final String imageUrl =
|
final String imageUrl =
|
||||||
'${src!.startsWith('//') ? 'https:${src!}' : src!}@${quality ?? 100}q.webp';
|
'${src!.startsWith('//') ? 'https:${src!}' : src!}@${quality ?? 100}q.webp';
|
||||||
int? memCacheWidth, memCacheHeight;
|
int? memCacheWidth, memCacheHeight;
|
||||||
double aspectRatio = (width / height).toDouble();
|
|
||||||
|
|
||||||
void setMemCacheSizes() {
|
if (width > height || (origAspectRatio != null && origAspectRatio! > 1)) {
|
||||||
if (aspectRatio > 1) {
|
|
||||||
memCacheHeight = height.cacheSize(context);
|
|
||||||
} else if (aspectRatio < 1) {
|
|
||||||
memCacheWidth = width.cacheSize(context);
|
memCacheWidth = width.cacheSize(context);
|
||||||
} else {
|
} else if (width < height ||
|
||||||
if (origAspectRatio != null && origAspectRatio! > 1) {
|
(origAspectRatio != null && origAspectRatio! < 1)) {
|
||||||
memCacheWidth = width.cacheSize(context);
|
|
||||||
} else if (origAspectRatio != null && origAspectRatio! < 1) {
|
|
||||||
memCacheHeight = height.cacheSize(context);
|
memCacheHeight = height.cacheSize(context);
|
||||||
} else {
|
} else {
|
||||||
|
// 不能同时设置,否则会导致图片变形
|
||||||
memCacheWidth = width.cacheSize(context);
|
memCacheWidth = width.cacheSize(context);
|
||||||
memCacheHeight = height.cacheSize(context);
|
// memCacheHeight = height.cacheSize(context);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setMemCacheSizes();
|
|
||||||
|
|
||||||
if (memCacheWidth == null && memCacheHeight == null) {
|
|
||||||
memCacheWidth = width.toInt();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return src != '' && src != null
|
return src != '' && src != null
|
||||||
|
|||||||
Reference in New Issue
Block a user