From 4d945c06b144c0406520d218e76588a59cadb782 Mon Sep 17 00:00:00 2001 From: Bryan Oltman Date: Tue, 10 Dec 2019 15:49:39 -0500 Subject: [PATCH] [ActionSheet] Delete inkColor and enableRippleBehavior properties (#9238) MDCActionSheetController's inkColor and enableRippleBehavior properties are deprecated and have no internal usage. inkColor and enableRippleBehavior properties still exist in MDCActionSheetItemTableViewCell and will be deleted in a future PR. Fixes #9128 --- .../ColorThemer/MDCActionSheetColorThemer.m | 8 +-- .../src/MDCActionSheetController.h | 18 ------ .../src/MDCActionSheetController.m | 25 +------- ...MDCActionSheetController+MaterialTheming.m | 9 +-- .../tests/unit/ActionSheetRippleTests.m | 63 +------------------ .../MDCActionSheetThemeTest.m | 3 - .../tests/unit/MDCActionSheetTableCellTest.m | 14 ----- .../unit/Theming/MDCActionSheetThemingTest.m | 3 - 8 files changed, 7 insertions(+), 136 deletions(-) diff --git a/components/ActionSheet/src/ColorThemer/MDCActionSheetColorThemer.m b/components/ActionSheet/src/ColorThemer/MDCActionSheetColorThemer.m index 516eb6408e4..10b3fa35996 100644 --- a/components/ActionSheet/src/ColorThemer/MDCActionSheetColorThemer.m +++ b/components/ActionSheet/src/ColorThemer/MDCActionSheetColorThemer.m @@ -38,12 +38,8 @@ + (void)applySemanticColorScheme:(id)colorScheme [colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]; actionSheetController.actionTextColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kHighAlpha]; - UIColor *rippleColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - actionSheetController.inkColor = rippleColor; -#pragma clang diagnostic pop - actionSheetController.rippleColor = rippleColor; + actionSheetController.rippleColor = + [colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha]; } @end diff --git a/components/ActionSheet/src/MDCActionSheetController.h b/components/ActionSheet/src/MDCActionSheetController.h index 6678a5b57b5..ec6779fef31 100644 --- a/components/ActionSheet/src/MDCActionSheetController.h +++ b/components/ActionSheet/src/MDCActionSheetController.h @@ -181,24 +181,6 @@ __attribute__((objc_subclassing_restricted)) @interface MDCActionSheetController */ @property(nonatomic, strong, nullable) UIColor *actionTintColor; -/** - The ink color for the action items within an action sheet. - */ -@property(nonatomic, strong, nullable) - UIColor *inkColor __deprecated_msg("Use rippleColor instead."); - -/** - By setting this property to @c YES, the Ripple component will be used instead of Ink - to display visual feedback to the user. - - @note This property is enabled by default. It will be deprecated and then deleted as part of our - migration to Ripple. Learn more at - https://github.com/material-components/material-components-ios/tree/develop/components/Ink#migration-guide-ink-to-ripple - - Defaults to YES. - */ -@property(nonatomic, assign) BOOL enableRippleBehavior __deprecated; - /** The ripple color for the action items within an action sheet. */ diff --git a/components/ActionSheet/src/MDCActionSheetController.m b/components/ActionSheet/src/MDCActionSheetController.m index efed6d75f4e..27e75087485 100644 --- a/components/ActionSheet/src/MDCActionSheetController.m +++ b/components/ActionSheet/src/MDCActionSheetController.m @@ -140,7 +140,6 @@ - (instancetype)initWithTitle:(NSString *)title message:(NSString *)message { [UIColor.blackColor colorWithAlphaComponent:kDividerDefaultAlpha]; _mdc_overrideBaseElevation = -1; _elevation = MDCShadowElevationModalBottomSheet; - _enableRippleBehavior = YES; } return self; @@ -325,11 +324,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cell.backgroundColor = self.backgroundColor; cell.actionFont = self.actionFont; cell.accessibilityIdentifier = action.accessibilityIdentifier; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - cell.inkColor = self.inkColor; - cell.enableRippleBehavior = self.enableRippleBehavior; -#pragma clang diagnostic pop + cell.enableRippleBehavior = YES; cell.rippleColor = self.rippleColor; cell.tintColor = action.tintColor ?: self.actionTintColor; cell.imageRenderingMode = self.imageRenderingMode; @@ -513,29 +508,11 @@ - (BOOL)anyActionHasAnImage { return NO; } -- (UIColor *)inkColor { - return _inkColor; -} - -- (void)setInkColor:(UIColor *)inkColor { - _inkColor = inkColor; - [self.tableView reloadData]; -} - - (void)setRippleColor:(UIColor *)rippleColor { _rippleColor = rippleColor; [self.tableView reloadData]; } -- (void)setEnableRippleBehavior:(BOOL)enableRippleBehavior { - if (_enableRippleBehavior == enableRippleBehavior) { - return; - } - _enableRippleBehavior = enableRippleBehavior; - - [self.tableView reloadData]; -} - - (void)setElevation:(MDCShadowElevation)elevation { if (MDCCGFloatEqual(elevation, _elevation)) { return; diff --git a/components/ActionSheet/src/Theming/MDCActionSheetController+MaterialTheming.m b/components/ActionSheet/src/Theming/MDCActionSheetController+MaterialTheming.m index 8a61ed7df45..0321f0f5971 100644 --- a/components/ActionSheet/src/Theming/MDCActionSheetController+MaterialTheming.m +++ b/components/ActionSheet/src/Theming/MDCActionSheetController+MaterialTheming.m @@ -19,7 +19,7 @@ static const CGFloat kHighAlpha = (CGFloat)0.87; static const CGFloat kMediumAlpha = (CGFloat)0.6; -static const CGFloat kInkAlpha = (CGFloat)0.16; +static const CGFloat kRippleAlpha = (CGFloat)0.16; @implementation MDCActionSheetController (MaterialTheming) @@ -57,12 +57,7 @@ - (void)applyThemeWithColorScheme:(id)colorScheme { self.imageRenderingMode = UIImageRenderingModeAlwaysTemplate; self.actionTintColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]; self.actionTextColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kHighAlpha]; - UIColor *rippleColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - self.inkColor = rippleColor; -#pragma clang diagnostic pop - self.rippleColor = rippleColor; + self.rippleColor = [colorScheme.onSurfaceColor colorWithAlphaComponent:kRippleAlpha]; #if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0) if (@available(iOS 13.0, *)) { self.traitCollectionDidChangeBlock = ^(MDCActionSheetController *_Nonnull actionSheet, diff --git a/components/ActionSheet/tests/unit/ActionSheetRippleTests.m b/components/ActionSheet/tests/unit/ActionSheetRippleTests.m index 6ded6b1c9f8..b6e9e35a97b 100644 --- a/components/ActionSheet/tests/unit/ActionSheetRippleTests.m +++ b/components/ActionSheet/tests/unit/ActionSheetRippleTests.m @@ -55,16 +55,11 @@ - (void)tearDown { /** Test to confirm behavior of initializing a @c MDCActionSheetController without any customization. */ -- (void)testRippleIsEnabledAndInkIsDisabledForAllCellsAndTheirPropertiesAreCorrect { +- (void)testDefaultRipplePropertiesAreCorrect { // When NSArray *cells = [MDCActionSheetTestHelper getCellsFromActionSheet:self.actionSheetController]; -// Then -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - XCTAssertTrue(self.actionSheetController.enableRippleBehavior); - XCTAssertEqualObjects(self.actionSheetController.inkColor, nil); -#pragma clang diagnostic pop + // Then XCTAssertEqualObjects(self.actionSheetController.rippleColor, nil); for (MDCActionSheetItemTableViewCell *cell in cells) { XCTAssertTrue(cell.enableRippleBehavior); @@ -86,60 +81,6 @@ - (void)testRippleIsEnabledAndInkIsDisabledForAllCellsAndTheirPropertiesAreCorre } } -/** - Test to confirm behavior of initializing a @c MDCActionSheetController with Ripple enabled. - */ -- (void) - testRippleIsEnabledAndInkIsDisabledForAllCellsAndTheirPropertiesAreCorrectWhenRippleBehaviorIsEnabled { - // When - NSArray *cells = [MDCActionSheetTestHelper getCellsFromActionSheet:self.actionSheetController]; - -// Then -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - XCTAssertTrue(self.actionSheetController.enableRippleBehavior); - XCTAssertEqualObjects(self.actionSheetController.inkColor, nil); -#pragma clang diagnostic pop - XCTAssertEqualObjects(self.actionSheetController.rippleColor, nil); - for (MDCActionSheetItemTableViewCell *cell in cells) { - XCTAssertTrue(cell.enableRippleBehavior); - XCTAssertNotNil(cell.rippleTouchController); - XCTAssertNotNil(cell.inkTouchController); - XCTAssertEqualObjects(cell.inkTouchController.defaultInkView.inkColor, - [[UIColor alloc] initWithWhite:0 alpha:(CGFloat)0.14]); - XCTAssertEqualObjects(cell.rippleTouchController.rippleView.rippleColor, - [[UIColor alloc] initWithWhite:0 alpha:(CGFloat)0.14]); - XCTAssertEqual(cell.inkTouchController.defaultInkView.inkStyle, MDCInkStyleBounded); - XCTAssertEqual(cell.rippleTouchController.rippleView.rippleStyle, MDCRippleStyleBounded); - XCTAssertNotNil(cell.rippleTouchController.rippleView.superview); - XCTAssertNil(cell.inkTouchController.defaultInkView.superview); - - CGRect cellBounds = CGRectStandardize(cell.bounds); - CGRect rippleBounds = CGRectStandardize(cell.rippleTouchController.rippleView.bounds); - XCTAssertTrue(CGRectEqualToRect(cellBounds, rippleBounds), @"%@ is not equal to %@", - NSStringFromCGRect(cellBounds), NSStringFromCGRect(rippleBounds)); - } -} - -/** - Test to confirm toggling @c enableRippleBehavior removes the @c rippleView as a subview. - */ -- (void)testSetEnableRippleBehaviorToYesThenNoRemovesRippleViewAsSubviewOfCell { -// When -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - self.actionSheetController.enableRippleBehavior = YES; - self.actionSheetController.enableRippleBehavior = NO; -#pragma clang diagnostic pop - NSArray *cells = [MDCActionSheetTestHelper getCellsFromActionSheet:self.actionSheetController]; - - // Then - for (MDCActionSheetItemTableViewCell *cell in cells) { - XCTAssertEqualObjects(cell.inkTouchController.defaultInkView.superview, cell); - XCTAssertNil(cell.rippleTouchController.rippleView.superview); - } -} - /** Test setting ActionSheet's RippleColor API updates the internal RippleTouchController's ripple color. diff --git a/components/ActionSheet/tests/unit/ActionSheetThemer/MDCActionSheetThemeTest.m b/components/ActionSheet/tests/unit/ActionSheetThemer/MDCActionSheetThemeTest.m index 45f1b63bc48..4d1e488fc90 100644 --- a/components/ActionSheet/tests/unit/ActionSheetThemer/MDCActionSheetThemeTest.m +++ b/components/ActionSheet/tests/unit/ActionSheetThemer/MDCActionSheetThemeTest.m @@ -23,7 +23,6 @@ static const CGFloat kHighAlpha = (CGFloat)0.87; static const CGFloat kMediumAlpha = (CGFloat)0.6; -static const CGFloat kInkAlpha = (CGFloat)0.16; @interface MDCActionSheetHeaderView (Testing) @property(nonatomic, strong) UILabel *titleLabel; @@ -193,8 +192,6 @@ - (void)testApplyColorTheme { [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]); XCTAssertEqualObjects(cell.actionLabel.textColor, [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kHighAlpha]); - XCTAssertEqualObjects(cell.inkTouchController.defaultInkView.inkColor, - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha]); } } diff --git a/components/ActionSheet/tests/unit/MDCActionSheetTableCellTest.m b/components/ActionSheet/tests/unit/MDCActionSheetTableCellTest.m index 4a4f08c1b64..e5facc064a2 100644 --- a/components/ActionSheet/tests/unit/MDCActionSheetTableCellTest.m +++ b/components/ActionSheet/tests/unit/MDCActionSheetTableCellTest.m @@ -134,20 +134,6 @@ - (void)testDefaultInkColor { } } -- (void)testSetInkColor { - // When - NSArray *colors = [MDCActionSheetTestHelper colorsToTest]; - - for (UIColor *color in colors) { - self.actionSheet.inkColor = color; - NSArray *cells = [MDCActionSheetTestHelper getCellsFromActionSheet:self.actionSheet]; - for (MDCActionSheetItemTableViewCell *cell in cells) { - // Then - XCTAssertEqualObjects(cell.inkTouchController.defaultInkView.inkColor, color); - } - } -} - - (void)testSetRippleColor { // When NSArray *colors = [MDCActionSheetTestHelper colorsToTest]; diff --git a/components/ActionSheet/tests/unit/Theming/MDCActionSheetThemingTest.m b/components/ActionSheet/tests/unit/Theming/MDCActionSheetThemingTest.m index b46c949e776..d5d66354b26 100644 --- a/components/ActionSheet/tests/unit/Theming/MDCActionSheetThemingTest.m +++ b/components/ActionSheet/tests/unit/Theming/MDCActionSheetThemingTest.m @@ -21,7 +21,6 @@ static const CGFloat kHighAlpha = (CGFloat)0.87; static const CGFloat kMediumAlpha = (CGFloat)0.6; -static const CGFloat kInkAlpha = (CGFloat)0.16; @interface MDCActionSheetController (Testing) @property(nonatomic, strong) UITableView *tableView; @@ -94,8 +93,6 @@ - (void)testActionSheetThemingTest { [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kMediumAlpha]); XCTAssertEqualObjects(actionSheetCell.actionLabel.textColor, [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kHighAlpha]); - XCTAssertEqualObjects(actionSheetCell.inkTouchController.defaultInkView.inkColor, - [self.colorScheme.onSurfaceColor colorWithAlphaComponent:kInkAlpha]); XCTAssertEqualObjects(actionSheetCell.actionLabel.font, typographyScheme.subtitle1); // Elevation