Merge branch 'mkirk/fixup-bubble-shape'

This commit is contained in:
Michael Kirk 2018-07-06 14:56:22 -06:00
commit f19d3374ec
2 changed files with 46 additions and 16 deletions

View file

@ -7,7 +7,7 @@
NS_ASSUME_NONNULL_BEGIN
const CGFloat kOWSMessageCellCornerRadius_Large = 16;
const CGFloat kOWSMessageCellCornerRadius_Large = 18;
const CGFloat kOWSMessageCellCornerRadius_Small = 2;
@interface OWSBubbleView ()
@ -161,19 +161,40 @@ const CGFloat kOWSMessageCellCornerRadius_Small = 2;
CGFloat bottomRounding
= (useSmallCorners_Bottom ? kOWSMessageCellCornerRadius_Small : kOWSMessageCellCornerRadius_Large);
const CGFloat topAngle = 3.0f * M_PI_2;
const CGFloat rightAngle = 0.0f;
const CGFloat bottomAngle = M_PI_2;
const CGFloat leftAngle = M_PI;
[bezierPath moveToPoint:CGPointMake(bubbleLeft + topRounding, bubbleTop)];
[bezierPath addLineToPoint:CGPointMake(bubbleRight - topRounding, bubbleTop)];
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleRight, bubbleTop + topRounding)
controlPoint:CGPointMake(bubbleRight, bubbleTop)];
[bezierPath addLineToPoint:CGPointMake(bubbleRight, bubbleBottom - bottomRounding)];
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleRight - bottomRounding, bubbleBottom)
controlPoint:CGPointMake(bubbleRight, bubbleBottom)];
[bezierPath addLineToPoint:CGPointMake(bubbleLeft + bottomRounding, bubbleBottom)];
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleLeft, bubbleBottom - bottomRounding)
controlPoint:CGPointMake(bubbleLeft, bubbleBottom)];
[bezierPath addLineToPoint:CGPointMake(bubbleLeft, bubbleTop + topRounding)];
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleLeft + topRounding, bubbleTop)
controlPoint:CGPointMake(bubbleLeft, bubbleTop)];
// top right corner
[bezierPath addArcWithCenter:CGPointMake(bubbleRight - topRounding, bubbleTop + topRounding)
radius:topRounding
startAngle:topAngle
endAngle:rightAngle
clockwise:true];
// bottom right corner
[bezierPath addArcWithCenter:CGPointMake(bubbleRight - bottomRounding, bubbleBottom - bottomRounding)
radius:bottomRounding
startAngle:rightAngle
endAngle:bottomAngle
clockwise:true];
// bottom left corner
[bezierPath addArcWithCenter:CGPointMake(bubbleLeft + bottomRounding, bubbleBottom - bottomRounding)
radius:bottomRounding
startAngle:bottomAngle
endAngle:leftAngle
clockwise:true];
// top left corner
[bezierPath addArcWithCenter:CGPointMake(bubbleLeft + topRounding, bubbleTop + topRounding)
radius:topRounding
startAngle:leftAngle
endAngle:topAngle
clockwise:true];
return bezierPath;
}

View file

@ -97,16 +97,25 @@ public class ConversationStyle: NSObject {
maxMessageWidth = floor(contentWidth - 48)
let messageTextFont = UIFont.ows_dynamicTypeBody
let baseFontOffset: CGFloat = 11
// Don't include the distance from the "cap height" to the top of the UILabel
// in the top margin.
textInsetTop = max(0, 12 - (messageTextFont.ascender - messageTextFont.capHeight))
textInsetTop = max(0, round(baseFontOffset - (messageTextFont.ascender - messageTextFont.capHeight)))
// Don't include the distance from the "baseline" to the bottom of the UILabel
// (e.g. the descender) in the top margin. Note that UIFont.descender is a
// negative value.
textInsetBottom = max(0, 12 - abs(messageTextFont.descender))
textInsetBottom = max(0, round(baseFontOffset - abs(messageTextFont.descender)))
if _isDebugAssertConfiguration(), UIFont.ows_dynamicTypeBody.pointSize == 17 {
assert(textInsetTop == 7)
assert(textInsetBottom == 7)
}
textInsetHorizontal = 12
lastTextLineAxis = CGFloat(round(12 + messageTextFont.capHeight * 0.5))
lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5))
self.primaryColor = ConversationStyle.primaryColor(thread: thread)
}