Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions components/private/Color/src/MaterialColor.h

This file was deleted.

34 changes: 0 additions & 34 deletions components/private/Color/src/UIColor+MDC.h

This file was deleted.

53 changes: 0 additions & 53 deletions components/private/Color/src/UIColor+MDC.m

This file was deleted.

48 changes: 38 additions & 10 deletions components/private/ThumbTrack/src/MDCThumbTrack.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#import "MDCThumbView.h"
#import "MaterialInk.h"
#import "MaterialRTL.h"
#import "UIColor+MDC.h"

static const CGFloat kAnimationDuration = 0.25f;
static const CGFloat kThumbChangeAnimationDuration = 0.12f;
Expand Down Expand Up @@ -622,17 +621,17 @@ - (void)updateViewsNoAnimation {
if (_interpolateOnOffColors) {
// Set background/border colors based on interpolated percent.
CGFloat percent = [self relativeValueForValue:_value];
_thumbView.layer.backgroundColor = [UIColor mdc_colorInterpolatedFromColor:_thumbOffColor
toColor:_thumbOnColor
percent:percent]
_thumbView.layer.backgroundColor = [self colorInterpolatedFromColor:_thumbOffColor
toColor:_thumbOnColor
percent:percent]
.CGColor;
_thumbView.layer.borderColor = [UIColor mdc_colorInterpolatedFromColor:_thumbOffColor
toColor:_thumbOnColor
percent:percent]
_thumbView.layer.borderColor = [self colorInterpolatedFromColor:_thumbOffColor
toColor:_thumbOnColor
percent:percent]
.CGColor;
_trackView.backgroundColor = [UIColor mdc_colorInterpolatedFromColor:_trackOffColor
toColor:_trackOnColor
percent:percent];
_trackView.backgroundColor = [self colorInterpolatedFromColor:_trackOffColor
toColor:_trackOnColor
percent:percent];
_trackOnLayer.backgroundColor = _clearColor.CGColor;
} else if (!_thumbIsHollowAtStart || ![self isValueAtMinimum]) {
[self updateTrackMask];
Expand Down Expand Up @@ -936,6 +935,35 @@ - (void)updateDummyPanRecognizerTarget {
[panTarget addGestureRecognizer:_dummyPanRecognizer];
}

#pragma mark - Color Helpers

- (UIColor *)colorInterpolatedFromColor:(UIColor *)fromColor toColor:(UIColor *)toColor percent:(CGFloat)percent {
// Clamp percent to [0.0, 1.0]
percent = MAX(0, percent);
percent = MIN(1, percent);

CGFloat r1, g1, b1, a1;
r1 = g1 = b1 = a1 = 1;
if (![fromColor getRed:&r1 green:&g1 blue:&b1 alpha:&a1]) {
[fromColor getWhite:&r1 alpha:&a1];
g1 = b1 = r1;
};

CGFloat r2, g2, b2, a2;
r2 = g2 = b2 = a2 = 1;
if (![toColor getRed:&r2 green:&g2 blue:&b2 alpha:&a2]) {
[toColor getWhite:&r2 alpha:&a2];
g2 = b2 = r2;
}

CGFloat rfinal = r1 * (1 - percent) + r2 * percent;
CGFloat gfinal = g1 * (1 - percent) + g2 * percent;
CGFloat bfinal = b1 * (1 - percent) + b2 * percent;
CGFloat afinal = a1 * (1 - percent) + a2 * percent;

return [UIColor colorWithRed:rfinal green:gfinal blue:bfinal alpha:afinal];
}

#pragma mark - UIResponder Events

/**
Expand Down