Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(928)

Unified Diff: ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.mm

Issue 2825143002: [Payment Request] Accepted credit card type icons in the credit card editor (Closed)
Patch Set: Addressed comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/payments/credit_card_edit_view_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.mm
diff --git a/ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.mm b/ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.mm
index df84898983330d55616d0885c6db7c5101782f37..a16a34a678682ec4e63cd3bebb9851aaa84baa2b 100644
--- a/ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.mm
@@ -10,6 +10,7 @@
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/grit/components_scaled_resources.h"
+#import "ios/chrome/browser/payments/cells/accepted_payment_methods_item.h"
#import "ios/chrome/browser/payments/cells/autofill_profile_item.h"
#import "ios/chrome/browser/payments/cells/payments_text_item.h"
#import "ios/chrome/browser/payments/cells/price_item.h"
@@ -56,6 +57,7 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionIdentifierNativeAppCell,
SectionIdentifierAutofill,
SectionIdentifierPayments,
+ SectionIdentifierPaymentsNoBackground,
SectionIdentifierAccountCell,
SectionIdentifierAccountControlCell,
SectionIdentifierFooters,
@@ -97,6 +99,9 @@ typedef NS_ENUM(NSInteger, ItemType) {
// Image fixed horizontal size.
const CGFloat kHorizontalImageFixedSize = 40;
+// Credit Card icon size.
+const CGFloat kCardTypeIconDimension = 25.0;
+
} // namespace
@implementation MaterialCellCatalogViewController
@@ -258,6 +263,7 @@ const CGFloat kHorizontalImageFixedSize = 40;
[model addSectionWithIdentifier:SectionIdentifierPayments];
[model addItem:[self paymentsItemWithWrappingTextandOptionalImage]
toSectionWithIdentifier:SectionIdentifierPayments];
+
PriceItem* priceItem1 =
[[PriceItem alloc] initWithType:ItemTypePaymentsSingleLine];
priceItem1.item = @"Total";
@@ -306,6 +312,11 @@ const CGFloat kHorizontalImageFixedSize = 40;
[model addItem:profileItem3
toSectionWithIdentifier:SectionIdentifierPayments];
+ // Payments cells with no background.
+ [model addSectionWithIdentifier:SectionIdentifierPaymentsNoBackground];
+ [model addItem:[self acceptedPaymentMethodsItem]
+ toSectionWithIdentifier:SectionIdentifierPaymentsNoBackground];
+
// Account cells.
[model addSectionWithIdentifier:SectionIdentifierAccountCell];
[model addItem:[self accountItemDetailWithError]
@@ -407,6 +418,7 @@ const CGFloat kHorizontalImageFixedSize = 40;
NSInteger sectionIdentifier =
[self.collectionViewModel sectionIdentifierForSection:indexPath.section];
switch (sectionIdentifier) {
+ case SectionIdentifierPaymentsNoBackground:
case SectionIdentifierFooters:
// Display the Learn More footer without any background image or
// shadowing.
@@ -557,6 +569,31 @@ const CGFloat kHorizontalImageFixedSize = 40;
return item;
}
+- (CollectionViewItem*)acceptedPaymentMethodsItem {
+ AcceptedPaymentMethodsItem* item = [[AcceptedPaymentMethodsItem alloc]
+ initWithType:ItemTypePaymentsDynamicHeight];
+ item.message = @"Cards accepted:";
+
+ NSMutableArray* cardTypeIcons = [NSMutableArray array];
+ const char* cardTypes[]{autofill::kVisaCard,
+ autofill::kMasterCard,
+ autofill::kAmericanExpressCard,
+ autofill::kJCBCard,
+ autofill::kDinersCard,
+ autofill::kDiscoverCard};
+ for (const std::string& cardType : cardTypes) {
+ autofill::data_util::PaymentRequestData data =
+ autofill::data_util::GetPaymentRequestData(cardType);
+ UIImage* cardTypeIcon =
+ ResizeImage(NativeImage(data.icon_resource_id),
+ CGSizeMake(kCardTypeIconDimension, kCardTypeIconDimension),
+ ProjectionMode::kAspectFillNoClipping);
+ [cardTypeIcons addObject:cardTypeIcon];
+ }
+ item.methodTypeIcons = cardTypeIcons;
+ return item;
+}
+
- (CollectionViewItem*)autofillItemWithMainAndTrailingText {
AutofillDataItem* item =
[[AutofillDataItem alloc] initWithType:ItemTypeAutofillDynamicHeight];
« no previous file with comments | « ios/chrome/browser/payments/credit_card_edit_view_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698