From dcf5abc11884b085321eec4b6142d7150a73c12c Mon Sep 17 00:00:00 2001 From: Leandro Borges Ferreira Date: Sun, 26 Feb 2023 16:53:13 +0100 Subject: [PATCH] Fixing some measures --- .../reactions/reactions_align.dart | 24 ++++++++++++------- .../lib/src/utils/extensions.dart | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart index 9985bd43..639fad4c 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget/reactions/reactions_align.dart @@ -18,8 +18,12 @@ double calculateReactionsHorizontalAlignmentValue( final maxHeight = constraints.maxHeight; final roughSentenceSize = message.roughMessageSize(fontSize); + print('roughSentenceSize: $roughSentenceSize'); + print('maxSize: $maxSize'); final hasAttachments = message.attachments.isNotEmpty; - final divFactor = hasAttachments + final isReply = message.quotedMessageId != null; + final isAttachment = hasAttachments && !isReply; + final divFactor = isAttachment ? 1 : (roughSentenceSize == 0 ? 1 : (roughSentenceSize / maxSize)); @@ -31,7 +35,7 @@ double calculateReactionsHorizontalAlignmentValue( maxHeight, shiftFactor, divFactor, - hasAttachments, + isAttachment, ); } else { return _landScapeAlign( @@ -41,7 +45,7 @@ double calculateReactionsHorizontalAlignmentValue( maxHeight, shiftFactor, divFactor, - hasAttachments, + isAttachment, ); } } @@ -53,7 +57,7 @@ double _portraitAlign( double maxHeight, double shiftFactor, num divFactor, - bool hasAttachments, + bool isAttachment, ) { var result = 0.0; @@ -63,14 +67,14 @@ double _portraitAlign( const constant = 1300; if (user?.id == message.user?.id) { - if (divFactor >= 1.0 || hasAttachments) { + if (divFactor >= 1.0 || isAttachment) { result = shiftFactor - maxWidth / constant; } else { // Small messages, it is simpler to align then. result = 1.2 - divFactor; } } else { - if (divFactor >= 1.0 || hasAttachments) { + if (divFactor >= 1.0 || isAttachment) { result = shiftFactor + maxWidth / constant; } else { result = -(1.2 - divFactor); @@ -87,17 +91,21 @@ double _landScapeAlign( double maxHeight, double shiftFactor, num divFactor, - bool hasAttachments, + bool isAttachment, ) { var result = 0.0; + print('is attachment: $isAttachment'); + print('shiftFactor: $shiftFactor'); + print('divFactor: $divFactor'); + /* This is an empiric value. This number tries to approximate all the offset necessary for the position of reaction look the best way possible. */ const constant = 3000; - if (hasAttachments) { + if (isAttachment) { result = 0; } else if (user?.id == message.user?.id) { if (divFactor >= 1.7) { diff --git a/packages/stream_chat_flutter/lib/src/utils/extensions.dart b/packages/stream_chat_flutter/lib/src/utils/extensions.dart index bbe43690..8b575910 100644 --- a/packages/stream_chat_flutter/lib/src/utils/extensions.dart +++ b/packages/stream_chat_flutter/lib/src/utils/extensions.dart @@ -374,7 +374,7 @@ extension MessageX on Message { (min(quotedMessage!.text?.biggestLine().length ?? 0, 65)) + 6; if (quotedMessage!.attachments.isNotEmpty) { - quotedMessageLength += 40; + quotedMessageLength += 8; } if (quotedMessageLength > messageTextLength) { messageTextLength = quotedMessageLength;