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

Unified Diff: ios/chrome/browser/ui/payments/billing_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
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/billing_address_selection_coordinator_unittest.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 271335e35e77cc2a2744f890acbb06bb7ff29fd9..3335c867a7474e610cae1770849052154604dca2 100644
--- a/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
@@ -83,7 +83,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 =
@@ -99,8 +99,10 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
// Update the data source with the selection.
self.mediator.selectedItemIndex = index;
[self delayedNotifyDelegateOfSelection:billingProfile];
+ return YES;
} else {
[self startAddressEditCoordinatorWithAddress:billingProfile];
+ return NO;
}
}
@@ -135,13 +137,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*>& billingProfiles =
+ self.paymentRequest->billing_profiles();
+ const auto position =
+ std::find(billingProfiles.begin(), billingProfiles.end(), address);
+ DCHECK(position != billingProfiles.end());
+
+ // Mark the edited item as complete meaning all required information has been
+ // filled out.
+ CollectionViewItem<PaymentsIsSelectable>* editedItem =
+ self.mediator.selectableItems[position - billingProfiles.begin()];
+ editedItem.complete = YES;
+
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();
}
@@ -151,12 +160,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 billingAddressSelectionCoordinator:self
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/billing_address_selection_coordinator_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698