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

Unified Diff: ios/chrome/browser/ui/payments/payment_method_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/payment_method_selection_coordinator.mm
diff --git a/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm b/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
index 26e681f739a1b2a4cc7fc5e15b9a34eac83be68b..c7c4f3359df4f59046fc42fcc5fb9fbc27a3f41e 100644
--- a/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
+++ b/ios/chrome/browser/ui/payments/payment_method_selection_coordinator.mm
@@ -29,6 +29,11 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
@property(nonatomic, strong) PaymentMethodSelectionMediator* mediator;
+// Initializes and starts the CreditCardEditCoordinator. Sets |creditCard| as
+// the credit card to be edited.
+- (void)startCreditCardEditCoordinatorWithCreditCard:
+ (autofill::CreditCard*)creditCard;
+
// Called when the user selects a payment method. 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
@@ -89,23 +94,41 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
- (void)paymentRequestSelectorViewControllerDidSelectAddItem:
(PaymentRequestSelectorViewController*)controller {
- self.creditCardEditCoordinator = [[CreditCardEditCoordinator alloc]
- initWithBaseViewController:self.viewController];
- self.creditCardEditCoordinator.paymentRequest = self.paymentRequest;
- self.creditCardEditCoordinator.delegate = self;
- [self.creditCardEditCoordinator start];
+ [self startCreditCardEditCoordinatorWithCreditCard:nil];
+}
+
+- (void)paymentRequestSelectorViewControllerDidToggleEditingMode {
+ [self.viewController loadModel];
+ [self.viewController.collectionView reloadData];
+}
+
+- (void)paymentRequestSelectorViewController:
+ (PaymentRequestSelectorViewController*)controller
+ didSelectItemAtIndexForEditing:(NSUInteger)index {
+ DCHECK(index < self.paymentRequest->credit_cards().size());
+ [self
+ startCreditCardEditCoordinatorWithCreditCard:self.paymentRequest
+ ->credit_cards()[index]];
}
#pragma mark - CreditCardEditCoordinatorDelegate
- (void)creditCardEditCoordinator:(CreditCardEditCoordinator*)coordinator
didFinishEditingCreditCard:(autofill::CreditCard*)creditCard {
+ // Update the data source with the new data.
+ [self.mediator loadItems];
+
+ [self.viewController loadModel];
+ [self.viewController.collectionView reloadData];
+
[self.creditCardEditCoordinator stop];
self.creditCardEditCoordinator = nil;
- // Inform |self.delegate| that this card has been selected.
- [self.delegate paymentMethodSelectionCoordinator:self
- didSelectPaymentMethod:creditCard];
+ if (self.mediator.state != PaymentRequestSelectorStateEdit) {
+ // Inform |self.delegate| that this card has been selected.
+ [self.delegate paymentMethodSelectionCoordinator:self
+ didSelectPaymentMethod:creditCard];
+ }
}
- (void)creditCardEditCoordinatorDidCancel:
@@ -116,6 +139,16 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
#pragma mark - Helper methods
+- (void)startCreditCardEditCoordinatorWithCreditCard:
+ (autofill::CreditCard*)creditCard {
+ self.creditCardEditCoordinator = [[CreditCardEditCoordinator alloc]
+ initWithBaseViewController:self.viewController];
+ self.creditCardEditCoordinator.paymentRequest = self.paymentRequest;
+ self.creditCardEditCoordinator.creditCard = creditCard;
+ self.creditCardEditCoordinator.delegate = self;
+ [self.creditCardEditCoordinator start];
+}
+
- (void)delayedNotifyDelegateOfSelection:(autofill::CreditCard*)paymentMethod {
self.viewController.view.userInteractionEnabled = NO;
__weak PaymentMethodSelectionCoordinator* weakSelf = self;

Powered by Google App Engine
This is Rietveld 408576698