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

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

Issue 2701923003: [Payment Request] Error message screen (Closed)
Patch Set: rebase Created 3 years, 10 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_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"
11 #include "components/strings/grit/components_strings.h" 11 #include "components/strings/grit/components_strings.h"
12 #import "ios/chrome/browser/payments/cells/payment_method_item.h" 12 #import "ios/chrome/browser/payments/cells/payment_method_item.h"
13 #import "ios/chrome/browser/payments/cells/payments_text_item.h" 13 #import "ios/chrome/browser/payments/cells/payments_text_item.h"
14 #import "ios/chrome/browser/payments/payment_method_selection_view_controller_ac tions.h"
14 #include "ios/chrome/browser/payments/payment_request.h" 15 #include "ios/chrome/browser/payments/payment_request.h"
15 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 16 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
16 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h" 17 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item .h"
17 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 18 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
18 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 19 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
19 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 20 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
20 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 21 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
21 #import "ios/chrome/browser/ui/icons/chrome_icon.h" 22 #import "ios/chrome/browser/ui/icons/chrome_icon.h"
22 #include "ios/chrome/browser/ui/uikit_ui_util.h" 23 #include "ios/chrome/browser/ui/uikit_ui_util.h"
23 #include "ios/chrome/grit/ios_strings.h" 24 #include "ios/chrome/grit/ios_strings.h"
24 #include "ios/chrome/grit/ios_theme_resources.h" 25 #include "ios/chrome/grit/ios_theme_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
27 28
28 #if !defined(__has_feature) || !__has_feature(objc_arc) 29 #if !defined(__has_feature) || !__has_feature(objc_arc)
29 #error "This file requires ARC support." 30 #error "This file requires ARC support."
30 #endif 31 #endif
31 32
32 NSString* const kPaymentMethodSelectionCollectionViewId = 33 NSString* const kPaymentMethodSelectionCollectionViewID =
33 @"kPaymentMethodSelectionCollectionViewId"; 34 @"kPaymentMethodSelectionCollectionViewID";
34 35
35 namespace { 36 namespace {
36 37
37 const CGFloat kSeparatorEdgeInset = 14; 38 const CGFloat kSeparatorEdgeInset = 14;
38 39
39 typedef NS_ENUM(NSInteger, SectionIdentifier) { 40 typedef NS_ENUM(NSInteger, SectionIdentifier) {
40 SectionIdentifierPayment = kSectionIdentifierEnumZero, 41 SectionIdentifierPayment = kSectionIdentifierEnumZero,
41 }; 42 };
42 43
43 typedef NS_ENUM(NSInteger, ItemType) { 44 typedef NS_ENUM(NSInteger, ItemType) {
44 ItemTypePaymentMethod = kItemTypeEnumZero, // This is a repeated item type. 45 ItemTypePaymentMethod = kItemTypeEnumZero, // This is a repeated item type.
45 ItemTypeAddMethod, 46 ItemTypeAddMethod,
46 }; 47 };
47 48
48 } // namespace 49 } // namespace
49 50
50 @interface PaymentMethodSelectionViewController () { 51 @interface PaymentMethodSelectionViewController ()<
52 PaymentMethodSelectionViewControllerActions> {
51 // The PaymentRequest object owning an instance of web::PaymentRequest as 53 // The PaymentRequest object owning an instance of web::PaymentRequest as
52 // provided by the page invoking the Payment Request API. This is a weak 54 // provided by the page invoking the Payment Request API. This is a weak
53 // pointer and should outlive this class. 55 // pointer and should outlive this class.
54 PaymentRequest* _paymentRequest; 56 PaymentRequest* _paymentRequest;
55 57
56 // The currently selected item. May be nil. 58 // The currently selected item. May be nil.
57 __weak PaymentMethodItem* _selectedItem; 59 __weak PaymentMethodItem* _selectedItem;
58 } 60 }
59 61
60 // Called when the user presses the return button.
61 - (void)onReturn;
62
63 @end 62 @end
64 63
65 @implementation PaymentMethodSelectionViewController 64 @implementation PaymentMethodSelectionViewController
66 @synthesize delegate = _delegate; 65 @synthesize delegate = _delegate;
67 66
68 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { 67 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest {
69 DCHECK(paymentRequest); 68 DCHECK(paymentRequest);
70 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 69 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
71 [self setTitle:l10n_util::GetNSString( 70 [self setTitle:l10n_util::GetNSString(
72 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)]; 71 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)];
73 72
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;
82 } 82 }
83 return self; 83 return self;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_ADD_METHOD_BUTTON); 123 l10n_util::GetNSString(IDS_IOS_PAYMENT_REQUEST_ADD_METHOD_BUTTON);
124 addPaymentMethod.image = NativeImage(IDR_IOS_PAYMENTS_ADD); 124 addPaymentMethod.image = NativeImage(IDR_IOS_PAYMENTS_ADD);
125 addPaymentMethod.accessibilityTraits |= UIAccessibilityTraitButton; 125 addPaymentMethod.accessibilityTraits |= UIAccessibilityTraitButton;
126 [model addItem:addPaymentMethod 126 [model addItem:addPaymentMethod
127 toSectionWithIdentifier:SectionIdentifierPayment]; 127 toSectionWithIdentifier:SectionIdentifierPayment];
128 } 128 }
129 129
130 - (void)viewDidLoad { 130 - (void)viewDidLoad {
131 [super viewDidLoad]; 131 [super viewDidLoad];
132 self.collectionView.accessibilityIdentifier = 132 self.collectionView.accessibilityIdentifier =
133 kPaymentMethodSelectionCollectionViewId; 133 kPaymentMethodSelectionCollectionViewID;
134 134
135 // Customize collection view settings. 135 // Customize collection view settings.
136 self.styler.cellStyle = MDCCollectionViewCellStyleCard; 136 self.styler.cellStyle = MDCCollectionViewCellStyleCard;
137 self.styler.separatorInset = 137 self.styler.separatorInset =
138 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); 138 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset);
139 } 139 }
140 140
141 #pragma mark UICollectionViewDelegate 141 #pragma mark UICollectionViewDelegate
142 142
143 - (void)collectionView:(UICollectionView*)collectionView 143 - (void)collectionView:(UICollectionView*)collectionView
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return [MDCCollectionViewCell 190 return [MDCCollectionViewCell
191 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) 191 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds)
192 forItem:item]; 192 forItem:item];
193 default: 193 default:
194 NOTREACHED(); 194 NOTREACHED();
195 return MDCCellDefaultOneLineHeight; 195 return MDCCellDefaultOneLineHeight;
196 } 196 }
197 } 197 }
198 198
199 @end 199 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698