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

Side by Side Diff: ios/chrome/browser/payments/payment_items_display_view_controller.mm

Issue 2588913002: EarlGrey tests for Payment Request (base CL) (Closed)
Patch Set: Moved the experimental flag back to the BVC Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 #import "base/ios/weak_nsobject.h" 7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "components/autofill/core/browser/credit_card.h" 11 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/strings/grit/components_strings.h"
12 #import "ios/chrome/browser/payments/payment_request_utils.h" 13 #import "ios/chrome/browser/payments/payment_request_utils.h"
13 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
15 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
16 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 17 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
17 #import "ios/chrome/browser/ui/icons/chrome_icon.h" 18 #import "ios/chrome/browser/ui/icons/chrome_icon.h"
18 #include "ios/chrome/browser/ui/rtl_geometry.h" 19 #include "ios/chrome/browser/ui/rtl_geometry.h"
19 #include "ios/chrome/grit/ios_strings.h" 20 #include "ios/chrome/grit/ios_strings.h"
20 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h" 21 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate rialButtons.h"
21 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 22 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 24
24 NSString* const kPaymentItemsDisplayCollectionViewId = 25 NSString* const kPaymentItemsDisplayCollectionViewId =
25 @"kPaymentItemsDisplayCollectionViewId"; 26 @"kPaymentItemsDisplayCollectionViewId";
27 NSString* const kPaymentItemsDisplayItemId = @"kPaymentItemsDisplayItemId";
26 28
27 namespace { 29 namespace {
28 30
29 const CGFloat kButtonEdgeInset = 9; 31 const CGFloat kButtonEdgeInset = 9;
30 const CGFloat kSeparatorEdgeInset = 14; 32 const CGFloat kSeparatorEdgeInset = 14;
31 33
32 typedef NS_ENUM(NSInteger, SectionIdentifier) { 34 typedef NS_ENUM(NSInteger, SectionIdentifier) {
33 SectionIdentifierPayment = kSectionIdentifierEnumZero, 35 SectionIdentifierPayment = kSectionIdentifierEnumZero,
34 }; 36 };
35 37
(...skipping 25 matching lines...) Expand all
61 - (instancetype)initWithPayButtonEnabled:(BOOL)payButtonEnabled { 63 - (instancetype)initWithPayButtonEnabled:(BOOL)payButtonEnabled {
62 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 64 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
63 [self setTitle:l10n_util::GetNSString( 65 [self setTitle:l10n_util::GetNSString(
64 IDS_IOS_PAYMENT_REQUEST_PAYMENT_ITEMS_TITLE)]; 66 IDS_IOS_PAYMENT_REQUEST_PAYMENT_ITEMS_TITLE)];
65 67
66 // Set up left (return) button. 68 // Set up left (return) button.
67 UIBarButtonItem* returnButton = 69 UIBarButtonItem* returnButton =
68 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] 70 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
69 target:nil 71 target:nil
70 action:@selector(onReturn)]; 72 action:@selector(onReturn)];
73 [returnButton
74 setAccessibilityLabel:l10n_util::GetNSString(IDS_ACCNAME_BACK)];
71 [self navigationItem].leftBarButtonItem = returnButton; 75 [self navigationItem].leftBarButtonItem = returnButton;
72 76
73 // Set up right (pay) button. 77 // Set up right (pay) button.
74 _payButton.reset([[MDCFlatButton alloc] init]); 78 _payButton.reset([[MDCFlatButton alloc] init]);
75 [_payButton 79 [_payButton
76 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON) 80 setTitle:l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_PAY_BUTTON)
77 forState:UIControlStateNormal]; 81 forState:UIControlStateNormal];
78 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500] 82 [_payButton setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
79 forState:UIControlStateNormal]; 83 forState:UIControlStateNormal];
80 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]]; 84 [_payButton setInkColor:[UIColor colorWithWhite:1 alpha:0.2]];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 #pragma mark - CollectionViewController methods 137 #pragma mark - CollectionViewController methods
134 138
135 - (void)loadModel { 139 - (void)loadModel {
136 [super loadModel]; 140 [super loadModel];
137 CollectionViewModel* model = self.collectionViewModel; 141 CollectionViewModel* model = self.collectionViewModel;
138 [model addSectionWithIdentifier:SectionIdentifierPayment]; 142 [model addSectionWithIdentifier:SectionIdentifierPayment];
139 143
140 // Add the total entry. 144 // Add the total entry.
141 CollectionViewDetailItem* totalItem = [[[CollectionViewDetailItem alloc] 145 CollectionViewDetailItem* totalItem = [[[CollectionViewDetailItem alloc]
142 initWithType:ItemTypePaymentItemTotal] autorelease]; 146 initWithType:ItemTypePaymentItemTotal] autorelease];
147 totalItem.accessibilityIdentifier = kPaymentItemsDisplayItemId;
143 totalItem.text = base::SysUTF16ToNSString(_total.label); 148 totalItem.text = base::SysUTF16ToNSString(_total.label);
144 149
145 NSString* currencyCode = base::SysUTF16ToNSString(_total.amount.currency); 150 NSString* currencyCode = base::SysUTF16ToNSString(_total.amount.currency);
146 NSDecimalNumber* value = [NSDecimalNumber 151 NSDecimalNumber* value = [NSDecimalNumber
147 decimalNumberWithString:SysUTF16ToNSString(_total.amount.value)]; 152 decimalNumberWithString:SysUTF16ToNSString(_total.amount.value)];
148 totalItem.detailText = 153 totalItem.detailText =
149 payment_request_utils::FormattedCurrencyString(value, currencyCode); 154 payment_request_utils::FormattedCurrencyString(value, currencyCode);
150 155
151 [model addItem:totalItem toSectionWithIdentifier:SectionIdentifierPayment]; 156 [model addItem:totalItem toSectionWithIdentifier:SectionIdentifierPayment];
152 157
153 // Add the line item entries. 158 // Add the line item entries.
154 for (size_t i = 0; i < _paymentItems.size(); ++i) { 159 for (size_t i = 0; i < _paymentItems.size(); ++i) {
155 web::PaymentItem paymentItem = _paymentItems[i]; 160 web::PaymentItem paymentItem = _paymentItems[i];
156 CollectionViewDetailItem* paymentItemItem = 161 CollectionViewDetailItem* paymentItemItem =
157 [[[CollectionViewDetailItem alloc] initWithType:ItemTypePaymentItem] 162 [[[CollectionViewDetailItem alloc] initWithType:ItemTypePaymentItem]
158 autorelease]; 163 autorelease];
164 paymentItemItem.accessibilityIdentifier = kPaymentItemsDisplayItemId;
159 paymentItemItem.text = base::SysUTF16ToNSString(paymentItem.label); 165 paymentItemItem.text = base::SysUTF16ToNSString(paymentItem.label);
160 166
161 NSString* currencyCode = 167 NSString* currencyCode =
162 base::SysUTF16ToNSString(paymentItem.amount.currency); 168 base::SysUTF16ToNSString(paymentItem.amount.currency);
163 NSDecimalNumber* value = [NSDecimalNumber 169 NSDecimalNumber* value = [NSDecimalNumber
164 decimalNumberWithString:SysUTF16ToNSString(paymentItem.amount.value)]; 170 decimalNumberWithString:SysUTF16ToNSString(paymentItem.amount.value)];
165 paymentItemItem.detailText = 171 paymentItemItem.detailText =
166 payment_request_utils::FormattedCurrencyString(value, currencyCode); 172 payment_request_utils::FormattedCurrencyString(value, currencyCode);
167 [model addItem:paymentItemItem 173 [model addItem:paymentItemItem
168 toSectionWithIdentifier:SectionIdentifierPayment]; 174 toSectionWithIdentifier:SectionIdentifierPayment];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 #pragma mark MDCCollectionViewStylingDelegate 227 #pragma mark MDCCollectionViewStylingDelegate
222 228
223 // There are no effects from touching the payment items so there should not be 229 // There are no effects from touching the payment items so there should not be
224 // an ink ripple. 230 // an ink ripple.
225 - (BOOL)collectionView:(UICollectionView*)collectionView 231 - (BOOL)collectionView:(UICollectionView*)collectionView
226 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { 232 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath {
227 return YES; 233 return YES;
228 } 234 }
229 235
230 @end 236 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698