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

Unified Diff: ios/chrome/browser/ui/payments/shipping_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 | « ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
diff --git a/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm b/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
index aab29f26bea234c38a73d86df9869c9090777c81..01a8b22fab6b17a32ac0ce778676b29c3b6a5f06 100644
--- a/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
@@ -4,6 +4,9 @@
#import "ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.h"
+#include <vector>
+
+#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/payments/core/strings_util.h"
@@ -105,10 +108,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());
@@ -117,7 +117,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:shippingProfile];
} else {
[self startAddressEditCoordinatorWithAddress:shippingProfile];
@@ -156,6 +158,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*>& shippingProfiles =
+ self.paymentRequest->shipping_profiles();
+ const auto position =
+ std::find(shippingProfiles.begin(), shippingProfiles.end(), address);
+ DCHECK(position != shippingProfiles.end());
+ self.mediator.selectedItemIndex = position - shippingProfiles.begin();
+ }
+
[self.viewController loadModel];
[self.viewController.collectionView reloadData];
@@ -164,9 +176,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 | « ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698