[Collections] Use MDCPalettes for info bar colors
MODIFY
MaterialComponents.podspec
MaterialComponents.podspec
@@ -226,6 +226,7 @@ Pod::Spec.new do |mdc|
component.dependency "MaterialComponents/CollectionCells"
component.dependency "MaterialComponents/CollectionLayoutAttributes"
component.dependency "MaterialComponents/Ink"
+ component.dependency "MaterialComponents/Palettes"
component.dependency "MaterialComponents/ShadowElevations"
component.dependency "MaterialComponents/ShadowLayer"
component.dependency "MaterialComponents/Typography"

MODIFY
components/Collections/src/private/MDCCollectionInfoBarView.m
components/Collections/src/private/MDCCollectionInfoBarView.m
#import "MDCCollectionInfoBarView.h"
+#import "MaterialPalettes.h"
#import "MaterialShadowLayer.h"
#import "MaterialTypography.h"
@@ -25,16 +26,12 @@ const CGFloat MDCCollectionInfoBarFooterHeight = 48.0f;
static const CGFloat MDCCollectionInfoBarLabelHorizontalPadding = 16.0f;
-// Colors derived from https://material.io/guidelines/style/color.html#color-color-palette .
-static const uint32_t kCollectionInfoBarBlueColor = 0x448AFF; // Blue A200
-static const uint32_t kCollectionInfoBarRedColor = 0xF44336; // Red 500
+static inline UIColor *CollectionInfoBarBlueColor(void) {
+ return MDCPalette.bluePalette.accent200;
+}
-// Creates a UIColor from a 24-bit RGB color encoded as an integer.
-static inline UIColor *ColorFromRGB(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 inline UIColor *CollectionInfoBarRedColor(void) {
+ return MDCPalette.redPalette.tint500;
}
@interface ShadowedView : UIView
@@ -163,7 +160,7 @@ static inline UIColor *ColorFromRGB(uint32_t rgbValue) {
self.allowsTap = NO;
self.shouldApplyBackgroundViewShadow = NO;
self.textAlignment = NSTextAlignmentLeft;
- self.tintColor = ColorFromRGB(kCollectionInfoBarBlueColor);
+ self.tintColor = CollectionInfoBarBlueColor();
self.titleLabel.textColor = [UIColor whiteColor];
self.autoDismissAfterDuration = 1.0f;
self.backgroundView.alpha = 0.9f;
@@ -172,7 +169,7 @@ static inline UIColor *ColorFromRGB(uint32_t rgbValue) {
self.shouldApplyBackgroundViewShadow = YES;
self.textAlignment = NSTextAlignmentCenter;
self.tintColor = [UIColor whiteColor];
- self.titleLabel.textColor = ColorFromRGB(kCollectionInfoBarRedColor);
+ self.titleLabel.textColor = CollectionInfoBarRedColor();
self.autoDismissAfterDuration = 0.0f;
self.backgroundView.alpha = 1.0f;
self.isAccessibilityElement = YES;

[Collections] Use MDCPalettes for info bar colors (#2364)