| 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_items_display_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_items_display_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 "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/autofill/core/browser/credit_card.h" | 10 #include "components/autofill/core/browser/credit_card.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 @end | 59 @end |
| 60 | 60 |
| 61 @implementation PaymentItemsDisplayViewController | 61 @implementation PaymentItemsDisplayViewController |
| 62 @synthesize delegate = _delegate; | 62 @synthesize delegate = _delegate; |
| 63 | 63 |
| 64 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest | 64 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest |
| 65 payButtonEnabled:(BOOL)payButtonEnabled { | 65 payButtonEnabled:(BOOL)payButtonEnabled { |
| 66 DCHECK(paymentRequest); | 66 DCHECK(paymentRequest); |
| 67 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 67 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { |
| 68 [self setTitle:l10n_util::GetNSString( | 68 [self setTitle:l10n_util::GetNSString(IDS_PAYMENTS_ORDER_SUMMARY_LABEL)]; |
| 69 IDS_IOS_PAYMENT_REQUEST_PAYMENT_ITEMS_TITLE)]; | |
| 70 | 69 |
| 71 // Set up leading (return) button. | 70 // Set up leading (return) button. |
| 72 UIBarButtonItem* returnButton = | 71 UIBarButtonItem* returnButton = |
| 73 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] | 72 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] |
| 74 target:nil | 73 target:nil |
| 75 action:@selector(onReturn)]; | 74 action:@selector(onReturn)]; |
| 76 [returnButton | 75 [returnButton |
| 77 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_BACK)]; | 76 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_BACK)]; |
| 78 [self navigationItem].leftBarButtonItem = returnButton; | 77 [self navigationItem].leftBarButtonItem = returnButton; |
| 79 | 78 |
| 80 // Set up trailing (pay) button. | 79 // Set up trailing (pay) button. |
| 81 _payButton = [[MDCFlatButton alloc] init]; | 80 _payButton = [[MDCFlatButton alloc] init]; |
| 82 [_payButton | 81 [_payButton setTitle:l10n_util::GetNSString(IDS_PAYMENTS_PAY_BUTTON) |
| 83 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) | 82 forState:UIControlStateNormal]; |
| 84 forState:UIControlStateNormal]; | |
| 85 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] | 83 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] |
| 86 forState:UIControlStateNormal]; | 84 forState:UIControlStateNormal]; |
| 87 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; | 85 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; |
| 88 [_payButton setBackgroundColor:[UIColor grayColor] | 86 [_payButton setBackgroundColor:[UIColor grayColor] |
| 89 forState:UIControlStateDisabled]; | 87 forState:UIControlStateDisabled]; |
| 90 [_payButton addTarget:nil | 88 [_payButton addTarget:nil |
| 91 action:@selector(onConfirm) | 89 action:@selector(onConfirm) |
| 92 forControlEvents:UIControlEventTouchUpInside]; | 90 forControlEvents:UIControlEventTouchUpInside]; |
| 93 [_payButton sizeToFit]; | 91 [_payButton sizeToFit]; |
| 94 [_payButton setEnabled:payButtonEnabled]; | 92 [_payButton setEnabled:payButtonEnabled]; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 137 |
| 140 // Add the total entry. | 138 // Add the total entry. |
| 141 PriceItem* totalItem = | 139 PriceItem* totalItem = |
| 142 [[PriceItem alloc] initWithType:ItemTypePaymentItemTotal]; | 140 [[PriceItem alloc] initWithType:ItemTypePaymentItemTotal]; |
| 143 totalItem.accessibilityIdentifier = kPaymentItemsDisplayItemID; | 141 totalItem.accessibilityIdentifier = kPaymentItemsDisplayItemID; |
| 144 totalItem.item = | 142 totalItem.item = |
| 145 base::SysUTF16ToNSString(_paymentRequest->payment_details().total.label); | 143 base::SysUTF16ToNSString(_paymentRequest->payment_details().total.label); |
| 146 payments::CurrencyFormatter* currencyFormatter = | 144 payments::CurrencyFormatter* currencyFormatter = |
| 147 _paymentRequest->GetOrCreateCurrencyFormatter(); | 145 _paymentRequest->GetOrCreateCurrencyFormatter(); |
| 148 totalItem.price = SysUTF16ToNSString(l10n_util::GetStringFUTF16( | 146 totalItem.price = SysUTF16ToNSString(l10n_util::GetStringFUTF16( |
| 149 IDS_IOS_PAYMENT_REQUEST_PAYMENT_ITEMS_TOTAL_FORMAT, | 147 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, |
| 150 base::UTF8ToUTF16(currencyFormatter->formatted_currency_code()), | 148 base::UTF8ToUTF16(currencyFormatter->formatted_currency_code()), |
| 151 currencyFormatter->Format(base::UTF16ToASCII( | 149 currencyFormatter->Format(base::UTF16ToASCII( |
| 152 _paymentRequest->payment_details().total.amount.value)))); | 150 _paymentRequest->payment_details().total.amount.value)))); |
| 153 | 151 |
| 154 [model addItem:totalItem toSectionWithIdentifier:SectionIdentifierPayment]; | 152 [model addItem:totalItem toSectionWithIdentifier:SectionIdentifierPayment]; |
| 155 | 153 |
| 156 // Add the line item entries. | 154 // Add the line item entries. |
| 157 for (const auto& paymentItem : | 155 for (const auto& paymentItem : |
| 158 _paymentRequest->payment_details().display_items) { | 156 _paymentRequest->payment_details().display_items) { |
| 159 PriceItem* paymentItemItem = | 157 PriceItem* paymentItemItem = |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 #pragma mark MDCCollectionViewStylingDelegate | 217 #pragma mark MDCCollectionViewStylingDelegate |
| 220 | 218 |
| 221 // There are no effects from touching the payment items so there should not be | 219 // There are no effects from touching the payment items so there should not be |
| 222 // an ink ripple. | 220 // an ink ripple. |
| 223 - (BOOL)collectionView:(UICollectionView*)collectionView | 221 - (BOOL)collectionView:(UICollectionView*)collectionView |
| 224 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { | 222 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { |
| 225 return YES; | 223 return YES; |
| 226 } | 224 } |
| 227 | 225 |
| 228 @end | 226 @end |
| OLD | NEW |