Skip to content

Commit

Permalink
[ActionSheet] Delete inkColor and enableRippleBehavior properties (#9238
Browse files Browse the repository at this point in the history
)

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
  • Loading branch information
bryanoltman committed Dec 10, 2019
1 parent 30df338 commit 4d945c0
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 136 deletions.
Expand Up @@ -38,12 +38,8 @@ + (void)applySemanticColorScheme:(id<MDCColorScheming>)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
18 changes: 0 additions & 18 deletions components/ActionSheet/src/MDCActionSheetController.h
Expand Up @@ -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.
*/
Expand Down
25 changes: 1 addition & 24 deletions components/ActionSheet/src/MDCActionSheetController.m
Expand Up @@ -140,7 +140,6 @@ - (instancetype)initWithTitle:(NSString *)title message:(NSString *)message {
[UIColor.blackColor colorWithAlphaComponent:kDividerDefaultAlpha];
_mdc_overrideBaseElevation = -1;
_elevation = MDCShadowElevationModalBottomSheet;
_enableRippleBehavior = YES;
}

return self;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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)

Expand Down Expand Up @@ -57,12 +57,7 @@ - (void)applyThemeWithColorScheme:(id<MDCColorScheming>)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,
Expand Down
63 changes: 2 additions & 61 deletions components/ActionSheet/tests/unit/ActionSheetRippleTests.m
Expand Up @@ -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);
Expand All @@ -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.
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
}
}

Expand Down
14 changes: 0 additions & 14 deletions components/ActionSheet/tests/unit/MDCActionSheetTableCellTest.m
Expand Up @@ -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];
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4d945c0

Please sign in to comment.