Skip to content

Commit

Permalink
[Mutliple components] Update components that use colors to use MDCPal…
Browse files Browse the repository at this point in the history
…ette. (#2129)

* Update components that use colors to use MDCPalette.

* Update podspec to make palettes available to Collection Cell
  • Loading branch information
codeman7 authored and willlarche committed Oct 9, 2017
1 parent f9cf78c commit a462a2a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 30 deletions.
1 change: 1 addition & 0 deletions MaterialComponents.podspec
Expand Up @@ -174,6 +174,7 @@ Pod::Spec.new do |s|
ss.dependency "MaterialComponents/CollectionLayoutAttributes"
ss.dependency "MaterialComponents/Ink"
ss.dependency "MaterialComponents/Typography"
ss.dependency "MaterialComponents/Palettes"
ss.dependency "MaterialComponents/private/Icons/ic_check"
ss.dependency "MaterialComponents/private/Icons/ic_check_circle"
ss.dependency "MaterialComponents/private/Icons/ic_chevron_right"
Expand Down
9 changes: 5 additions & 4 deletions components/ActivityIndicator/src/MDCActivityIndicator.m
Expand Up @@ -23,6 +23,7 @@
#import "private/MDCActivityIndicator+Private.h"
#import "private/MaterialActivityIndicatorStrings.h"
#import "private/MaterialActivityIndicatorStrings_table.h"
#import "MaterialPalettes.h"

static const NSInteger kMDCActivityIndicatorTotalDetentCount = 5;
static const NSTimeInterval kMDCActivityIndicatorAnimateOutDuration = 0.1f;
Expand Down Expand Up @@ -796,10 +797,10 @@ + (CGFloat)defaultHeight {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
s_defaultCycleColors =
@[ [[UIColor alloc] initWithRed:0.129f green:0.588f blue:0.953f alpha:1],
[[UIColor alloc] initWithRed:0.957f green:0.263f blue:0.212f alpha:1],
[[UIColor alloc] initWithRed:1.0f green:0.922f blue:0.231f alpha:1],
[[UIColor alloc] initWithRed:0.298f green:0.686f blue:0.314f alpha:1] ];
@[ MDCPalette.bluePalette.tint500,
MDCPalette.redPalette.tint500,
MDCPalette.yellowPalette.tint500,
MDCPalette.greenPalette.tint500 ];
});
return s_defaultCycleColors;
}
Expand Down
11 changes: 3 additions & 8 deletions components/CollectionCells/src/MDCCollectionViewCell.m
Expand Up @@ -24,6 +24,7 @@
#import "MaterialIcons+ic_radio_button_unchecked.h"
#import "MaterialIcons+ic_reorder.h"
#import "MaterialRTL.h"
#import "MaterialPalettes.h"

static CGFloat kEditingControlAppearanceOffset = 16.0f;

Expand All @@ -33,18 +34,12 @@
// Default editing icon colors.
// Color is 0x626262
static inline UIColor *MDCCollectionViewCellGreyColor(void) {
return [UIColor colorWithRed:(CGFloat)(98 / 255.0)
green:(CGFloat)(98 / 255.0)
blue:(CGFloat)(98 / 255.0)
alpha:1];
return MDCPalette.greyPalette.tint700;
}

// Color is 0xF44336
static inline UIColor *MDCCollectionViewCellRedColor(void) {
return [UIColor colorWithRed:(CGFloat)(244 / 255.0)
green:(CGFloat)(67 / 255.0)
blue:(CGFloat)(54 / 255.0)
alpha:1];
return MDCPalette.redPalette.tint500;
}

// File name of the bundle (without the '.bundle' extension) containing resources.
Expand Down
3 changes: 2 additions & 1 deletion components/Collections/examples/CollectionsInkExample.m
Expand Up @@ -15,6 +15,7 @@
*/

#import "CollectionsInkExample.h"
#import "MaterialPalettes.h"

static NSString *const kReusableIdentifierItem = @"itemCellIdentifier";

