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

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

Issue 2701923003: [Payment Request] Error message screen (Closed)
Patch Set: Addressed comments 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/shipping_option_selection_view_controller.h " 5 #import "ios/chrome/browser/payments/shipping_option_selection_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/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/payments/currency_formatter.h" 11 #include "components/payments/currency_formatter.h"
12 #include "components/strings/grit/components_strings.h" 12 #include "components/strings/grit/components_strings.h"
13 #import "ios/chrome/browser/payments/cells/payments_text_item.h" 13 #import "ios/chrome/browser/payments/cells/payments_text_item.h"
14 #include "ios/chrome/browser/payments/payment_request.h" 14 #include "ios/chrome/browser/payments/payment_request.h"
15 #import "ios/chrome/browser/payments/shipping_option_selection_view_controller_a ctions.h"
15 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" 16 #import "ios/chrome/browser/ui/autofill/cells/status_item.h"
16 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 17 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.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 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" 26 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h"
26 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 27 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
27 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
28 29
29 NSString* const kShippingOptionSelectionCollectionViewId = 30 NSString* const kShippingOptionSelectionCollectionViewID =
30 @"kShippingOptionSelectionCollectionViewId"; 31 @"kShippingOptionSelectionCollectionViewID";
31 32
32 namespace { 33 namespace {
33 34
34 const CGFloat kSeparatorEdgeInset = 14; 35 const CGFloat kSeparatorEdgeInset = 14;
35 36
36 typedef NS_ENUM(NSInteger, SectionIdentifier) { 37 typedef NS_ENUM(NSInteger, SectionIdentifier) {
37 SectionIdentifierShippingOption = kSectionIdentifierEnumZero, 38 SectionIdentifierShippingOption = kSectionIdentifierEnumZero,
38 }; 39 };
39 40
40 typedef NS_ENUM(NSInteger, ItemType) { 41 typedef NS_ENUM(NSInteger, ItemType) {
41 ItemTypeSpinner = kItemTypeEnumZero, 42 ItemTypeSpinner = kItemTypeEnumZero,
42 ItemTypeMessage, 43 ItemTypeMessage,
43 ItemTypeShippingOption, // This is a repeated item type. 44 ItemTypeShippingOption, // This is a repeated item type.
44 }; 45 };
45 46
46 } // namespace 47 } // namespace
47 48
48 @interface ShippingOptionSelectionViewController () { 49 @interface ShippingOptionSelectionViewController ()<
50 ShippingOptionSelectionViewControllerActions> {
49 base::WeakNSProtocol<id<ShippingOptionSelectionViewControllerDelegate>> 51 base::WeakNSProtocol<id<ShippingOptionSelectionViewControllerDelegate>>
50 _delegate; 52 _delegate;
51 53
52 // The PaymentRequest object owning an instance of web::PaymentRequest as 54 // The PaymentRequest object owning an instance of web::PaymentRequest as
53 // provided by the page invoking the Payment Request API. This is a weak 55 // provided by the page invoking the Payment Request API. This is a weak
54 // pointer and should outlive this class. 56 // pointer and should outlive this class.
55 PaymentRequest* _paymentRequest; 57 PaymentRequest* _paymentRequest;
56 58
57 // The currently selected item. May be nil. 59 // The currently selected item. May be nil.
58 CollectionViewTextItem* _selectedItem; 60 CollectionViewTextItem* _selectedItem;
59 } 61 }
60 62
61 // Called when the user presses the return button.
62 - (void)onReturn;
63
64 @end 63 @end
65 64
66 @implementation ShippingOptionSelectionViewController 65 @implementation ShippingOptionSelectionViewController
67 66
68 @synthesize isLoading = _isLoading; 67 @synthesize isLoading = _isLoading;
69 @synthesize errorMessage = _errorMessage; 68 @synthesize errorMessage = _errorMessage;
70 69
71 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { 70 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest {
72 DCHECK(paymentRequest); 71 DCHECK(paymentRequest);
73 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { 72 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) {
74 self.title = l10n_util::GetNSString( 73 self.title = l10n_util::GetNSString(
75 IDS_IOS_PAYMENT_REQUEST_SHIPPING_OPTION_SELECTION_TITLE); 74 IDS_IOS_PAYMENT_REQUEST_SHIPPING_OPTION_SELECTION_TITLE);
76 75
76 // Set up leading (return) button.
77 UIBarButtonItem* returnButton = 77 UIBarButtonItem* returnButton =
78 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] 78 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
79 target:nil 79 target:nil
80 action:@selector(onReturn)]; 80 action:@selector(onReturn)];
81 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK); 81 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK);
82 self.navigationItem.leftBarButtonItem = returnButton; 82 self.navigationItem.leftBarButtonItem = returnButton;
83 83
84 _paymentRequest = paymentRequest; 84 _paymentRequest = paymentRequest;
85 } 85 }
86 return self; 86 return self;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 [model addItem:item 150 [model addItem:item
151 toSectionWithIdentifier:SectionIdentifierShippingOption]; 151 toSectionWithIdentifier:SectionIdentifierShippingOption];
152 } 152 }
153 } 153 }
154 154
155 - (void)viewDidLoad { 155 - (void)viewDidLoad {
156 [super viewDidLoad]; 156 [super viewDidLoad];
157 self.collectionView.accessibilityIdentifier = 157 self.collectionView.accessibilityIdentifier =
158 kShippingOptionSelectionCollectionViewId; 158 kShippingOptionSelectionCollectionViewID;
159 159
160 // Customize collection view settings. 160 // Customize collection view settings.
161 self.styler.cellStyle = MDCCollectionViewCellStyleCard; 161 self.styler.cellStyle = MDCCollectionViewCellStyleCard;
162 self.styler.separatorInset = 162 self.styler.separatorInset =
163 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); 163 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset);
164 } 164 }
165 165
166 #pragma mark UICollectionViewDataSource 166 #pragma mark UICollectionViewDataSource
167 167
168 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView 168 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { 246 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath {
247 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 247 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
248 if (type == ItemTypeMessage) { 248 if (type == ItemTypeMessage) {
249 return YES; 249 return YES;
250 } else { 250 } else {
251 return NO; 251 return NO;
252 } 252 }
253 } 253 }
254 254
255 @end 255 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698