OLD | NEW |
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/ui/payments/payment_request_selector_view_controller
.h" | 5 #import "ios/chrome/browser/ui/payments/payment_request_selector_view_controller
.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.h" |
9 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" | 9 #import "ios/chrome/browser/ui/autofill/cells/status_item.h" |
10 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 10 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 CollectionViewItem* item = [model itemAtIndexPath:indexPath]; | 181 CollectionViewItem* item = [model itemAtIndexPath:indexPath]; |
182 switch (item.type) { | 182 switch (item.type) { |
183 case ItemTypeSelectableItem: { | 183 case ItemTypeSelectableItem: { |
184 // Update the currently selected cell, if any. | 184 // Update the currently selected cell, if any. |
185 if (self.dataSource.selectedItemIndex != NSUIntegerMax) { | 185 if (self.dataSource.selectedItemIndex != NSUIntegerMax) { |
186 CollectionViewItem<PaymentsHasAccessoryType>* oldSelectedItem = | 186 CollectionViewItem<PaymentsHasAccessoryType>* oldSelectedItem = |
187 reinterpret_cast<CollectionViewItem<PaymentsHasAccessoryType>*>( | 187 reinterpret_cast<CollectionViewItem<PaymentsHasAccessoryType>*>( |
188 [self.dataSource | 188 [self.dataSource |
189 selectableItemAtIndex:self.dataSource.selectedItemIndex]); | 189 selectableItemAtIndex:self.dataSource.selectedItemIndex]); |
190 oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone; | 190 oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone; |
191 [self reconfigureCellsForItems:@[ oldSelectedItem ] | 191 [self reconfigureCellsForItems:@[ oldSelectedItem ]]; |
192 inSectionWithIdentifier:SectionIdentifierItems]; | |
193 } | 192 } |
194 | 193 |
195 // Update the newly selected cell. | 194 // Update the newly selected cell. |
196 CollectionViewItem<PaymentsHasAccessoryType>* newSelectedItem = | 195 CollectionViewItem<PaymentsHasAccessoryType>* newSelectedItem = |
197 reinterpret_cast<CollectionViewItem<PaymentsHasAccessoryType>*>(item); | 196 reinterpret_cast<CollectionViewItem<PaymentsHasAccessoryType>*>(item); |
198 newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; | 197 newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
199 [self reconfigureCellsForItems:@[ newSelectedItem ] | 198 [self reconfigureCellsForItems:@[ newSelectedItem ]]; |
200 inSectionWithIdentifier:SectionIdentifierItems]; | |
201 | 199 |
202 // Notify the delegate of the selection. | 200 // Notify the delegate of the selection. |
203 NSUInteger index = | 201 NSUInteger index = |
204 [self.collectionViewModel indexInItemTypeForIndexPath:indexPath]; | 202 [self.collectionViewModel indexInItemTypeForIndexPath:indexPath]; |
205 DCHECK(index < [[self.dataSource selectableItems] count]); | 203 DCHECK(index < [[self.dataSource selectableItems] count]); |
206 [self.delegate paymentRequestSelectorViewController:self | 204 [self.delegate paymentRequestSelectorViewController:self |
207 didSelectItemAtIndex:index]; | 205 didSelectItemAtIndex:index]; |
208 break; | 206 break; |
209 } | 207 } |
210 case ItemTypeAddItem: { | 208 case ItemTypeAddItem: { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { | 240 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { |
243 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; | 241 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
244 if (type == ItemTypeHeader) { | 242 if (type == ItemTypeHeader) { |
245 return YES; | 243 return YES; |
246 } else { | 244 } else { |
247 return NO; | 245 return NO; |
248 } | 246 } |
249 } | 247 } |
250 | 248 |
251 @end | 249 @end |
OLD | NEW |