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

Side by Side Diff: ios/chrome/browser/ui/payments/credit_card_edit_coordinator.mm

Issue 2944083003: [Payment Request] Fixes modally presented editors (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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/payments/credit_card_edit_coordinator.h" 5 #import "ios/chrome/browser/ui/payments/credit_card_edit_coordinator.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return false; 62 return false;
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 @interface CreditCardEditCoordinator () 67 @interface CreditCardEditCoordinator ()
68 68
69 @property(nonatomic, strong) 69 @property(nonatomic, strong)
70 BillingAddressSelectionCoordinator* billingAddressSelectionCoordinator; 70 BillingAddressSelectionCoordinator* billingAddressSelectionCoordinator;
71 71
72 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; 72 @property(nonatomic, strong) UINavigationController* viewController;
73
74 @property(nonatomic, strong)
75 PaymentRequestEditViewController* editViewController;
73 76
74 @property(nonatomic, strong) CreditCardEditViewControllerMediator* mediator; 77 @property(nonatomic, strong) CreditCardEditViewControllerMediator* mediator;
75 78
76 @end 79 @end
77 80
78 @implementation CreditCardEditCoordinator 81 @implementation CreditCardEditCoordinator
79 82
80 @synthesize creditCard = _creditCard; 83 @synthesize creditCard = _creditCard;
81 @synthesize paymentRequest = _paymentRequest; 84 @synthesize paymentRequest = _paymentRequest;
82 @synthesize delegate = _delegate; 85 @synthesize delegate = _delegate;
83 @synthesize billingAddressSelectionCoordinator = 86 @synthesize billingAddressSelectionCoordinator =
84 _billingAddressSelectionCoordinator; 87 _billingAddressSelectionCoordinator;
85 @synthesize viewController = _viewController; 88 @synthesize viewController = _viewController;
89 @synthesize editViewController = _editViewController;
86 @synthesize mediator = _mediator; 90 @synthesize mediator = _mediator;
87 91
88 - (void)start { 92 - (void)start {
89 _viewController = [[PaymentRequestEditViewController alloc] init]; 93 _editViewController = [[PaymentRequestEditViewController alloc] init];
90 // TODO(crbug.com/602666): Title varies depending on the missing fields. 94 // TODO(crbug.com/602666): Title varies depending on the missing fields.
91 NSString* title = _creditCard 95 NSString* title = _creditCard
92 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CARD) 96 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CARD)
93 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD_LABEL); 97 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD_LABEL);
94 [_viewController setTitle:title]; 98 [_editViewController setTitle:title];
95 [_viewController setDelegate:self]; 99 [_editViewController setDelegate:self];
96 [_viewController setValidatorDelegate:self]; 100 [_editViewController setValidatorDelegate:self];
97 _mediator = [[CreditCardEditViewControllerMediator alloc] 101 _mediator = [[CreditCardEditViewControllerMediator alloc]
98 initWithPaymentRequest:_paymentRequest 102 initWithPaymentRequest:_paymentRequest
99 creditCard:_creditCard]; 103 creditCard:_creditCard];
100 [_mediator setConsumer:_viewController]; 104 [_mediator setConsumer:_editViewController];
101 [_viewController setDataSource:_mediator]; 105 [_editViewController setDataSource:_mediator];
102 [_viewController loadModel]; 106 [_editViewController loadModel];
103 107
104 [[self baseViewController] presentViewController:_viewController 108 self.viewController = [[UINavigationController alloc]
109 initWithRootViewController:self.editViewController];
110 [self.viewController setModalPresentationStyle:UIModalPresentationFormSheet];
111 [self.viewController
112 setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
113 [self.viewController setNavigationBarHidden:YES];
114
115 [[self baseViewController] presentViewController:self.viewController
105 animated:YES 116 animated:YES
106 completion:nil]; 117 completion:nil];
107 } 118 }
108 119
109 - (void)stop { 120 - (void)stop {
110 [[self.viewController presentingViewController] 121 [[self.viewController presentingViewController]
111 dismissViewControllerAnimated:YES 122 dismissViewControllerAnimated:YES
112 completion:nil]; 123 completion:nil];
113 [self.billingAddressSelectionCoordinator stop]; 124 [self.billingAddressSelectionCoordinator stop];
114 self.billingAddressSelectionCoordinator = nil; 125 self.billingAddressSelectionCoordinator = nil;
115 _viewController = nil; 126 self.editViewController = nil;
127 self.viewController = nil;
116 } 128 }
117 129
118 #pragma mark - PaymentRequestEditViewControllerValidator 130 #pragma mark - PaymentRequestEditViewControllerValidator
119 131
120 - (NSString*)paymentRequestEditViewController: 132 - (NSString*)paymentRequestEditViewController:
121 (PaymentRequestEditViewController*)controller 133 (PaymentRequestEditViewController*)controller
122 validateField:(EditorField*)field { 134 validateField:(EditorField*)field {
123 if (field.value.length) { 135 if (field.value.length) {
124 base::string16 errorMessage; 136 base::string16 errorMessage;
125 base::string16 valueString = base::SysNSStringToUTF16(field.value); 137 base::string16 valueString = base::SysNSStringToUTF16(field.value);
(...skipping 15 matching lines...) Expand all
141 } 153 }
142 154
143 #pragma mark - PaymentRequestEditViewControllerDelegate 155 #pragma mark - PaymentRequestEditViewControllerDelegate
144 156
145 - (void)paymentRequestEditViewController: 157 - (void)paymentRequestEditViewController:
146 (PaymentRequestEditViewController*)controller 158 (PaymentRequestEditViewController*)controller
147 didSelectField:(EditorField*)field { 159 didSelectField:(EditorField*)field {
148 if (field.autofillUIType == AutofillUITypeCreditCardBillingAddress) { 160 if (field.autofillUIType == AutofillUITypeCreditCardBillingAddress) {
149 self.billingAddressSelectionCoordinator = 161 self.billingAddressSelectionCoordinator =
150 [[BillingAddressSelectionCoordinator alloc] 162 [[BillingAddressSelectionCoordinator alloc]
151 initWithBaseViewController:self.viewController]; 163 initWithBaseViewController:self.editViewController];
152 [self.billingAddressSelectionCoordinator 164 [self.billingAddressSelectionCoordinator
153 setPaymentRequest:self.paymentRequest]; 165 setPaymentRequest:self.paymentRequest];
154 [self.billingAddressSelectionCoordinator 166 [self.billingAddressSelectionCoordinator
155 setSelectedBillingProfile:self.mediator.billingProfile]; 167 setSelectedBillingProfile:self.mediator.billingProfile];
156 [self.billingAddressSelectionCoordinator setDelegate:self]; 168 [self.billingAddressSelectionCoordinator setDelegate:self];
157 [self.billingAddressSelectionCoordinator start]; 169 [self.billingAddressSelectionCoordinator start];
158 } 170 }
159 } 171 }
160 172
161 - (void)paymentRequestEditViewController: 173 - (void)paymentRequestEditViewController:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 #pragma mark - BillingAddressSelectionCoordinatorDelegate 227 #pragma mark - BillingAddressSelectionCoordinatorDelegate
216 228
217 - (void)billingAddressSelectionCoordinator: 229 - (void)billingAddressSelectionCoordinator:
218 (BillingAddressSelectionCoordinator*)coordinator 230 (BillingAddressSelectionCoordinator*)coordinator
219 didSelectBillingAddress: 231 didSelectBillingAddress:
220 (autofill::AutofillProfile*)billingAddress { 232 (autofill::AutofillProfile*)billingAddress {
221 // Update view controller's data source with the selection and reload the view 233 // Update view controller's data source with the selection and reload the view
222 // controller. 234 // controller.
223 DCHECK(billingAddress); 235 DCHECK(billingAddress);
224 [self.mediator setBillingProfile:billingAddress]; 236 [self.mediator setBillingProfile:billingAddress];
225 [self.viewController loadModel]; 237 [self.editViewController loadModel];
226 [self.viewController.collectionView reloadData]; 238 [self.editViewController.collectionView reloadData];
227 239
228 [self.billingAddressSelectionCoordinator stop]; 240 [self.billingAddressSelectionCoordinator stop];
229 self.billingAddressSelectionCoordinator = nil; 241 self.billingAddressSelectionCoordinator = nil;
230 } 242 }
231 243
232 - (void)billingAddressSelectionCoordinatorDidReturn: 244 - (void)billingAddressSelectionCoordinatorDidReturn:
233 (BillingAddressSelectionCoordinator*)coordinator { 245 (BillingAddressSelectionCoordinator*)coordinator {
234 [self.billingAddressSelectionCoordinator stop]; 246 [self.billingAddressSelectionCoordinator stop];
235 self.billingAddressSelectionCoordinator = nil; 247 self.billingAddressSelectionCoordinator = nil;
236 } 248 }
237 249
238 @end 250 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698