Commit 5e1332da authored by Mohamad Ahmadi's avatar Mohamad Ahmadi Committed by Commit Bot

[Payment Request] Makes cell section headers light grey

Bug:764473

before: https://drive.google.com/open?id=0B-GXJsF3pXyjUGVnaTFfTVBtamc
after: https://drive.google.com/open?id=0B-GXJsF3pXyjRzVBenpfYy1OZjg

Change-Id: I1df52d623da2b197f4385863fae4c16ddd16a240
Reviewed-on: https://chromium-review.googlesource.com/663839
Commit-Queue: Marc-Antoine Courteau <macourteau@chromium.org>
Reviewed-by: default avatarMarc-Antoine Courteau <macourteau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501628}
parent dbe1a962
...@@ -15,13 +15,21 @@ ...@@ -15,13 +15,21 @@
@interface PaymentsTextItem : CollectionViewItem<PaymentsIsSelectable> @interface PaymentsTextItem : CollectionViewItem<PaymentsIsSelectable>
// The main text to display. // The main text to display.
@property(nonatomic, copy) NSString* text; @property(nonatomic, nullable, copy) NSString* text;
// The secondary text to display. // The secondary text to display.
@property(nonatomic, copy) NSString* detailText; @property(nonatomic, nullable, copy) NSString* detailText;
// The color of the main text. Default is the 900 tint color of the grey
// palette.
@property(nonatomic, null_resettable, copy) UIColor* textColor;
// The color of the secondary text. Default is the 900 tint color of the grey
// palette.
@property(nonatomic, null_resettable, copy) UIColor* detailTextColor;
// The image to display. // The image to display.
@property(nonatomic, strong) UIImage* image; @property(nonatomic, nullable, strong) UIImage* image;
// The accessory type for the represented cell. // The accessory type for the represented cell.
@property(nonatomic) MDCCollectionViewCellAccessoryType accessoryType; @property(nonatomic) MDCCollectionViewCellAccessoryType accessoryType;
...@@ -38,13 +46,13 @@ ...@@ -38,13 +46,13 @@
@interface PaymentsTextCell : MDCCollectionViewCell @interface PaymentsTextCell : MDCCollectionViewCell
// UILabel corresponding to |text| from the item. // UILabel corresponding to |text| from the item.
@property(nonatomic, readonly, strong) UILabel* textLabel; @property(nonatomic, readonly, nullable, strong) UILabel* textLabel;
// UILabel corresponding to |detailText| from the item. // UILabel corresponding to |detailText| from the item.
@property(nonatomic, readonly, strong) UILabel* detailTextLabel; @property(nonatomic, readonly, nullable, strong) UILabel* detailTextLabel;
// UIImageView corresponding to |image| from the item. // UIImageView corresponding to |image| from the item.
@property(nonatomic, readonly, strong) UIImageView* imageView; @property(nonatomic, readonly, nullable, strong) UIImageView* imageView;
@end @end
......
...@@ -30,6 +30,8 @@ const CGFloat kVerticalSpacingBetweenLabels = 8; ...@@ -30,6 +30,8 @@ const CGFloat kVerticalSpacingBetweenLabels = 8;
@synthesize text = _text; @synthesize text = _text;
@synthesize detailText = _detailText; @synthesize detailText = _detailText;
@synthesize textColor = _textColor;
@synthesize detailTextColor = _detailTextColor;
@synthesize image = _image; @synthesize image = _image;
@synthesize accessoryType = _accessoryType; @synthesize accessoryType = _accessoryType;
@synthesize complete = _complete; @synthesize complete = _complete;
...@@ -44,11 +46,27 @@ const CGFloat kVerticalSpacingBetweenLabels = 8; ...@@ -44,11 +46,27 @@ const CGFloat kVerticalSpacingBetweenLabels = 8;
return self; return self;
} }
- (UIColor*)textColor {
if (!_textColor) {
_textColor = [[MDCPalette greyPalette] tint900];
}
return _textColor;
}
- (UIColor*)detailTextColor {
if (!_detailTextColor) {
_detailTextColor = [[MDCPalette greyPalette] tint900];
}
return _detailTextColor;
}
- (void)configureCell:(PaymentsTextCell*)cell { - (void)configureCell:(PaymentsTextCell*)cell {
[super configureCell:cell]; [super configureCell:cell];
cell.accessoryType = self.accessoryType; cell.accessoryType = self.accessoryType;
cell.textLabel.text = self.text; cell.textLabel.text = self.text;
cell.textLabel.textColor = self.textColor;
cell.detailTextLabel.text = self.detailText; cell.detailTextLabel.text = self.detailText;
cell.detailTextLabel.textColor = self.detailTextColor;
cell.imageView.image = self.image; cell.imageView.image = self.image;
} }
...@@ -107,12 +125,10 @@ const CGFloat kVerticalSpacingBetweenLabels = 8; ...@@ -107,12 +125,10 @@ const CGFloat kVerticalSpacingBetweenLabels = 8;
// Set default font and text colors for labels. // Set default font and text colors for labels.
- (void)setDefaultViewStyling { - (void)setDefaultViewStyling {
_textLabel.font = [MDCTypography body2Font]; _textLabel.font = [MDCTypography body2Font];
_textLabel.textColor = [[MDCPalette greyPalette] tint900];
_textLabel.numberOfLines = 0; _textLabel.numberOfLines = 0;
_textLabel.lineBreakMode = NSLineBreakByWordWrapping; _textLabel.lineBreakMode = NSLineBreakByWordWrapping;
_detailTextLabel.font = [MDCTypography body1Font]; _detailTextLabel.font = [MDCTypography body1Font];
_detailTextLabel.textColor = [[MDCPalette greyPalette] tint900];
_detailTextLabel.numberOfLines = 0; _detailTextLabel.numberOfLines = 0;
_detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping; _detailTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
} }
......
...@@ -126,7 +126,7 @@ using ::payment_request_util::GetShippingSectionTitle; ...@@ -126,7 +126,7 @@ using ::payment_request_util::GetShippingSectionTitle;
return item; return item;
} }
- (CollectionViewItem*)shippingSectionHeaderItem { - (PaymentsTextItem*)shippingSectionHeaderItem {
PaymentsTextItem* item = [[PaymentsTextItem alloc] init]; PaymentsTextItem* item = [[PaymentsTextItem alloc] init];
item.text = GetShippingSectionTitle(self.paymentRequest->shipping_type()); item.text = GetShippingSectionTitle(self.paymentRequest->shipping_type());
return item; return item;
...@@ -177,7 +177,7 @@ using ::payment_request_util::GetShippingSectionTitle; ...@@ -177,7 +177,7 @@ using ::payment_request_util::GetShippingSectionTitle;
return item; return item;
} }
- (CollectionViewItem*)paymentMethodSectionHeaderItem { - (PaymentsTextItem*)paymentMethodSectionHeaderItem {
if (!self.paymentRequest->selected_payment_method()) if (!self.paymentRequest->selected_payment_method())
return nil; return nil;
PaymentsTextItem* item = [[PaymentsTextItem alloc] init]; PaymentsTextItem* item = [[PaymentsTextItem alloc] init];
...@@ -221,7 +221,7 @@ using ::payment_request_util::GetShippingSectionTitle; ...@@ -221,7 +221,7 @@ using ::payment_request_util::GetShippingSectionTitle;
return item; return item;
} }
- (CollectionViewItem*)contactInfoSectionHeaderItem { - (PaymentsTextItem*)contactInfoSectionHeaderItem {
if (!self.paymentRequest->selected_contact_profile()) if (!self.paymentRequest->selected_contact_profile())
return nil; return nil;
PaymentsTextItem* item = [[PaymentsTextItem alloc] init]; PaymentsTextItem* item = [[PaymentsTextItem alloc] init];
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h" #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/payments/cells/page_info_item.h" #import "ios/chrome/browser/ui/payments/cells/page_info_item.h"
#import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
#import "ios/chrome/browser/ui/payments/cells/price_item.h" #import "ios/chrome/browser/ui/payments/cells/price_item.h"
#import "ios/chrome/browser/ui/payments/payment_request_view_controller_actions.h" #import "ios/chrome/browser/ui/payments/payment_request_view_controller_actions.h"
#include "ios/chrome/browser/ui/rtl_geometry.h" #include "ios/chrome/browser/ui/rtl_geometry.h"
...@@ -50,7 +51,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -50,7 +51,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeSummaryPageInfo = kItemTypeEnumZero, ItemTypeSummaryPageInfo = kItemTypeEnumZero,
ItemTypeSpinner, ItemTypeSpinner,
ItemTypeSummaryTotal, ItemTypeSummaryTotal,
ItemTypeShippingTitle, ItemTypeShippingHeader,
ItemTypeShippingAddress, ItemTypeShippingAddress,
ItemTypeShippingOption, ItemTypeShippingOption,
ItemTypePaymentHeader, ItemTypePaymentHeader,
...@@ -193,9 +194,10 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -193,9 +194,10 @@ typedef NS_ENUM(NSInteger, ItemType) {
if ([_dataSource requestShipping]) { if ([_dataSource requestShipping]) {
[model addSectionWithIdentifier:SectionIdentifierShipping]; [model addSectionWithIdentifier:SectionIdentifierShipping];
CollectionViewItem* shippingSectionHeaderItem = PaymentsTextItem* shippingSectionHeaderItem =
[_dataSource shippingSectionHeaderItem]; [_dataSource shippingSectionHeaderItem];
[shippingSectionHeaderItem setType:ItemTypeShippingTitle]; [shippingSectionHeaderItem setTextColor:[[MDCPalette greyPalette] tint500]];
[shippingSectionHeaderItem setType:ItemTypeShippingHeader];
[model setHeader:shippingSectionHeaderItem [model setHeader:shippingSectionHeaderItem
forSectionWithIdentifier:SectionIdentifierShipping]; forSectionWithIdentifier:SectionIdentifierShipping];
...@@ -459,10 +461,12 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -459,10 +461,12 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)populatePaymentMethodSection { - (void)populatePaymentMethodSection {
CollectionViewModel* model = self.collectionViewModel; CollectionViewModel* model = self.collectionViewModel;
CollectionViewItem* paymentMethodSectionHeaderItem = PaymentsTextItem* paymentMethodSectionHeaderItem =
[_dataSource paymentMethodSectionHeaderItem]; [_dataSource paymentMethodSectionHeaderItem];
if (paymentMethodSectionHeaderItem) { if (paymentMethodSectionHeaderItem) {
[paymentMethodSectionHeaderItem setType:ItemTypePaymentHeader]; [paymentMethodSectionHeaderItem setType:ItemTypePaymentHeader];
[paymentMethodSectionHeaderItem
setTextColor:[[MDCPalette greyPalette] tint500]];
[model setHeader:paymentMethodSectionHeaderItem [model setHeader:paymentMethodSectionHeaderItem
forSectionWithIdentifier:SectionIdentifierPayment]; forSectionWithIdentifier:SectionIdentifierPayment];
} }
...@@ -477,10 +481,12 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -477,10 +481,12 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)populateContactInfoSection { - (void)populateContactInfoSection {
CollectionViewModel* model = self.collectionViewModel; CollectionViewModel* model = self.collectionViewModel;
CollectionViewItem* contactInfoSectionHeaderItem = PaymentsTextItem* contactInfoSectionHeaderItem =
[_dataSource contactInfoSectionHeaderItem]; [_dataSource contactInfoSectionHeaderItem];
if (contactInfoSectionHeaderItem) { if (contactInfoSectionHeaderItem) {
[contactInfoSectionHeaderItem setType:ItemTypeContactInfoHeader]; [contactInfoSectionHeaderItem setType:ItemTypeContactInfoHeader];
[contactInfoSectionHeaderItem
setTextColor:[[MDCPalette greyPalette] tint500]];
[model setHeader:contactInfoSectionHeaderItem [model setHeader:contactInfoSectionHeaderItem
forSectionWithIdentifier:SectionIdentifierContactInfo]; forSectionWithIdentifier:SectionIdentifierContactInfo];
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
@class CollectionViewFooterItem; @class CollectionViewFooterItem;
@class CollectionViewItem; @class CollectionViewItem;
@class PaymentsTextItem;
// Data source protocol for PaymentRequestViewController. // Data source protocol for PaymentRequestViewController.
@protocol PaymentRequestViewControllerDataSource @protocol PaymentRequestViewControllerDataSource
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
- (CollectionViewItem*)paymentSummaryItem; - (CollectionViewItem*)paymentSummaryItem;
// Returns the header item for the Shipping section. // Returns the header item for the Shipping section.
- (CollectionViewItem*)shippingSectionHeaderItem; - (PaymentsTextItem*)shippingSectionHeaderItem;
// Returns the Shipping Address item displayed in the Shipping section. // Returns the Shipping Address item displayed in the Shipping section.
- (CollectionViewItem*)shippingAddressItem; - (CollectionViewItem*)shippingAddressItem;
...@@ -45,13 +46,13 @@ ...@@ -45,13 +46,13 @@
- (CollectionViewItem*)shippingOptionItem; - (CollectionViewItem*)shippingOptionItem;
// Returns the header item for the Payment Method section. // Returns the header item for the Payment Method section.
- (CollectionViewItem*)paymentMethodSectionHeaderItem; - (PaymentsTextItem*)paymentMethodSectionHeaderItem;
// Returns the item displayed in the Payment Method section. // Returns the item displayed in the Payment Method section.
- (CollectionViewItem*)paymentMethodItem; - (CollectionViewItem*)paymentMethodItem;
// Returns the header item for the Contact Info section. // Returns the header item for the Contact Info section.
- (CollectionViewItem*)contactInfoSectionHeaderItem; - (PaymentsTextItem*)contactInfoSectionHeaderItem;
// Returns the item displayed in the Contact Info section. // Returns the item displayed in the Contact Info section.
- (CollectionViewItem*)contactInfoItem; - (CollectionViewItem*)contactInfoItem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment