Merge branch 'charlesmchen/smallMediaCorners'
This commit is contained in:
commit
cf38da0d18
@ -6,7 +6,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern const CGFloat kOWSMessageCellCornerRadius;
|
||||
extern const CGFloat kOWSMessageCellCornerRadius_Large;
|
||||
extern const CGFloat kOWSMessageCellCornerRadius_Small;
|
||||
|
||||
@class OWSBubbleView;
|
||||
|
||||
@ -24,6 +25,9 @@ extern const CGFloat kOWSMessageCellCornerRadius;
|
||||
|
||||
@property (nonatomic, nullable) UIColor *bubbleColor;
|
||||
|
||||
@property (nonatomic) BOOL useSmallCorners_Top;
|
||||
@property (nonatomic) BOOL useSmallCorners_Bottom;
|
||||
|
||||
- (UIBezierPath *)maskPath;
|
||||
|
||||
#pragma mark - Coordination
|
||||
@ -34,7 +38,7 @@ extern const CGFloat kOWSMessageCellCornerRadius;
|
||||
|
||||
- (void)updatePartnerViews;
|
||||
|
||||
+ (CGFloat)minWidth;
|
||||
- (CGFloat)minWidth;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
const CGFloat kOWSMessageCellCornerRadius = 16;
|
||||
const CGFloat kOWSMessageCellCornerRadius_Large = 16;
|
||||
const CGFloat kOWSMessageCellCornerRadius_Small = 2;
|
||||
|
||||
@interface OWSBubbleView ()
|
||||
|
||||
@ -89,9 +90,7 @@ const CGFloat kOWSMessageCellCornerRadius = 16;
|
||||
{
|
||||
_bubbleColor = bubbleColor;
|
||||
|
||||
if (!self.shapeLayer) {
|
||||
[self updateLayers];
|
||||
}
|
||||
[self updateLayers];
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
@ -102,6 +101,20 @@ const CGFloat kOWSMessageCellCornerRadius = 16;
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (void)setUseSmallCorners_Top:(BOOL)useSmallCorners_Top
|
||||
{
|
||||
_useSmallCorners_Top = useSmallCorners_Top;
|
||||
|
||||
[self updateLayers];
|
||||
}
|
||||
|
||||
- (void)setUseSmallCorners_Bottom:(BOOL)useSmallCorners_Bottom
|
||||
{
|
||||
_useSmallCorners_Bottom = useSmallCorners_Bottom;
|
||||
|
||||
[self updateLayers];
|
||||
}
|
||||
|
||||
- (void)updateLayers
|
||||
{
|
||||
if (!self.maskLayer) {
|
||||
@ -126,14 +139,42 @@ const CGFloat kOWSMessageCellCornerRadius = 16;
|
||||
|
||||
- (UIBezierPath *)maskPath
|
||||
{
|
||||
return [self.class maskPathForSize:self.bounds.size];
|
||||
return [self.class maskPathForSize:self.bounds.size
|
||||
useSmallCorners_Top:self.useSmallCorners_Top
|
||||
useSmallCorners_Bottom:self.useSmallCorners_Bottom];
|
||||
}
|
||||
|
||||
+ (UIBezierPath *)maskPathForSize:(CGSize)size
|
||||
useSmallCorners_Top:(BOOL)useSmallCorners_Top
|
||||
useSmallCorners_Bottom:(BOOL)useSmallCorners_Bottom
|
||||
{
|
||||
CGRect bounds = CGRectZero;
|
||||
bounds.size = size;
|
||||
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:bounds cornerRadius:kOWSMessageCellCornerRadius];
|
||||
|
||||
UIBezierPath *bezierPath = [UIBezierPath new];
|
||||
|
||||
CGFloat bubbleLeft = 0.f;
|
||||
CGFloat bubbleRight = size.width;
|
||||
CGFloat bubbleTop = 0.f;
|
||||
CGFloat bubbleBottom = size.height;
|
||||
CGFloat topRounding = (useSmallCorners_Top ? kOWSMessageCellCornerRadius_Small : kOWSMessageCellCornerRadius_Large);
|
||||
CGFloat bottomRounding
|
||||
= (useSmallCorners_Bottom ? kOWSMessageCellCornerRadius_Small : kOWSMessageCellCornerRadius_Large);
|
||||
|
||||
[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)];
|
||||
|
||||
return bezierPath;
|
||||
}
|
||||
|
||||
@ -164,9 +205,13 @@ const CGFloat kOWSMessageCellCornerRadius = 16;
|
||||
}
|
||||
}
|
||||
|
||||
+ (CGFloat)minWidth
|
||||
- (CGFloat)minWidth
|
||||
{
|
||||
return (kOWSMessageCellCornerRadius * 2);
|
||||
if (self.useSmallCorners_Top && self.useSmallCorners_Bottom) {
|
||||
return (kOWSMessageCellCornerRadius_Small * 2);
|
||||
} else {
|
||||
return (kOWSMessageCellCornerRadius_Large * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -488,6 +488,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// If we're stroking the bubble edge, ensure the stroke
|
||||
// view is in front of its peers to prevent it from being occluded.
|
||||
[self.bubbleStrokeView.superview bringSubviewToFront:self.bubbleStrokeView];
|
||||
|
||||
[self configureBubbleRounding];
|
||||
}
|
||||
|
||||
- (void)configureBubbleRounding
|
||||
{
|
||||
self.bubbleView.useSmallCorners_Top
|
||||
= (self.hasBodyMediaWithThumbnail && !self.shouldShowSenderName && !self.isQuotedReply);
|
||||
self.bubbleView.useSmallCorners_Bottom
|
||||
= (self.hasBodyMediaWithThumbnail && !self.hasBodyText && !self.hasBottomFooter);
|
||||
}
|
||||
|
||||
- (void)updateBubbleColor
|
||||
@ -1164,6 +1174,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
CGSize cellSize = CGSizeZero;
|
||||
|
||||
[self configureBubbleRounding];
|
||||
|
||||
NSMutableArray<NSValue *> *textViewSizes = [NSMutableArray new];
|
||||
|
||||
NSValue *_Nullable senderNameSize = [self senderNameSize];
|
||||
@ -1221,7 +1233,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
}
|
||||
|
||||
// Make sure the bubble is always wide enough to complete it's bubble shape.
|
||||
cellSize.width = MAX(cellSize.width, OWSBubbleView.minWidth);
|
||||
cellSize.width = MAX(cellSize.width, self.bubbleView.minWidth);
|
||||
|
||||
OWSAssert(cellSize.width > 0 && cellSize.height > 0);
|
||||
|
||||
|
||||
@ -342,7 +342,8 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
|
||||
detailView.backgroundColor = .clear
|
||||
self.view.backgroundColor = .clear
|
||||
|
||||
self.presentationView.layer.cornerRadius = kOWSMessageCellCornerRadius
|
||||
// TODO: Sync with (possibly assymetrical) corner rounding in message bubbles.
|
||||
self.presentationView.layer.cornerRadius = kOWSMessageCellCornerRadius_Large
|
||||
|
||||
fromViewController.present(self, animated: false) {
|
||||
|
||||
@ -505,7 +506,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
|
||||
if changedItems {
|
||||
self.presentationView.alpha = 0
|
||||
} else {
|
||||
self.presentationView.layer.cornerRadius = kOWSMessageCellCornerRadius
|
||||
self.presentationView.layer.cornerRadius = kOWSMessageCellCornerRadius_Large
|
||||
}
|
||||
},
|
||||
completion: { (_: Bool) in
|
||||
|
||||
Loading…
Reference in New Issue
Block a user