Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent d161e5ff3d
commit cbaf40d4ce

@ -30,10 +30,15 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
+ (OWSBubbleShapeView *)bubbleDrawView; - (instancetype)initDraw NS_DESIGNATED_INITIALIZER;
+ (OWSBubbleShapeView *)bubbleShadowView; - (instancetype)initShadow NS_DESIGNATED_INITIALIZER;
+ (OWSBubbleShapeView *)bubbleClipView; ;
+ (OWSBubbleShapeView *)bubbleInnerShadowView; - (instancetype)initClip NS_DESIGNATED_INITIALIZER;
;
- (instancetype)initInnerShadowWithColor:(UIColor *)color
radius:(CGFloat)radius
opacity:(float)opacity NS_DESIGNATED_INITIALIZER;
;
@end @end

@ -31,13 +31,8 @@ typedef NS_ENUM(NSUInteger, OWSBubbleShapeViewMode) {
@implementation OWSBubbleShapeView @implementation OWSBubbleShapeView
- (instancetype)init - (void)configure
{ {
self = [super init];
if (!self) {
return self;
}
self.mode = OWSBubbleShapeViewMode_Draw; self.mode = OWSBubbleShapeViewMode_Draw;
self.opaque = NO; self.opaque = NO;
self.backgroundColor = [UIColor clearColor]; self.backgroundColor = [UIColor clearColor];
@ -47,36 +42,67 @@ typedef NS_ENUM(NSUInteger, OWSBubbleShapeViewMode) {
[self.layer addSublayer:self.shapeLayer]; [self.layer addSublayer:self.shapeLayer];
self.maskLayer = [CAShapeLayer new]; self.maskLayer = [CAShapeLayer new];
return self;
} }
+ (OWSBubbleShapeView *)bubbleDrawView
- (instancetype)initDraw
{ {
OWSBubbleShapeView *instance = [OWSBubbleShapeView new]; self = [super init];
instance.mode = OWSBubbleShapeViewMode_Draw; if (!self) {
return instance; return self;
}
self.mode = OWSBubbleShapeViewMode_Draw;
[self configure];
return self;
} }
+ (OWSBubbleShapeView *)bubbleShadowView - (instancetype)initShadow
{ {
OWSBubbleShapeView *instance = [OWSBubbleShapeView new]; self = [super init];
instance.mode = OWSBubbleShapeViewMode_Shadow; if (!self) {
return instance; return self;
}
self.mode = OWSBubbleShapeViewMode_Shadow;
[self configure];
return self;
} }
+ (OWSBubbleShapeView *)bubbleClipView - (instancetype)initClip
{ {
OWSBubbleShapeView *instance = [OWSBubbleShapeView new]; self = [super init];
instance.mode = OWSBubbleShapeViewMode_Clip; if (!self) {
return instance; return self;
}
self.mode = OWSBubbleShapeViewMode_Clip;
[self configure];
return self;
} }
+ (OWSBubbleShapeView *)bubbleInnerShadowView - (instancetype)initInnerShadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(float)opacity
{ {
OWSBubbleShapeView *instance = [OWSBubbleShapeView new]; self = [super init];
instance.mode = OWSBubbleShapeViewMode_InnerShadow; if (!self) {
return instance; return self;
}
self.mode = OWSBubbleShapeViewMode_InnerShadow;
_innerShadowColor = color;
_innerShadowRadius = radius;
_innerShadowOpacity = opacity;
[self configure];
[self updateLayers];
return self;
} }
- (void)setFillColor:(nullable UIColor *)fillColor - (void)setFillColor:(nullable UIColor *)fillColor

@ -352,11 +352,11 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (self.hasBodyMediaWithThumbnail) { if (self.hasBodyMediaWithThumbnail) {
[self.stackView addArrangedSubview:bodyMediaView]; [self.stackView addArrangedSubview:bodyMediaView];
OWSBubbleShapeView *innerShadowView = [OWSBubbleShapeView bubbleInnerShadowView]; OWSBubbleShapeView *innerShadowView = [[OWSBubbleShapeView alloc]
innerShadowView.innerShadowColor initInnerShadowWithColor:(Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor
= (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_blackColor); : UIColor.ows_blackColor)
innerShadowView.innerShadowRadius = 0.5f; radius:0.5f
innerShadowView.innerShadowOpacity = 0.15f; opacity:0.15f];
[bodyMediaView addSubview:innerShadowView]; [bodyMediaView addSubview:innerShadowView];
[self.bubbleView addPartnerView:innerShadowView]; [self.bubbleView addPartnerView:innerShadowView];
[self.viewConstraints addObjectsFromArray:[innerShadowView ows_autoPinToSuperviewEdges]]; [self.viewConstraints addObjectsFromArray:[innerShadowView ows_autoPinToSuperviewEdges]];
@ -497,8 +497,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
UIView *proxyView = [UIView new]; UIView *proxyView = [UIView new];
[self.stackView addArrangedSubview:proxyView]; [self.stackView addArrangedSubview:proxyView];
OWSBubbleShapeView *shadowView = [OWSBubbleShapeView bubbleShadowView]; OWSBubbleShapeView *shadowView = [[OWSBubbleShapeView alloc] initShadow];
OWSBubbleShapeView *clipView = [OWSBubbleShapeView bubbleClipView]; OWSBubbleShapeView *clipView = [[OWSBubbleShapeView alloc] initClip];
[self addSubview:shadowView]; [self addSubview:shadowView];
[self addSubview:clipView]; [self addSubview:clipView];

Loading…
Cancel
Save