From 1903e86a0286d7401b8663fd06d81870769fd0d8 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Thu, 11 Dec 2025 23:41:12 +0300 Subject: [PATCH] patch bubbles --- yobble/Views/Chat/PrivateChatView.swift | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/yobble/Views/Chat/PrivateChatView.swift b/yobble/Views/Chat/PrivateChatView.swift index a75bc10..bfe439f 100644 --- a/yobble/Views/Chat/PrivateChatView.swift +++ b/yobble/Views/Chat/PrivateChatView.swift @@ -791,14 +791,23 @@ private struct MessageBubbleShape: Shape { let horizontalSpan = max(0, rect.width - 2 * radius) - let hornsEnabled = horizontalSpan > (2 * hornWidth + 2 * hornSpacing) - let legsEnabled = horizontalSpan > (2 * legWidth + 2 * legSpacing) + let hornsEnabled = horizontalSpan > 0.5 + let legsEnabled = horizontalSpan > 0.5 - let effectiveHornWidth = hornsEnabled ? min(hornWidth, horizontalSpan / 4) : 0 - let effectiveLegWidth = legsEnabled ? min(legWidth, horizontalSpan / 4) : 0 + func clampedFeatureWidth(targetWidth: CGFloat) -> CGFloat { + guard horizontalSpan > 0 else { return 0 } + let preferredWidth = max(horizontalSpan * 0.25, targetWidth) + return min(preferredWidth, min(targetWidth, horizontalSpan / 2)) + } - let effectiveHornSpacing = hornsEnabled ? min(hornSpacing, (horizontalSpan - effectiveHornWidth * 2) / 2) : 0 - let effectiveLegSpacing = legsEnabled ? min(legSpacing, (horizontalSpan - effectiveLegWidth * 2) / 2) : 0 + let effectiveHornWidth = hornsEnabled ? clampedFeatureWidth(targetWidth: hornWidth) : 0 + let effectiveLegWidth = legsEnabled ? clampedFeatureWidth(targetWidth: legWidth) : 0 + + let hornSpacingCandidate = max(horizontalSpan - effectiveHornWidth * 2, 0) / 2 + let legSpacingCandidate = max(horizontalSpan - effectiveLegWidth * 2, 0) / 2 + + let effectiveHornSpacing = hornsEnabled ? min(hornSpacing, hornSpacingCandidate) : 0 + let effectiveLegSpacing = legsEnabled ? min(legSpacing, legSpacingCandidate) : 0 let leftHornStart = left + radius + effectiveHornSpacing let rightHornStart = right - radius - effectiveHornSpacing - effectiveHornWidth