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

Unified Diff: ios/chrome/browser/ui/payments/contact_info_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
Index: ios/chrome/browser/ui/payments/contact_info_selection_coordinator.mm
diff --git a/ios/chrome/browser/ui/payments/contact_info_selection_coordinator.mm b/ios/chrome/browser/ui/payments/contact_info_selection_coordinator.mm
index 0c07deb67773911eb49eeeb2e023eb145c12cb4e..84890e63b1d312946a562014c6f1909d18106742 100644
--- a/ios/chrome/browser/ui/payments/contact_info_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/contact_info_selection_coordinator.mm
@@ -35,6 +35,11 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
@property(nonatomic, strong) ContactInfoSelectionMediator* mediator;
+// Initializes and starts the ContactInfoEditCoordinator. Sets |profile| as the
+// profile to be edited.
+- (void)startContactInfoEditCoordinatorWithProfile:
+ (autofill::AutofillProfile*)profile;
+
// Called when the user selects a contact profile. The cell is checked, the
// UI is locked so that the user can't interact with it, then the delegate is
// notified.
@@ -96,23 +101,41 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
- (void)paymentRequestSelectorViewControllerDidSelectAddItem:
(PaymentRequestSelectorViewController*)controller {
- self.contactInfoEditCoordinator = [[ContactInfoEditCoordinator alloc]
- initWithBaseViewController:self.viewController];
- self.contactInfoEditCoordinator.paymentRequest = self.paymentRequest;
- self.contactInfoEditCoordinator.delegate = self;
- [self.contactInfoEditCoordinator start];
+ [self startContactInfoEditCoordinatorWithProfile:nil];
+}
+
+- (void)paymentRequestSelectorViewControllerDidToggleEditingMode:
+ (PaymentRequestSelectorViewController*)controller {
+ [self.viewController loadModel];
+ [self.viewController.collectionView reloadData];
+}
+
+- (void)paymentRequestSelectorViewController:
+ (PaymentRequestSelectorViewController*)controller
+ didSelectItemAtIndexForEditing:(NSUInteger)index {
+ DCHECK(index < self.paymentRequest->contact_profiles().size());
+ [self startContactInfoEditCoordinatorWithProfile:
+ self.paymentRequest->contact_profiles()[index]];
}
#pragma mark - ContactInfoEditCoordinatorDelegate
- (void)contactInfoEditCoordinator:(ContactInfoEditCoordinator*)coordinator
didFinishEditingProfile:(autofill::AutofillProfile*)profile {
+ // Update the data source with the new data.
+ [self.mediator loadItems];
+
+ [self.viewController loadModel];
+ [self.viewController.collectionView reloadData];
+
[self.contactInfoEditCoordinator stop];
self.contactInfoEditCoordinator = nil;
- // Inform |self.delegate| that |profile| has been selected.
- [self.delegate contactInfoSelectionCoordinator:self
- didSelectContactProfile:profile];
+ if (self.mediator.state != PaymentRequestSelectorStateEdit) {
+ // Inform |self.delegate| that |profile| has been selected.
+ [self.delegate contactInfoSelectionCoordinator:self
+ didSelectContactProfile:profile];
+ }
}
- (void)contactInfoEditCoordinatorDidCancel:
@@ -123,6 +146,16 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
#pragma mark - Helper methods
+- (void)startContactInfoEditCoordinatorWithProfile:
+ (autofill::AutofillProfile*)profile {
+ self.contactInfoEditCoordinator = [[ContactInfoEditCoordinator alloc]
+ initWithBaseViewController:self.viewController];
+ self.contactInfoEditCoordinator.paymentRequest = self.paymentRequest;
+ self.contactInfoEditCoordinator.profile = profile;
+ self.contactInfoEditCoordinator.delegate = self;
+ [self.contactInfoEditCoordinator start];
+}
+
- (void)delayedNotifyDelegateOfSelection:
(autofill::AutofillProfile*)contactProfile {
self.viewController.view.userInteractionEnabled = NO;

Powered by Google App Engine
This is Rietveld 408576698