From 9294c8bcdf9cea660b3638c01a47645f510905ca Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 14 Jan 2024 19:17:17 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=8A=A8=E6=80=81=E9=95=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/dynamics/widgets/content_panel.dart | 42 +++++++++++++------ .../detail/reply/widgets/reply_item.dart | 3 +- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lib/pages/dynamics/widgets/content_panel.dart b/lib/pages/dynamics/widgets/content_panel.dart index 7072d9cf..eee4255c 100644 --- a/lib/pages/dynamics/widgets/content_panel.dart +++ b/lib/pages/dynamics/widgets/content_panel.dart @@ -1,5 +1,6 @@ // 内容 import 'package:flutter/material.dart'; +import 'package:pilipala/common/widgets/badge.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/models/dynamics/result.dart'; import 'package:pilipala/pages/preview/index.dart'; @@ -49,6 +50,12 @@ class _ContentState extends State { child: LayoutBuilder( builder: (context, BoxConstraints box) { double maxWidth = box.maxWidth.truncateToDouble(); + double maxHeight = box.maxWidth * 0.6; // 设置最大高度 + double height = maxWidth * + 0.5 * + (pictureItem.height != null && pictureItem.width != null + ? pictureItem.height! / pictureItem.width! + : 1); return GestureDetector( onTap: () { showDialog( @@ -59,18 +66,29 @@ class _ContentState extends State { }, ); }, - child: Padding( - padding: const EdgeInsets.only(top: 4), - child: NetworkImgLayer( - src: pictureItem.url, - width: maxWidth / 2, - height: maxWidth * - 0.5 * - (pictureItem.height != null && pictureItem.width != null - ? pictureItem.height! / pictureItem.width! - : 1), - ), - ), + child: Container( + padding: const EdgeInsets.only(top: 4), + constraints: BoxConstraints(maxHeight: maxHeight), + width: box.maxWidth / 2, + height: height, + child: Stack( + children: [ + Positioned.fill( + child: NetworkImgLayer( + src: pictureItem.url, + width: maxWidth / 2, + height: height, + ), + ), + height > maxHeight + ? const PBadge( + text: '长图', + right: 8, + bottom: 8, + ) + : const SizedBox(), + ], + )), ); }, ), diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index a2a78caf..475c0939 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -850,13 +850,12 @@ InlineSpan buildContent( child: LayoutBuilder( builder: (BuildContext context, BoxConstraints box) { double maxHeight = box.maxWidth * 0.6; // 设置最大高度 - double width = (box.maxWidth / 2).truncateToDouble(); + // double width = (box.maxWidth / 2).truncateToDouble(); double height = ((box.maxWidth / 2 * pictureItem['img_height'] / pictureItem['img_width'])) .truncateToDouble(); - print('width: $width, height: $height'); return GestureDetector( onTap: () { showDialog(