Fixing some measures

This commit is contained in:
Leandro Borges Ferreira
2023-02-26 16:53:13 +01:00
parent 4dda50df73
commit dcf5abc118
2 changed files with 17 additions and 9 deletions
@@ -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) {
@@ -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;