Skip to content

Commit

Permalink
[Ink] Combine initialization method for MDCLegacyInkLayer (#7316)
Browse files Browse the repository at this point in the history
  • Loading branch information
maicki authored and yarneo committed May 1, 2019
1 parent 780b916 commit 932c32f
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions components/Ink/src/private/MDCLegacyInkLayer.m
Expand Up @@ -476,12 +476,7 @@ - (instancetype)init {
self = [super init];
if (self) {
self.masksToBounds = YES;
_inkColor = [UIColor colorWithWhite:0 alpha:(CGFloat)0.08];
_bounded = YES;
_compositeRipple = [CAShapeLayer layer];
_foregroundRipples = [NSMutableArray array];
_backgroundRipples = [NSMutableArray array];
[self addSublayer:_compositeRipple];
[self commonMDCLegacyInkLayerInit];
}
return self;
}
Expand All @@ -490,24 +485,28 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];

if (self) {
_bounded = YES;
_inkColor = [UIColor colorWithWhite:0 alpha:(CGFloat)0.08];
// Discard any sublayers, which should be the composite ripple and any active ripples
if (self.sublayers.count > 0) {
NSArray<CALayer *> *sublayers = [self.sublayers copy];
for (CALayer *sublayer in sublayers) {
[sublayer removeFromSuperlayer];
}
}
_compositeRipple = [CAShapeLayer layer];
_foregroundRipples = [NSMutableArray array];
_backgroundRipples = [NSMutableArray array];
[self addSublayer:_compositeRipple];
[self commonMDCLegacyInkLayerInit];
}

return self;
}

- (void)commonMDCLegacyInkLayerInit {
_bounded = YES;
_inkColor = [UIColor colorWithWhite:0 alpha:(CGFloat)0.08];
_compositeRipple = [CAShapeLayer layer];
_foregroundRipples = [NSMutableArray array];
_backgroundRipples = [NSMutableArray array];
[self addSublayer:_compositeRipple];
}

- (void)layoutSublayers {
[super layoutSublayers];
CGFloat radius = MDCLegacyInkLayerRadiusBounds(
Expand Down

0 comments on commit 932c32f

Please sign in to comment.