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

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

Issue 2958823002: [Payment Request] Incomplete item shouldn't appear as selected when tapped. (Closed)
Patch Set: Addressed comments 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
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
diff --git a/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm b/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
index 819ac9b9bb6d845b5d3822c47a53f476c1ff254a..271335e35e77cc2a2744f890acbb06bb7ff29fd9 100644
--- a/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/payments/billing_address_selection_coordinator.h"
+#include <vector>
+
#include "base/logging.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/strings/grit/components_strings.h"
@@ -84,10 +86,7 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
- (void)paymentRequestSelectorViewController:
(PaymentRequestSelectorViewController*)controller
didSelectItemAtIndex:(NSUInteger)index {
- // Update the data source with the selection.
- self.mediator.selectedItemIndex = index;
-
- CollectionViewItem<PaymentsIsSelectable>* paymentItem =
+ CollectionViewItem<PaymentsIsSelectable>* selectedItem =
self.mediator.selectableItems[index];
DCHECK(index < self.paymentRequest->billing_profiles().size());
@@ -96,7 +95,9 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Proceed with item selection only if the item has all required info, or
// else bring up the address editor.
- if (paymentItem.complete) {
+ if (selectedItem.complete) {
+ // Update the data source with the selection.
+ self.mediator.selectedItemIndex = index;
[self delayedNotifyDelegateOfSelection:billingProfile];
} else {
[self startAddressEditCoordinatorWithAddress:billingProfile];
@@ -134,6 +135,16 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Update the data source with the new data.
[self.mediator loadItems];
+ if (![self.viewController isEditing]) {
+ // Update the data source with the selection.
+ const std::vector<autofill::AutofillProfile*>& billingProfiles =
+ self.paymentRequest->billing_profiles();
+ const auto position =
+ std::find(billingProfiles.begin(), billingProfiles.end(), address);
+ DCHECK(position != billingProfiles.end());
+ self.mediator.selectedItemIndex = position - billingProfiles.begin();
+ }
+
[self.viewController loadModel];
[self.viewController.collectionView reloadData];
@@ -142,9 +153,9 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Mark the item as complete meaning all required information has been
// filled out.
- CollectionViewItem<PaymentsIsSelectable>* paymentItem =
+ CollectionViewItem<PaymentsIsSelectable>* selectedItem =
self.mediator.selectableItems[self.mediator.selectedItemIndex];
- paymentItem.complete = YES;
+ selectedItem.complete = YES;
if (![self.viewController isEditing]) {
// Inform |self.delegate| that |address| has been selected.
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698