| 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..376c7d222ff319046005f949d3556d3e49fa8e51 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,46 @@ 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)paymentRequestSelectorViewController:
|
| + (PaymentRequestSelectorViewController*)controller
|
| + didChangeToState:
|
| + (PaymentRequestSelectorState)state {
|
| + // Update the data source with the new state.
|
| + self.mediator.state = state;
|
| +
|
| + [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 createItems];
|
| +
|
| + [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 +151,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;
|
|
|