From 90349189eef186c9e8c9f46ada243eb0249185bd Mon Sep 17 00:00:00 2001 From: dom Date: Thu, 15 Jan 2026 16:40:44 +0800 Subject: [PATCH] fix image grid Signed-off-by: dom --- lib/common/widgets/image/custom_grid_view.dart | 2 +- lib/common/widgets/image/network_img_layer.dart | 12 ++++++------ lib/models_new/live/live_danmaku/live_emote.dart | 4 ++-- lib/pages/live_room/widgets/chat_panel.dart | 6 +----- lib/pages/video/view.dart | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/common/widgets/image/custom_grid_view.dart b/lib/common/widgets/image/custom_grid_view.dart index 594d00004..12dad66fb 100644 --- a/lib/common/widgets/image/custom_grid_view.dart +++ b/lib/common/widgets/image/custom_grid_view.dart @@ -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, ), ), diff --git a/lib/common/widgets/image/network_img_layer.dart b/lib/common/widgets/image/network_img_layer.dart index cabc92b06..648332172 100644 --- a/lib/common/widgets/image/network_img_layer.dart +++ b/lib/common/widgets/image/network_img_layer.dart @@ -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? 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), diff --git a/lib/models_new/live/live_danmaku/live_emote.dart b/lib/models_new/live/live_danmaku/live_emote.dart index 3c80dad17..1c91981fa 100644 --- a/lib/models_new/live/live_danmaku/live_emote.dart +++ b/lib/models_new/live/live_danmaku/live_emote.dart @@ -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 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 toJson() => { diff --git a/lib/pages/live_room/widgets/chat_panel.dart b/lib/pages/live_room/widgets/chat_panel.dart index 179270e70..19b69c80c 100644 --- a/lib/pages/live_room/widgets/chat_panel.dart +++ b/lib/pages/live_room/widgets/chat_panel.dart @@ -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, ), ); } diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 0733bb4f4..b64f5af5c 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -1602,7 +1602,7 @@ class _VideoDetailPageVState extends State src: videoDetailController.cover.value, width: width, height: height, - forceUseCacheWidth: true, + cacheWidth: true, getPlaceHolder: () => Center( child: Image.asset('assets/images/loading.png'), ),