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

Unified Diff: ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm

Issue 2956323002: [Payment Request] Simplifies VC's logic to decide if an item is selectable (Closed)
Patch Set: Addressed comment Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
diff --git a/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm b/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
index 89f7e4aa8c61919866577228a83ced3c780800b7..84412481cba6bb27bc1a1bfa37cbde1c2d5f4165 100644
--- a/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
@@ -80,7 +80,7 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
#pragma mark - PaymentRequestSelectorViewControllerDelegate
-- (void)paymentRequestSelectorViewController:
+- (BOOL)paymentRequestSelectorViewController:
(PaymentRequestSelectorViewController*)controller
didSelectItemAtIndex:(NSUInteger)index {
DCHECK(index < self.paymentRequest->credit_cards().size());
@@ -94,8 +94,10 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Update the data source with the selection.
self.mediator.selectedItemIndex = index;
[self delayedNotifyDelegateOfSelection:creditCard];
+ return YES;
} else {
[self startCreditCardEditCoordinatorWithCreditCard:creditCard];
+ return NO;
}
}
@@ -131,13 +133,19 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Update the data source with the new data.
[self.mediator loadItems];
+ const std::vector<autofill::CreditCard*>& creditCards =
+ self.paymentRequest->credit_cards();
+ auto position = std::find(creditCards.begin(), creditCards.end(), creditCard);
+ DCHECK(position != creditCards.end());
+
+ // Mark the edited item as complete meaning all required information has been
+ // filled out.
+ CollectionViewItem<PaymentsIsSelectable>* editedItem =
+ self.mediator.selectableItems[position - creditCards.begin()];
+ editedItem.complete = YES;
+
if (![self.viewController isEditing]) {
// Update the data source with the selection.
- const std::vector<autofill::CreditCard*>& creditCards =
- self.paymentRequest->credit_cards();
- auto position =
- std::find(creditCards.begin(), creditCards.end(), creditCard);
- DCHECK(position != creditCards.end());
self.mediator.selectedItemIndex = position - creditCards.begin();
}

Powered by Google App Engine
This is Rietveld 408576698