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/shipping_address_selection_view_controller.
h" | 5 #import "ios/chrome/browser/payments/shipping_address_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/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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 23 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
24 #include "ios/chrome/browser/ui/uikit_ui_util.h" | 24 #include "ios/chrome/browser/ui/uikit_ui_util.h" |
25 #include "ios/chrome/grit/ios_strings.h" | 25 #include "ios/chrome/grit/ios_strings.h" |
26 #include "ios/chrome/grit/ios_theme_resources.h" | 26 #include "ios/chrome/grit/ios_theme_resources.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 | 28 |
29 using payment_request_util::NameLabelFromAutofillProfile; | 29 using payment_request_util::NameLabelFromAutofillProfile; |
30 using payment_request_util::AddressLabelFromAutofillProfile; | 30 using payment_request_util::AddressLabelFromAutofillProfile; |
31 using payment_request_util::PhoneNumberLabelFromAutofillProfile; | 31 using payment_request_util::PhoneNumberLabelFromAutofillProfile; |
32 | 32 |
33 NSString* const kShippingAddressSelectionCollectionViewId = | 33 NSString* const kShippingAddressSelectionCollectionViewID = |
34 @"kShippingAddressSelectionCollectionViewId"; | 34 @"kShippingAddressSelectionCollectionViewID"; |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 const CGFloat kSeparatorEdgeInset = 14; | 38 const CGFloat kSeparatorEdgeInset = 14; |
39 | 39 |
40 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 40 typedef NS_ENUM(NSInteger, SectionIdentifier) { |
41 SectionIdentifierShippingAddress = kSectionIdentifierEnumZero, | 41 SectionIdentifierShippingAddress = kSectionIdentifierEnumZero, |
42 }; | 42 }; |
43 | 43 |
44 typedef NS_ENUM(NSInteger, ItemType) { | 44 typedef NS_ENUM(NSInteger, ItemType) { |
(...skipping 27 matching lines...) Expand all Loading... |
72 | 72 |
73 @synthesize isLoading = _isLoading; | 73 @synthesize isLoading = _isLoading; |
74 @synthesize errorMessage = _errorMessage; | 74 @synthesize errorMessage = _errorMessage; |
75 | 75 |
76 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { | 76 - (instancetype)initWithPaymentRequest:(PaymentRequest*)paymentRequest { |
77 DCHECK(paymentRequest); | 77 DCHECK(paymentRequest); |
78 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 78 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { |
79 self.title = l10n_util::GetNSString( | 79 self.title = l10n_util::GetNSString( |
80 IDS_IOS_PAYMENT_REQUEST_SHIPPING_ADDRESS_SELECTION_TITLE); | 80 IDS_IOS_PAYMENT_REQUEST_SHIPPING_ADDRESS_SELECTION_TITLE); |
81 | 81 |
| 82 // Set up leading (return) button. |
82 UIBarButtonItem* returnButton = | 83 UIBarButtonItem* returnButton = |
83 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] | 84 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] |
84 target:nil | 85 target:nil |
85 action:@selector(onReturn)]; | 86 action:@selector(onReturn)]; |
86 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK); | 87 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK); |
87 self.navigationItem.leftBarButtonItem = returnButton; | 88 self.navigationItem.leftBarButtonItem = returnButton; |
88 | 89 |
89 _paymentRequest = paymentRequest; | 90 _paymentRequest = paymentRequest; |
90 } | 91 } |
91 return self; | 92 return self; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 IDS_IOS_PAYMENT_REQUEST_SHIPPING_ADDRESS_SELECTION_ADD_BUTTON); | 157 IDS_IOS_PAYMENT_REQUEST_SHIPPING_ADDRESS_SELECTION_ADD_BUTTON); |
157 addShippingAddress.image = NativeImage(IDR_IOS_PAYMENTS_ADD); | 158 addShippingAddress.image = NativeImage(IDR_IOS_PAYMENTS_ADD); |
158 addShippingAddress.accessibilityTraits |= UIAccessibilityTraitButton; | 159 addShippingAddress.accessibilityTraits |= UIAccessibilityTraitButton; |
159 [model addItem:addShippingAddress | 160 [model addItem:addShippingAddress |
160 toSectionWithIdentifier:SectionIdentifierShippingAddress]; | 161 toSectionWithIdentifier:SectionIdentifierShippingAddress]; |
161 } | 162 } |
162 | 163 |
163 - (void)viewDidLoad { | 164 - (void)viewDidLoad { |
164 [super viewDidLoad]; | 165 [super viewDidLoad]; |
165 self.collectionView.accessibilityIdentifier = | 166 self.collectionView.accessibilityIdentifier = |
166 kShippingAddressSelectionCollectionViewId; | 167 kShippingAddressSelectionCollectionViewID; |
167 | 168 |
168 // Customize collection view settings. | 169 // Customize collection view settings. |
169 self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 170 self.styler.cellStyle = MDCCollectionViewCellStyleCard; |
170 self.styler.separatorInset = | 171 self.styler.separatorInset = |
171 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); | 172 UIEdgeInsetsMake(0, kSeparatorEdgeInset, 0, kSeparatorEdgeInset); |
172 } | 173 } |
173 | 174 |
174 #pragma mark UICollectionViewDataSource | 175 #pragma mark UICollectionViewDataSource |
175 | 176 |
176 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView | 177 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { | 264 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { |
264 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 265 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
265 if (type == ItemTypeMessage) { | 266 if (type == ItemTypeMessage) { |
266 return YES; | 267 return YES; |
267 } else { | 268 } else { |
268 return NO; | 269 return NO; |
269 } | 270 } |
270 } | 271 } |
271 | 272 |
272 @end | 273 @end |
OLD | NEW |