Expand Down Expand Up @@ -70,7 +71,7 @@ - (UIColor *)collectionView:(UICollectionView *)collectionView
inkColorAtIndexPath:(NSIndexPath *)indexPath {
// Update cell ink colors.
if (indexPath.item == 1) {
return [UIColor colorWithRed:0.012 green:0.663 blue:0.957 alpha:0.2];
return [MDCPalette.lightBluePalette.tint500 colorWithAlphaComponent:0.2f];
} else if (indexPath.item == 2) {
return [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2];
}
Expand Down
11 changes: 3 additions & 8 deletions components/Collections/src/private/MDCCollectionViewStyler.m
Expand Up @@ -18,6 +18,7 @@

#import "MaterialCollectionLayoutAttributes.h"
#import "MaterialCollections.h"
#import "MaterialPalettes.h"

#include <tgmath.h>

Expand Down Expand Up @@ -123,17 +124,11 @@ - (instancetype)initWithCollectionView:(UICollectionView *)collectionView {
_cellBackgroundColor = [UIColor whiteColor];
_cellStyle = MDCCollectionViewCellStyleDefault;
// Background color is 0xEEEEEE
_collectionView.backgroundColor = [UIColor colorWithRed:(CGFloat)(238 / 255.0)
green:(CGFloat)(238 / 255.0)
blue:(CGFloat)(238 / 255.0)
alpha:1];
_collectionView.backgroundColor = MDCPalette.greyPalette.tint200;
_inlaidIndexPathSet = [NSMutableSet set];

// Cell separator defaults.
_separatorColor = [UIColor colorWithRed:(CGFloat)(224 / 255.0)
green:(CGFloat)(224 / 255.0)
blue:(CGFloat)(224 / 255.0)
alpha:1];
_separatorColor = MDCPalette.greyPalette.tint300;
_separatorInset = UIEdgeInsetsZero;
_separatorLineHeight =
kCollectionViewCellSeparatorDefaultHeightInPixels / [[UIScreen mainScreen] scale];
Expand Down
Expand Up @@ -22,6 +22,7 @@
#import "FlexibleHeaderTopLayoutGuideSupplemental.h"

#import "MaterialFlexibleHeader.h"
#import "MaterialPalettes.h"

@implementation FlexibleHeaderTopLayoutGuideExample (CatalogByConvention)

Expand All @@ -46,8 +47,7 @@ - (UIStatusBarStyle)preferredStatusBarStyle {
}

- (void)setupScrollViewContent {
UIColor *color =
[UIColor colorWithRed:(97.0 / 255.0) green:(97.0 / 255.0) blue:(97.0 / 255.0) alpha:1.0];
UIColor *color = MDCPalette.greyPalette.tint700;
UIView *scrollViewContent =
[[UIView alloc] initWithFrame:CGRectMake(0,
0,
Expand Down
Expand Up @@ -23,6 +23,7 @@

#import "MaterialHeaderStackView.h"
#import "MaterialNavigationBar.h"
#import "MaterialPalettes.h"

@interface ExampleInstructionsViewHeaderStackViewTypicalUse : UIView

Expand Down Expand Up @@ -159,14 +160,14 @@ - (NSAttributedString *)instructionsString {
NSDictionary *instructionAttributes1 = @{
NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline],
NSForegroundColorAttributeName :
[UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f],
[MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f],
NSParagraphStyleAttributeName : style
};

NSDictionary *instructionAttributes2 = @{
NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline],
NSForegroundColorAttributeName :
[UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f],
[MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f],
NSParagraphStyleAttributeName : style
};

Expand Down Expand Up @@ -197,7 +198,7 @@ - (void)drawArrowWithFrame:(CGRect)frame {
[bezierPath closePath];
bezierPath.miterLimit = 4;

[[UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f] setFill];
[[MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f] setFill];
[bezierPath fill];
}

Expand Down
Expand Up @@ -22,6 +22,7 @@
#import "NavigationBarTypicalUseExampleSupplemental.h"

#import "MaterialNavigationBar.h"
#import "MaterialPalettes.h"

@interface ExampleInstructionsViewNavigationBarTypicalUseExample : UIView

Expand Down Expand Up @@ -117,14 +118,14 @@ - (NSAttributedString *)instructionsString {
NSDictionary *instructionAttributes1 = @{
NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline],
NSForegroundColorAttributeName :
[UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f],
[MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f],
NSParagraphStyleAttributeName : style
};

NSDictionary *instructionAttributes2 = @{
NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline],
NSForegroundColorAttributeName :
[UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f],
[MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f],
NSParagraphStyleAttributeName : style
};

Expand Down Expand Up @@ -155,7 +156,7 @@ - (void)drawArrowWithFrame:(CGRect)frame {
[bezierPath closePath];
bezierPath.miterLimit = 4;

[[UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f] setFill];
[[MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f] setFill];
[bezierPath fill];
}

Expand Down
Expand Up @@ -146,7 +146,7 @@ - (void)setupScrollingContent {

UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectZero];
infoLabel.translatesAutoresizingMaskIntoConstraints = NO;
infoLabel.textColor = [UIColor colorWithRed:0.459 green:0.459 blue:0.459 alpha:0.87f];
infoLabel.textColor = [MDCPalette.greyPalette.tint600 colorWithAlphaComponent:0.87f];
infoLabel.numberOfLines = 0;
infoLabel.text =
@"Tabs enable content organization at a high level, such as switching between views";
Expand Down

0 comments on commit a462a2a

Please sign in to comment.