Merge branch 'mkirk/fixup-bubble-shape'

pull/1/head
Michael Kirk 7 years ago
commit f19d3374ec

@ -7,7 +7,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
const CGFloat kOWSMessageCellCornerRadius_Large = 16; const CGFloat kOWSMessageCellCornerRadius_Large = 18;
const CGFloat kOWSMessageCellCornerRadius_Small = 2; const CGFloat kOWSMessageCellCornerRadius_Small = 2;
@interface OWSBubbleView () @interface OWSBubbleView ()
@ -161,19 +161,40 @@ const CGFloat kOWSMessageCellCornerRadius_Small = 2;
CGFloat bottomRounding CGFloat bottomRounding
= (useSmallCorners_Bottom ? kOWSMessageCellCornerRadius_Small : kOWSMessageCellCornerRadius_Large); = (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 moveToPoint:CGPointMake(bubbleLeft + topRounding, bubbleTop)];
[bezierPath addLineToPoint:CGPointMake(bubbleRight - topRounding, bubbleTop)];
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleRight, bubbleTop + topRounding) // top right corner
controlPoint:CGPointMake(bubbleRight, bubbleTop)]; [bezierPath addArcWithCenter:CGPointMake(bubbleRight - topRounding, bubbleTop + topRounding)
[bezierPath addLineToPoint:CGPointMake(bubbleRight, bubbleBottom - bottomRounding)]; radius:topRounding
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleRight - bottomRounding, bubbleBottom) startAngle:topAngle
controlPoint:CGPointMake(bubbleRight, bubbleBottom)]; endAngle:rightAngle
[bezierPath addLineToPoint:CGPointMake(bubbleLeft + bottomRounding, bubbleBottom)]; clockwise:true];
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleLeft, bubbleBottom - bottomRounding)
controlPoint:CGPointMake(bubbleLeft, bubbleBottom)]; // bottom right corner
[bezierPath addLineToPoint:CGPointMake(bubbleLeft, bubbleTop + topRounding)]; [bezierPath addArcWithCenter:CGPointMake(bubbleRight - bottomRounding, bubbleBottom - bottomRounding)
[bezierPath addQuadCurveToPoint:CGPointMake(bubbleLeft + topRounding, bubbleTop) radius:bottomRounding
controlPoint:CGPointMake(bubbleLeft, bubbleTop)]; 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; return bezierPath;
} }

@ -97,16 +97,25 @@ public class ConversationStyle: NSObject {
maxMessageWidth = floor(contentWidth - 48) maxMessageWidth = floor(contentWidth - 48)
let messageTextFont = UIFont.ows_dynamicTypeBody let messageTextFont = UIFont.ows_dynamicTypeBody
let baseFontOffset: CGFloat = 11
// Don't include the distance from the "cap height" to the top of the UILabel // Don't include the distance from the "cap height" to the top of the UILabel
// in the top margin. // 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 // 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 // (e.g. the descender) in the top margin. Note that UIFont.descender is a
// negative value. // 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 textInsetHorizontal = 12
lastTextLineAxis = CGFloat(round(12 + messageTextFont.capHeight * 0.5)) lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5))
self.primaryColor = ConversationStyle.primaryColor(thread: thread) self.primaryColor = ConversationStyle.primaryColor(thread: thread)
} }

Loading…
Cancel
Save