fix image grid

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-01-15 16:40:44 +08:00
parent bdc524e486
commit 90349189ee
5 changed files with 11 additions and 15 deletions

View File

@@ -281,7 +281,7 @@ class CustomGridView extends StatelessWidget {
width: imageWidth,
height: imageHeight,
alignment: item.isLongPic ? .topCenter : .center,
forceUseCacheWidth: item.width <= item.height,
cacheWidth: item.width <= item.height,
getPlaceHolder: () => placeHolder,
),
),

View File

@@ -11,30 +11,30 @@ class NetworkImgLayer extends StatelessWidget {
super.key,
required this.src,
required this.width,
this.height,
required this.height,
this.type = .def,
this.fadeOutDuration = const Duration(milliseconds: 120),
this.fadeInDuration = const Duration(milliseconds: 120),
this.quality,
this.borderRadius = StyleString.mdRadius,
this.forceUseCacheWidth = false,
this.getPlaceHolder,
this.fit = .cover,
this.alignment = .center,
this.cacheWidth,
});
final String? src;
final double width;
final double? height;
final double height;
final ImageType type;
final Duration fadeOutDuration;
final Duration fadeInDuration;
final int? quality;
final BorderRadius borderRadius;
final bool forceUseCacheWidth;
final ValueGetter<Widget>? getPlaceHolder;
final BoxFit fit;
final Alignment alignment;
final bool? cacheWidth;
static Color? reduceLuxColor = Pref.reduceLuxColor;
static bool reduce = false;
@@ -64,10 +64,10 @@ class NetworkImgLayer extends StatelessWidget {
required bool isAvatar,
}) {
int? memCacheWidth, memCacheHeight;
if (height == null || forceUseCacheWidth || width <= height!) {
if (cacheWidth ?? width <= height) {
memCacheWidth = width.cacheSize(context);
} else {
memCacheHeight = height?.cacheSize(context);
memCacheHeight = height.cacheSize(context);
}
return CachedNetworkImage(
imageUrl: ImageUtils.thumbnailUrl(src, quality),

View File

@@ -2,14 +2,14 @@ class BaseEmote {
late String url;
late String emoticonUnique;
late double width;
double? height;
late double height;
late final isUpower = emoticonUnique.startsWith('upower_');
BaseEmote.fromJson(Map<String, dynamic> json) {
url = json['url'];
emoticonUnique = json['emoticon_unique'];
width = (json['width'] as num).toDouble();
height = (json['height'] as num?)?.toDouble();
height = (json['height'] as num?)?.toDouble() ?? width;
}
Map<String, dynamic> toJson() => <String, dynamic>{

View File

@@ -234,11 +234,7 @@ class LiveRoomChatPanel extends StatelessWidget {
src: uemote.url,
type: ImageType.emote,
width: isUpower ? uemote.width : uemote.width / devicePixelRatio,
height: uemote.height == null
? null
: isUpower
? uemote.height!
: uemote.height! / devicePixelRatio,
height: isUpower ? uemote.height : uemote.height / devicePixelRatio,
),
);
}

View File

@@ -1602,7 +1602,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
src: videoDetailController.cover.value,
width: width,
height: height,
forceUseCacheWidth: true,
cacheWidth: true,
getPlaceHolder: () => Center(
child: Image.asset('assets/images/loading.png'),
),