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_method_selection_view_controller.h" | 5 #import "ios/chrome/browser/payments/payment_method_selection_view_controller.h" |
6 | 6 |
7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "components/autofill/core/browser/autofill_data_util.h" | 10 #include "components/autofill/core/browser/autofill_data_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 - (instancetype)init { | 56 - (instancetype)init { |
57 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { | 57 if ((self = [super initWithStyle:CollectionViewControllerStyleAppBar])) { |
58 [self setTitle:l10n_util::GetNSString( | 58 [self setTitle:l10n_util::GetNSString( |
59 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)]; | 59 IDS_IOS_PAYMENT_REQUEST_METHOD_SELECTION_TITLE)]; |
60 | 60 |
61 UIBarButtonItem* returnButton = | 61 UIBarButtonItem* returnButton = |
62 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] | 62 [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon] |
63 target:nil | 63 target:nil |
64 action:@selector(onReturn)]; | 64 action:@selector(onReturn)]; |
| 65 returnButton.accessibilityLabel = l10n_util::GetNSString(IDS_ACCNAME_BACK); |
65 [self navigationItem].leftBarButtonItem = returnButton; | 66 [self navigationItem].leftBarButtonItem = returnButton; |
66 } | 67 } |
67 return self; | 68 return self; |
68 } | 69 } |
69 | 70 |
70 - (id<PaymentMethodSelectionViewControllerDelegate>)delegate { | 71 - (id<PaymentMethodSelectionViewControllerDelegate>)delegate { |
71 return _delegate.get(); | 72 return _delegate.get(); |
72 } | 73 } |
73 | 74 |
74 - (void)setDelegate:(id<PaymentMethodSelectionViewControllerDelegate>)delegate { | 75 - (void)setDelegate:(id<PaymentMethodSelectionViewControllerDelegate>)delegate { |
75 _delegate.reset(delegate); | 76 _delegate.reset(delegate); |
76 } | 77 } |
77 | 78 |
78 - (void)onReturn { | 79 - (void)onReturn { |
79 [_delegate paymentMethodSelectionViewControllerDidReturn:self]; | 80 [_delegate paymentMethodSelectionViewControllerDidReturn:self]; |
80 } | 81 } |
81 | 82 |
82 #pragma mark - CollectionViewController methods | 83 #pragma mark - CollectionViewController methods |
83 | 84 |
84 - (void)loadModel { | 85 - (void)loadModel { |
85 [super loadModel]; | 86 [super loadModel]; |
86 CollectionViewModel* model = self.collectionViewModel; | 87 CollectionViewModel* model = self.collectionViewModel; |
87 | 88 |
88 [model addSectionWithIdentifier:SectionIdentifierPayment]; | 89 [model addSectionWithIdentifier:SectionIdentifierPayment]; |
89 | 90 |
90 for (size_t i = 0; i < _paymentMethods.size(); ++i) { | 91 for (size_t i = 0; i < _paymentMethods.size(); ++i) { |
91 autofill::CreditCard* paymentMethod = _paymentMethods[i]; | 92 autofill::CreditCard* paymentMethod = _paymentMethods[i]; |
92 PaymentMethodItem* paymentMethodItem = [[[PaymentMethodItem alloc] | 93 PaymentMethodItem* paymentMethodItem = [[[PaymentMethodItem alloc] |
93 initWithType:ItemTypePaymentMethod] autorelease]; | 94 initWithType:ItemTypePaymentMethod] autorelease]; |
| 95 paymentMethodItem.accessibilityTraits |= UIAccessibilityTraitButton; |
94 paymentMethodItem.methodID = | 96 paymentMethodItem.methodID = |
95 base::SysUTF16ToNSString(paymentMethod->TypeAndLastFourDigits()); | 97 base::SysUTF16ToNSString(paymentMethod->TypeAndLastFourDigits()); |
96 paymentMethodItem.methodDetail = base::SysUTF16ToNSString( | 98 paymentMethodItem.methodDetail = base::SysUTF16ToNSString( |
97 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); | 99 paymentMethod->GetRawInfo(autofill::CREDIT_CARD_NAME_FULL)); |
98 | 100 |
99 int methodTypeIconID = | 101 int methodTypeIconID = |
100 autofill::data_util::GetPaymentRequestData(paymentMethod->type()) | 102 autofill::data_util::GetPaymentRequestData(paymentMethod->type()) |
101 .icon_resource_id; | 103 .icon_resource_id; |
102 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 104 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
103 paymentMethodItem.methodTypeIcon = | 105 paymentMethodItem.methodTypeIcon = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 - (CGFloat)collectionView:(UICollectionView*)collectionView | 154 - (CGFloat)collectionView:(UICollectionView*)collectionView |
153 cellHeightAtIndexPath:(NSIndexPath*)indexPath { | 155 cellHeightAtIndexPath:(NSIndexPath*)indexPath { |
154 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 156 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
155 if (type == ItemTypeAddMethod) | 157 if (type == ItemTypeAddMethod) |
156 return MDCCellDefaultOneLineHeight; | 158 return MDCCellDefaultOneLineHeight; |
157 else | 159 else |
158 return MDCCellDefaultTwoLineHeight; | 160 return MDCCellDefaultTwoLineHeight; |
159 } | 161 } |
160 | 162 |
161 @end | 163 @end |
OLD | NEW |