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

Unified Diff: ios/chrome/browser/ui/payments/shipping_address_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/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 01a8b22fab6b17a32ac0ce778676b29c3b6a5f06..e25258d5fecdd919c4be7631c379a7f6a52bb5cc 100644
--- a/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
@@ -105,7 +105,7 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
#pragma mark - PaymentRequestSelectorViewControllerDelegate
-- (void)paymentRequestSelectorViewController:
+- (BOOL)paymentRequestSelectorViewController:
(PaymentRequestSelectorViewController*)controller
didSelectItemAtIndex:(NSUInteger)index {
CollectionViewItem<PaymentsIsSelectable>* selectedItem =
@@ -121,8 +121,10 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Update the data source with the selection.
self.mediator.selectedItemIndex = index;
[self delayedNotifyDelegateOfSelection:shippingProfile];
+ return YES;
} else {
[self startAddressEditCoordinatorWithAddress:shippingProfile];
+ return NO;
}
}
@@ -158,13 +160,20 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Update the data source with the new data.
[self.mediator loadItems];
+ const std::vector<autofill::AutofillProfile*>& shippingProfiles =
+ self.paymentRequest->shipping_profiles();
+ const auto position =
+ std::find(shippingProfiles.begin(), shippingProfiles.end(), address);
+ DCHECK(position != shippingProfiles.end());
+
+ // Mark the edited item as complete meaning all required information has been
+ // filled out.
+ CollectionViewItem<PaymentsIsSelectable>* editedItem =
+ self.mediator.selectableItems[position - shippingProfiles.begin()];
+ editedItem.complete = YES;
+
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();
}
@@ -174,12 +183,6 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
[self.addressEditCoordinator stop];
self.addressEditCoordinator = nil;
- // Mark the item as complete meaning all required information has been
- // filled out.
- CollectionViewItem<PaymentsIsSelectable>* selectedItem =
- self.mediator.selectableItems[self.mediator.selectedItemIndex];
- selectedItem.complete = YES;
-
if (![self.viewController isEditing]) {
// Inform |self.delegate| that |address| has been selected.
[self.delegate shippingAddressSelectionCoordinator:self

Powered by Google App Engine
This is Rietveld 408576698