[ProgressView] Use MDCPalettes for default tint color
* [ProgressView] Use MDCPalettes for default tint color
* Removed unnecessary method
* [ProgressView] Correcting merge mistake.
I accidentally kept it 'sss' instead of 'spec' when I did a web-based update.
MODIFY
MaterialComponents.podspec
MaterialComponents.podspec
@@ -391,6 +391,7 @@ Pod::Spec.new do |mdc|
spec.source_files = "components/#{component.base_name}/src/*.{h,m}"
spec.dependency "MDFInternationalization"
+ spec.dependency "MaterialComponents/Palettes"
spec.dependency "MaterialComponents/private/Math"
end
component.subspec "ColorThemer" do |spec|

MODIFY
components/ProgressView/src/MDCProgressView.m
components/ProgressView/src/MDCProgressView.m
#import "MDFInternationalization.h"
#import "MaterialMath.h"
+#import "MaterialPalettes.h"
-// Blue 500 from https://material.io/guidelines/style/color.html#color-color-palette .
-static const uint32_t MDCProgressViewDefaultTintColor = 0x2196F3;
+static inline UIColor *MDCProgressViewDefaultTintColor(void) {
+ return MDCPalette.bluePalette.tint500;
+}
// The ratio by which to desaturate the progress tint color to obtain the default track tint color.
static const CGFloat MDCProgressViewTrackColorDesaturation = 0.3f;
-// Creates a UIColor from a 24-bit RGB color encoded as an integer.
-static inline UIColor *MDCColorFromRGB(uint32_t rgbValue) {
- return [UIColor colorWithRed:((CGFloat)((rgbValue & 0xFF0000) >> 16)) / 255
- green:((CGFloat)((rgbValue & 0x00FF00) >> 8)) / 255
- blue:((CGFloat)((rgbValue & 0x0000FF) >> 0)) / 255
- alpha:1];
-}
-
static const NSTimeInterval MDCProgressViewAnimationDuration = 0.25;
@interface MDCProgressView ()
@@ -79,7 +73,7 @@ static const NSTimeInterval MDCProgressViewAnimationDuration = 0.25;
_progressView = [[UIView alloc] initWithFrame:CGRectZero];
[self addSubview:_progressView];
- _progressView.backgroundColor = [[self class] defaultProgressTintColor];
+ _progressView.backgroundColor = MDCProgressViewDefaultTintColor();
_trackView.backgroundColor =
[[self class] defaultTrackTintColorForProgressTintColor:_progressView.backgroundColor];
}
@@ -105,7 +99,7 @@ static const NSTimeInterval MDCProgressViewAnimationDuration = 0.25;
- (void)setProgressTintColor:(UIColor *)progressTintColor {
if (progressTintColor == nil) {
- progressTintColor = [[self class] defaultProgressTintColor];
+ progressTintColor = MDCProgressViewDefaultTintColor();
}
self.progressView.backgroundColor = progressTintColor;
}
@@ -264,10 +258,6 @@ static const NSTimeInterval MDCProgressViewAnimationDuration = 0.25;
return UIViewAnimationOptionCurveLinear;
}
-+ (UIColor *)defaultProgressTintColor {
- return MDCColorFromRGB(MDCProgressViewDefaultTintColor);
-}
-
+ (UIColor *)defaultTrackTintColorForProgressTintColor:(UIColor *)progressTintColor {
CGFloat hue, saturation, brightness, alpha;
if ([progressTintColor getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha]) {

[ProgressView] Use MDCPalettes for default tint color (#2368)

* [ProgressView] Use MDCPalettes for default tint color

* Removed unnecessary method

* [ProgressView] Correcting merge mistake.

I accidentally kept it 'sss' instead of 'spec' when I did a web-based update.