| 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/payments/payment_method_selection_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_method_selection_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "components/autofill/core/browser/autofill_data_util.h" | 9 #include "components/autofill/core/browser/autofill_data_util.h" |
| 10 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 @end | 62 @end |
| 63 | 63 |
| 64 @implementation PaymentMethodSelectionViewController | 64 @implementation PaymentMethodSelectionViewController |
| 65 @synthesize delegate = _delegate; | 65 @synthesize delegate = _delegate; |
| 66 | 66 |
| 67 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { | 67 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { |
| 68 DCHECK(paymentRequest); | 68 DCHECK(paymentRequest); |
| 69 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 69 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { |
| 70 [self setTitle:l10n_util::GetNSString( | 70 [self |
| 71 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)]; | 71 setTitle:l10n_util::GetNSString(IDS_PAYMENTS_METHOD_OF_PAYMENT_LABEL)]; |
| 72 | 72 |
| 73 // Set up leading (return) button. | 73 // Set up leading (return) button. |
| 74 UIBarButtonItem* returnButton = | 74 UIBarButtonItem* returnButton = |
| 75 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] | 75 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] |
| 76 target:nil | 76 target:nil |
| 77 action:@selector(onReturn)]; | 77 action:@selector(onReturn)]; |
| 78 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK); | 78 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK); |
| 79 [self navigationItem].leftBarButtonItem = returnButton; | 79 [self navigationItem].leftBarButtonItem = returnButton; |
| 80 | 80 |
| 81 _paymentRequest = paymentRequest; | 81 _paymentRequest = paymentRequest; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 112 if (_paymentRequest->selected_credit_card() == paymentMethod) { | 112 if (_paymentRequest->selected_credit_card() == paymentMethod) { |
| 113 paymentMethodItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; | 113 paymentMethodItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
| 114 _selectedItem = paymentMethodItem; | 114 _selectedItem = paymentMethodItem; |
| 115 } | 115 } |
| 116 [model addItem:paymentMethodItem | 116 [model addItem:paymentMethodItem |
| 117 toSectionWithIdentifier:SectionIdentifierPayment]; | 117 toSectionWithIdentifier:SectionIdentifierPayment]; |
| 118 } | 118 } |
| 119 | 119 |
| 120 PaymentsTextItem* addPaymentMethod = | 120 PaymentsTextItem* addPaymentMethod = |
| 121 [[PaymentsTextItem alloc] initWithType:ItemTypeAddMethod]; | 121 [[PaymentsTextItem alloc] initWithType:ItemTypeAddMethod]; |
| 122 addPaymentMethod.text = | 122 addPaymentMethod.text = l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD); |
| 123 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_ADD_METHOD_BUTTON); | |
| 124 addPaymentMethod.image = NativeImage(IDR_IOS_PAYMENTS_ADD); | 123 addPaymentMethod.image = NativeImage(IDR_IOS_PAYMENTS_ADD); |
| 125 addPaymentMethod.accessibilityTraits |= UIAccessibilityTraitButton; | 124 addPaymentMethod.accessibilityTraits |= UIAccessibilityTraitButton; |
| 126 [model addItem:addPaymentMethod | 125 [model addItem:addPaymentMethod |
| 127 toSectionWithIdentifier:SectionIdentifierPayment]; | 126 toSectionWithIdentifier:SectionIdentifierPayment]; |
| 128 } | 127 } |
| 129 | 128 |
| 130 - (void)viewDidLoad { | 129 - (void)viewDidLoad { |
| 131 [super viewDidLoad]; | 130 [super viewDidLoad]; |
| 132 self.collectionView.accessibilityIdentifier = | 131 self.collectionView.accessibilityIdentifier = |
| 133 kPaymentMethodSelectionCollectionViewID; | 132 kPaymentMethodSelectionCollectionViewID; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return [MDCCollectionViewCell | 189 return [MDCCollectionViewCell |
| 191 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) | 190 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) |
| 192 forItem:item]; | 191 forItem:item]; |
| 193 default: | 192 default: |
| 194 NOTREACHED(); | 193 NOTREACHED(); |
| 195 return MDCCellDefaultOneLineHeight; | 194 return MDCCellDefaultOneLineHeight; |
| 196 } | 195 } |
| 197 } | 196 } |
| 198 | 197 |
| 199 @end | 198 @end |
| OLD | NEW |