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

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: Initial 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
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..c82e713d758636b35945264942201ef767fb0adb 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"
@@ -97,6 +98,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 +262,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 +311,9 @@ const CGFloat kHorizontalImageFixedSize = 40;
[model addItem:profileItem3
toSectionWithIdentifier:SectionIdentifierPayments];
+ [model addItem:[self acceptedPaymentMethodsItem]
+ toSectionWithIdentifier:SectionIdentifierPayments];
+
// Account cells.
[model addSectionWithIdentifier:SectionIdentifierAccountCell];
[model addItem:[self accountItemDetailWithError]
@@ -557,6 +565,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];

Powered by Google App Engine
This is Rietveld 408576698