OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
10 #include "components/autofill/core/browser/autofill_data_util.h" | 10 #include "components/autofill/core/browser/autofill_data_util.h" |
11 #include "components/autofill/core/browser/credit_card.h" | 11 #include "components/autofill/core/browser/credit_card.h" |
12 #include "components/grit/components_scaled_resources.h" | 12 #include "components/grit/components_scaled_resources.h" |
| 13 #import "ios/chrome/browser/payments/cells/accepted_payment_methods_item.h" |
13 #import "ios/chrome/browser/payments/cells/autofill_profile_item.h" | 14 #import "ios/chrome/browser/payments/cells/autofill_profile_item.h" |
14 #import "ios/chrome/browser/payments/cells/payments_text_item.h" | 15 #import "ios/chrome/browser/payments/cells/payments_text_item.h" |
15 #import "ios/chrome/browser/payments/cells/price_item.h" | 16 #import "ios/chrome/browser/payments/cells/price_item.h" |
16 #import "ios/chrome/browser/ui/authentication/account_control_item.h" | 17 #import "ios/chrome/browser/ui/authentication/account_control_item.h" |
17 #import "ios/chrome/browser/ui/authentication/signin_promo_item.h" | 18 #import "ios/chrome/browser/ui/authentication/signin_promo_item.h" |
18 #import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h" | 19 #import "ios/chrome/browser/ui/authentication/signin_promo_view_configurator.h" |
19 #import "ios/chrome/browser/ui/authentication/signin_promo_view_mediator.h" | 20 #import "ios/chrome/browser/ui/authentication/signin_promo_view_mediator.h" |
20 #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" | 21 #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" |
21 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" | 22 #import "ios/chrome/browser/ui/autofill/cells/cvc_item.h" |
22 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" | 23 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 ItemTypeAutofillStatus, | 91 ItemTypeAutofillStatus, |
91 ItemTypeAutofillStorageSwitch, | 92 ItemTypeAutofillStorageSwitch, |
92 ItemTypeAccountControlDynamicHeight, | 93 ItemTypeAccountControlDynamicHeight, |
93 ItemTypeFooter, | 94 ItemTypeFooter, |
94 ItemTypeContentSuggestions, | 95 ItemTypeContentSuggestions, |
95 }; | 96 }; |
96 | 97 |
97 // Image fixed horizontal size. | 98 // Image fixed horizontal size. |
98 const CGFloat kHorizontalImageFixedSize = 40; | 99 const CGFloat kHorizontalImageFixedSize = 40; |
99 | 100 |
| 101 // Credit Card icon size. |
| 102 const CGFloat kCardTypeIconDimension = 25.0; |
| 103 |
100 } // namespace | 104 } // namespace |
101 | 105 |
102 @implementation MaterialCellCatalogViewController | 106 @implementation MaterialCellCatalogViewController |
103 | 107 |
104 - (instancetype)init { | 108 - (instancetype)init { |
105 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; | 109 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; |
106 if (self) { | 110 if (self) { |
107 [self loadModel]; | 111 [self loadModel]; |
108 } | 112 } |
109 return self; | 113 return self; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 toSectionWithIdentifier:SectionIdentifierAutofill]; | 255 toSectionWithIdentifier:SectionIdentifierAutofill]; |
252 [model addItem:[self statusItemError] | 256 [model addItem:[self statusItemError] |
253 toSectionWithIdentifier:SectionIdentifierAutofill]; | 257 toSectionWithIdentifier:SectionIdentifierAutofill]; |
254 [model addItem:[self storageSwitchItem] | 258 [model addItem:[self storageSwitchItem] |
255 toSectionWithIdentifier:SectionIdentifierAutofill]; | 259 toSectionWithIdentifier:SectionIdentifierAutofill]; |
256 | 260 |
257 // Payments cells. | 261 // Payments cells. |
258 [model addSectionWithIdentifier:SectionIdentifierPayments]; | 262 [model addSectionWithIdentifier:SectionIdentifierPayments]; |
259 [model addItem:[self paymentsItemWithWrappingTextandOptionalImage] | 263 [model addItem:[self paymentsItemWithWrappingTextandOptionalImage] |
260 toSectionWithIdentifier:SectionIdentifierPayments]; | 264 toSectionWithIdentifier:SectionIdentifierPayments]; |
| 265 |
261 PriceItem* priceItem1 = | 266 PriceItem* priceItem1 = |
262 [[PriceItem alloc] initWithType:ItemTypePaymentsSingleLine]; | 267 [[PriceItem alloc] initWithType:ItemTypePaymentsSingleLine]; |
263 priceItem1.item = @"Total"; | 268 priceItem1.item = @"Total"; |
264 priceItem1.notification = @"Updated"; | 269 priceItem1.notification = @"Updated"; |
265 priceItem1.price = @"USD $100.00"; | 270 priceItem1.price = @"USD $100.00"; |
266 [model addItem:priceItem1 toSectionWithIdentifier:SectionIdentifierPayments]; | 271 [model addItem:priceItem1 toSectionWithIdentifier:SectionIdentifierPayments]; |
267 PriceItem* priceItem2 = | 272 PriceItem* priceItem2 = |
268 [[PriceItem alloc] initWithType:ItemTypePaymentsSingleLine]; | 273 [[PriceItem alloc] initWithType:ItemTypePaymentsSingleLine]; |
269 priceItem2.item = @"Price label is long and should get clipped"; | 274 priceItem2.item = @"Price label is long and should get clipped"; |
270 priceItem2.notification = @"Updated"; | 275 priceItem2.notification = @"Updated"; |
(...skipping 28 matching lines...) Expand all Loading... |
299 profileItem2.notification = @"Some fields are missing"; | 304 profileItem2.notification = @"Some fields are missing"; |
300 [model addItem:profileItem2 | 305 [model addItem:profileItem2 |
301 toSectionWithIdentifier:SectionIdentifierPayments]; | 306 toSectionWithIdentifier:SectionIdentifierPayments]; |
302 AutofillProfileItem* profileItem3 = | 307 AutofillProfileItem* profileItem3 = |
303 [[AutofillProfileItem alloc] initWithType:ItemTypePaymentsDynamicHeight]; | 308 [[AutofillProfileItem alloc] initWithType:ItemTypePaymentsDynamicHeight]; |
304 profileItem3.address = @"All fields are optional"; | 309 profileItem3.address = @"All fields are optional"; |
305 profileItem3.email = @"foo@bar.com"; | 310 profileItem3.email = @"foo@bar.com"; |
306 [model addItem:profileItem3 | 311 [model addItem:profileItem3 |
307 toSectionWithIdentifier:SectionIdentifierPayments]; | 312 toSectionWithIdentifier:SectionIdentifierPayments]; |
308 | 313 |
| 314 [model addItem:[self acceptedPaymentMethodsItem] |
| 315 toSectionWithIdentifier:SectionIdentifierPayments]; |
| 316 |
309 // Account cells. | 317 // Account cells. |
310 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; | 318 [model addSectionWithIdentifier:SectionIdentifierAccountCell]; |
311 [model addItem:[self accountItemDetailWithError] | 319 [model addItem:[self accountItemDetailWithError] |
312 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 320 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
313 [model addItem:[self accountItemCheckMark] | 321 [model addItem:[self accountItemCheckMark] |
314 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 322 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
315 [model addItem:[self accountSignInItem] | 323 [model addItem:[self accountSignInItem] |
316 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 324 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
317 [model addItem:[self coldStateSigninPromoItem] | 325 [model addItem:[self coldStateSigninPromoItem] |
318 toSectionWithIdentifier:SectionIdentifierAccountCell]; | 326 toSectionWithIdentifier:SectionIdentifierAccountCell]; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 | 558 |
551 - (CollectionViewItem*)paymentsItemWithWrappingTextandOptionalImage { | 559 - (CollectionViewItem*)paymentsItemWithWrappingTextandOptionalImage { |
552 PaymentsTextItem* item = | 560 PaymentsTextItem* item = |
553 [[PaymentsTextItem alloc] initWithType:ItemTypePaymentsDynamicHeight]; | 561 [[PaymentsTextItem alloc] initWithType:ItemTypePaymentsDynamicHeight]; |
554 item.text = @"If you want to display a long text that wraps to the next line " | 562 item.text = @"If you want to display a long text that wraps to the next line " |
555 @"and may need to feature an image this is the cell to use."; | 563 @"and may need to feature an image this is the cell to use."; |
556 item.image = [UIImage imageNamed:@"app_icon_placeholder"]; | 564 item.image = [UIImage imageNamed:@"app_icon_placeholder"]; |
557 return item; | 565 return item; |
558 } | 566 } |
559 | 567 |
| 568 - (CollectionViewItem*)acceptedPaymentMethodsItem { |
| 569 AcceptedPaymentMethodsItem* item = [[AcceptedPaymentMethodsItem alloc] |
| 570 initWithType:ItemTypePaymentsDynamicHeight]; |
| 571 item.message = @"Cards accepted:"; |
| 572 |
| 573 NSMutableArray* cardTypeIcons = [NSMutableArray array]; |
| 574 const char* cardTypes[]{autofill::kVisaCard, |
| 575 autofill::kMasterCard, |
| 576 autofill::kAmericanExpressCard, |
| 577 autofill::kJCBCard, |
| 578 autofill::kDinersCard, |
| 579 autofill::kDiscoverCard}; |
| 580 for (const std::string& cardType : cardTypes) { |
| 581 autofill::data_util::PaymentRequestData data = |
| 582 autofill::data_util::GetPaymentRequestData(cardType); |
| 583 UIImage* cardTypeIcon = |
| 584 ResizeImage(NativeImage(data.icon_resource_id), |
| 585 CGSizeMake(kCardTypeIconDimension, kCardTypeIconDimension), |
| 586 ProjectionMode::kAspectFillNoClipping); |
| 587 [cardTypeIcons addObject:cardTypeIcon]; |
| 588 } |
| 589 item.methodTypeIcons = cardTypeIcons; |
| 590 return item; |
| 591 } |
| 592 |
560 - (CollectionViewItem*)autofillItemWithMainAndTrailingText { | 593 - (CollectionViewItem*)autofillItemWithMainAndTrailingText { |
561 AutofillDataItem* item = | 594 AutofillDataItem* item = |
562 [[AutofillDataItem alloc] initWithType:ItemTypeAutofillDynamicHeight]; | 595 [[AutofillDataItem alloc] initWithType:ItemTypeAutofillDynamicHeight]; |
563 item.text = @"Main Text"; | 596 item.text = @"Main Text"; |
564 item.trailingDetailText = @"Trailing Detail Text"; | 597 item.trailingDetailText = @"Trailing Detail Text"; |
565 item.accessoryType = MDCCollectionViewCellAccessoryNone; | 598 item.accessoryType = MDCCollectionViewCellAccessoryNone; |
566 return item; | 599 return item; |
567 } | 600 } |
568 | 601 |
569 - (CollectionViewItem*)autofillItemWithLeadingTextOnly { | 602 - (CollectionViewItem*)autofillItemWithLeadingTextOnly { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 - (ContentSuggestionsFooterItem*)contentSuggestionsFooterItem { | 736 - (ContentSuggestionsFooterItem*)contentSuggestionsFooterItem { |
704 ContentSuggestionsFooterItem* footerItem = | 737 ContentSuggestionsFooterItem* footerItem = |
705 [[ContentSuggestionsFooterItem alloc] | 738 [[ContentSuggestionsFooterItem alloc] |
706 initWithType:ItemTypeContentSuggestions | 739 initWithType:ItemTypeContentSuggestions |
707 title:@"Footer title" | 740 title:@"Footer title" |
708 block:nil]; | 741 block:nil]; |
709 return footerItem; | 742 return footerItem; |
710 } | 743 } |
711 | 744 |
712 @end | 745 @end |
OLD | NEW |