From 0638b0c99d9c84ea6527871bf530246909ef0501 Mon Sep 17 00:00:00 2001 From: bigtaed-sys <234930311+bigtaed-sys@users.noreply.github.com> Date: Fri, 17 Jul 2026 19:44:33 +0300 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=D1=84=D0=BE=D1=82=D0=BE=20=D0=B2?= =?UTF-8?q?=20=D0=BF=D1=83=D0=B7=D1=8B=D1=80=D1=8F=D1=85=20=D1=81=D0=BE?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D1=8E=D1=82=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=BF=D0=BE=D1=80=D1=86=D0=B8=D0=B8,=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8=20=D0=BE=D1=82=D1=81=D1=82=D1=83=D0=BF=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Одиночное фото больше не обрезается в квадрат: размер считается по реальному соотношению сторон с масштабированием в пределы min/max. Подпись под фото и видео получила верхний отступ и увеличенные боковые. --- .../attachment/bubbles/bubble_context.dart | 5 +- .../attachment/bubbles/photo_bubble.dart | 56 ++++++++++++++----- .../attachment/bubbles/video_bubble.dart | 1 + 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/lib/frontend/widgets/attachment/bubbles/bubble_context.dart b/lib/frontend/widgets/attachment/bubbles/bubble_context.dart index 23849ad..fe52aea 100644 --- a/lib/frontend/widgets/attachment/bubbles/bubble_context.dart +++ b/lib/frontend/widgets/attachment/bubbles/bubble_context.dart @@ -64,8 +64,9 @@ class BubbleContext { static const double photoMinSize = 100.0; static const double photoBorderRadius = 12.0; static const double bubbleBorderRadius = 20.0; - static const double captionPaddingHorizontal = 6.0; - static const double captionPaddingRight = 4.0; + static const double captionPaddingHorizontal = 10.0; + static const double captionPaddingRight = 6.0; + static const double captionPaddingTop = 6.0; static const double compactTimePadding = 8.0; final BuildContext context; diff --git a/lib/frontend/widgets/attachment/bubbles/photo_bubble.dart b/lib/frontend/widgets/attachment/bubbles/photo_bubble.dart index c22adae..3a6ac6a 100644 --- a/lib/frontend/widgets/attachment/bubbles/photo_bubble.dart +++ b/lib/frontend/widgets/attachment/bubbles/photo_bubble.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:math' as math; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/foundation.dart'; @@ -32,9 +33,42 @@ class PhotoBubble extends StatelessWidget { static double layoutWidth(List photos) { if (photos.length != 1) return BubbleContext.photoMaxSize; - return (photos.single.width?.toDouble() ?? 200).clamp( - BubbleContext.photoMinSize, - BubbleContext.photoMaxSize, + return _displaySize(photos.single).width; + } + + static Size _displaySize(PhotoAttachment photo) { + final width = photo.width?.toDouble() ?? 200; + final height = photo.height?.toDouble() ?? 200; + + final downScale = math.min( + 1.0, + math.min( + BubbleContext.photoMaxSize / width, + BubbleContext.photoMaxSize / height, + ), + ); + var displayWidth = width * downScale; + var displayHeight = height * downScale; + + final upScale = math.max( + 1.0, + math.max( + BubbleContext.photoMinSize / displayWidth, + BubbleContext.photoMinSize / displayHeight, + ), + ); + displayWidth *= upScale; + displayHeight *= upScale; + + return Size( + displayWidth.clamp( + BubbleContext.photoMinSize, + BubbleContext.photoMaxSize, + ), + displayHeight.clamp( + BubbleContext.photoMinSize, + BubbleContext.photoMaxSize, + ), ); } @@ -86,6 +120,7 @@ class PhotoBubble extends StatelessWidget { padding: const EdgeInsets.only( left: BubbleContext.captionPaddingHorizontal, right: BubbleContext.captionPaddingRight, + top: BubbleContext.captionPaddingTop, bottom: 6, ), child: Row( @@ -110,6 +145,7 @@ class PhotoBubble extends StatelessWidget { padding: const EdgeInsets.only( left: BubbleContext.captionPaddingHorizontal, right: BubbleContext.captionPaddingRight, + top: BubbleContext.captionPaddingTop, bottom: 6, ), child: Row( @@ -130,17 +166,9 @@ class PhotoBubble extends StatelessWidget { required bool hasCaption, required bool hasContentAbove, }) { - final width = photo.width?.toDouble() ?? 200; - final height = photo.height?.toDouble() ?? 200; - - final constrainedWidth = width.clamp( - BubbleContext.photoMinSize, - BubbleContext.photoMaxSize, - ); - final constrainedHeight = height.clamp( - BubbleContext.photoMinSize, - BubbleContext.photoMaxSize, - ); + final size = _displaySize(photo); + final constrainedWidth = size.width; + final constrainedHeight = size.height; final dpr = MediaQuery.of(ctx.context).devicePixelRatio; final matchTop = hasCaption && !hasContentAbove; diff --git a/lib/frontend/widgets/attachment/bubbles/video_bubble.dart b/lib/frontend/widgets/attachment/bubbles/video_bubble.dart index 660e380..086d378 100644 --- a/lib/frontend/widgets/attachment/bubbles/video_bubble.dart +++ b/lib/frontend/widgets/attachment/bubbles/video_bubble.dart @@ -194,6 +194,7 @@ class VideoBubble extends StatelessWidget { padding: const EdgeInsets.only( left: BubbleContext.captionPaddingHorizontal, right: BubbleContext.captionPaddingRight, + top: BubbleContext.captionPaddingTop, bottom: 6, ), child: Row(