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

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

Issue 2938673003: [Payment Request] Selector view edit mode (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/billing_address_selection_mediator.h » ('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 c43db50edf67807803092c69b967a1ebd7b976e0..ca2f6e1ce9142b0e597d4d94644de220b16a89df 100644
--- a/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/billing_address_selection_coordinator.mm
@@ -29,6 +29,11 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
@property(nonatomic, strong) BillingAddressSelectionMediator* mediator;
+// Initializes and starts the AddressEditCoordinator. Sets |address| as the
+// address to be edited.
+- (void)startAddressEditCoordinatorWithAddress:
+ (autofill::AutofillProfile*)address;
+
// Called when the user selects a billing address. The cell is checked, the
// UI is locked so that the user can't interact with it, then the delegate is
// notified. The delay is here to let the user get a visual feedback of the
@@ -93,23 +98,41 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
- (void)paymentRequestSelectorViewControllerDidSelectAddItem:
(PaymentRequestSelectorViewController*)controller {
- self.addressEditCoordinator = [[AddressEditCoordinator alloc]
- initWithBaseViewController:self.viewController];
- self.addressEditCoordinator.paymentRequest = self.paymentRequest;
- self.addressEditCoordinator.delegate = self;
- [self.addressEditCoordinator start];
+ [self startAddressEditCoordinatorWithAddress:nil];
+}
+
+- (void)paymentRequestSelectorViewControllerDidToggleEditingMode:
+ (PaymentRequestSelectorViewController*)controller {
+ [self.viewController loadModel];
+ [self.viewController.collectionView reloadData];
+}
+
+- (void)paymentRequestSelectorViewController:
+ (PaymentRequestSelectorViewController*)controller
+ didSelectItemAtIndexForEditing:(NSUInteger)index {
+ DCHECK(index < self.paymentRequest->billing_profiles().size());
+ [self startAddressEditCoordinatorWithAddress:self.paymentRequest
+ ->billing_profiles()[index]];
}
#pragma mark - AddressEditCoordinatorDelegate
- (void)addressEditCoordinator:(AddressEditCoordinator*)coordinator
didFinishEditingAddress:(autofill::AutofillProfile*)address {
+ // Update the data source with the new data.
+ [self.mediator loadItems];
+
+ [self.viewController loadModel];
+ [self.viewController.collectionView reloadData];
+
[self.addressEditCoordinator stop];
self.addressEditCoordinator = nil;
- // Inform |self.delegate| that |address| has been selected.
- [self.delegate billingAddressSelectionCoordinator:self
- didSelectBillingAddress:address];
+ if (self.mediator.state != PaymentRequestSelectorStateEdit) {
+ // Inform |self.delegate| that |address| has been selected.
+ [self.delegate billingAddressSelectionCoordinator:self
+ didSelectBillingAddress:address];
+ }
}
- (void)addressEditCoordinatorDidCancel:(AddressEditCoordinator*)coordinator {
@@ -119,6 +142,16 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
#pragma mark - Helper methods
+- (void)startAddressEditCoordinatorWithAddress:
+ (autofill::AutofillProfile*)address {
+ self.addressEditCoordinator = [[AddressEditCoordinator alloc]
+ initWithBaseViewController:self.viewController];
+ self.addressEditCoordinator.paymentRequest = self.paymentRequest;
+ self.addressEditCoordinator.address = address;
+ self.addressEditCoordinator.delegate = self;
+ [self.addressEditCoordinator start];
+}
+
- (void)delayedNotifyDelegateOfSelection:
(autofill::AutofillProfile*)billingAddress {
self.viewController.view.userInteractionEnabled = NO;
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/billing_address_selection_mediator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698