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

Side by Side Diff: ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm

Issue 2958823002: [Payment Request] Incomplete item shouldn't appear as selected when tapped. (Closed)
Patch Set: Addressed comments Created 3 years, 5 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/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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 (paymentRequestSelectorViewController:didSelectItemAtIndexForEditing 254 (paymentRequestSelectorViewController:didSelectItemAtIndexForEditing
255 :)]) { 255 :)]) {
256 [self.delegate paymentRequestSelectorViewController:self 256 [self.delegate paymentRequestSelectorViewController:self
257 didSelectItemAtIndexForEditing:index]; 257 didSelectItemAtIndexForEditing:index];
258 } 258 }
259 return; 259 return;
260 } 260 }
261 261
262 switch (item.type) { 262 switch (item.type) {
263 case ItemTypeSelectableItem: { 263 case ItemTypeSelectableItem: {
264 // Update the currently selected cell, if any.
265 if (self.dataSource.selectedItemIndex != NSUIntegerMax) {
266 DCHECK(self.dataSource.selectedItemIndex <
267 [[self.dataSource selectableItems] count]);
268 CollectionViewItem<PaymentsIsSelectable>* oldSelectedItem =
269 [[self.dataSource selectableItems]
270 objectAtIndex:self.dataSource.selectedItemIndex];
271 oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone;
272 [self reconfigureCellsForItems:@[ oldSelectedItem ]];
273 }
274
275 // Update the newly selected cell.
276 CollectionViewItem<PaymentsIsSelectable>* newSelectedItem = 264 CollectionViewItem<PaymentsIsSelectable>* newSelectedItem =
277 reinterpret_cast<CollectionViewItem<PaymentsIsSelectable>*>(item); 265 reinterpret_cast<CollectionViewItem<PaymentsIsSelectable>*>(item);
278 newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; 266 // Update the currently selected and the newly selected cells only if the
279 [self reconfigureCellsForItems:@[ newSelectedItem ]]; 267 // newly selected cell corresponds to a complete item and can be selected.
280 268 if (newSelectedItem.isComplete) {
269 // Update the currently selected cell, if any.
270 if (self.dataSource.selectedItemIndex != NSUIntegerMax) {
271 DCHECK(self.dataSource.selectedItemIndex <
272 [[self.dataSource selectableItems] count]);
273 CollectionViewItem<PaymentsIsSelectable>* oldSelectedItem =
274 [[self.dataSource selectableItems]
275 objectAtIndex:self.dataSource.selectedItemIndex];
276 oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone;
277 [self reconfigureCellsForItems:@[ oldSelectedItem ]];
278 }
279 // Update the newly selected cell.
280 newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark;
281 [self reconfigureCellsForItems:@[ newSelectedItem ]];
282 }
281 // Notify the delegate of the selection. 283 // Notify the delegate of the selection.
282 NSUInteger index = 284 NSUInteger index =
283 [self.collectionViewModel indexInItemTypeForIndexPath:indexPath]; 285 [self.collectionViewModel indexInItemTypeForIndexPath:indexPath];
284 DCHECK(index < [[self.dataSource selectableItems] count]); 286 DCHECK(index < [[self.dataSource selectableItems] count]);
285 [self.delegate paymentRequestSelectorViewController:self 287 [self.delegate paymentRequestSelectorViewController:self
286 didSelectItemAtIndex:index]; 288 didSelectItemAtIndex:index];
287 break; 289 break;
288 } 290 }
289 case ItemTypeAddItem: { 291 case ItemTypeAddItem: {
290 if ([self.delegate 292 if ([self.delegate
(...skipping 30 matching lines...) Expand all
321 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath { 323 hidesInkViewAtIndexPath:(NSIndexPath*)indexPath {
322 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; 324 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
323 if (type == ItemTypeHeader) { 325 if (type == ItemTypeHeader) {
324 return YES; 326 return YES;
325 } else { 327 } else {
326 return NO; 328 return NO;
327 } 329 }
328 } 330 }
329 331
330 @end 332 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698