From 932c32f7c58b1837654ad7c1c160e91ccbe81f95 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Wed, 1 May 2019 14:28:46 -0700 Subject: [PATCH] [Ink] Combine initialization method for MDCLegacyInkLayer (#7316) --- .../Ink/src/private/MDCLegacyInkLayer.m | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/components/Ink/src/private/MDCLegacyInkLayer.m b/components/Ink/src/private/MDCLegacyInkLayer.m index 06b217f69f1..9ad8bbbc589 100644 --- a/components/Ink/src/private/MDCLegacyInkLayer.m +++ b/components/Ink/src/private/MDCLegacyInkLayer.m @@ -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; } @@ -490,8 +485,6 @@ - (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 *sublayers = [self.sublayers copy]; @@ -499,15 +492,21 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { [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(