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

Side by Side Diff: ios/chrome/browser/ui/payments/address_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
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/address_edit_coordinator_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/address_edit_coordinator.h" 5 #import "ios/chrome/browser/ui/payments/address_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 "components/autofill/core/browser/autofill_country.h" 10 #include "components/autofill/core/browser/autofill_country.h"
(...skipping 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 using ::AutofillUITypeFromAutofillType; 29 using ::AutofillUITypeFromAutofillType;
30 using ::AutofillTypeFromAutofillUIType; 30 using ::AutofillTypeFromAutofillUIType;
31 } // namespace 31 } // namespace
32 32
33 @interface AddressEditCoordinator () 33 @interface AddressEditCoordinator ()
34 34
35 @property(nonatomic, strong) 35 @property(nonatomic, strong)
36 CountrySelectionCoordinator* countrySelectionCoordinator; 36 CountrySelectionCoordinator* countrySelectionCoordinator;
37 37
38 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; 38 @property(nonatomic, strong) UINavigationController* viewController;
39
40 @property(nonatomic, strong)
41 PaymentRequestEditViewController* editViewController;
39 42
40 @property(nonatomic, strong) AddressEditMediator* mediator; 43 @property(nonatomic, strong) AddressEditMediator* mediator;
41 44
42 @end 45 @end
43 46
44 @implementation AddressEditCoordinator 47 @implementation AddressEditCoordinator
45 48
46 @synthesize address = _address; 49 @synthesize address = _address;
47 @synthesize paymentRequest = _paymentRequest; 50 @synthesize paymentRequest = _paymentRequest;
48 @synthesize delegate = _delegate; 51 @synthesize delegate = _delegate;
49 @synthesize countrySelectionCoordinator = _countrySelectionCoordinator; 52 @synthesize countrySelectionCoordinator = _countrySelectionCoordinator;
50 @synthesize viewController = _viewController; 53 @synthesize viewController = _viewController;
54 @synthesize editViewController = _editViewController;
51 @synthesize mediator = _mediator; 55 @synthesize mediator = _mediator;
52 56
53 - (void)start { 57 - (void)start {
54 self.viewController = [[PaymentRequestEditViewController alloc] init]; 58 self.editViewController = [[PaymentRequestEditViewController alloc] init];
55 // TODO(crbug.com/602666): Title varies depending on what field is missing. 59 // TODO(crbug.com/602666): Title varies depending on what field is missing.
56 // e.g., Add Email vs. Add Phone Number. 60 // e.g., Add Email vs. Add Phone Number.
57 NSString* title = self.address 61 NSString* title = self.address
58 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_ADDRESS) 62 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_ADDRESS)
59 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_ADDRESS); 63 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_ADDRESS);
60 [self.viewController setTitle:title]; 64 [self.editViewController setTitle:title];
61 [self.viewController setDelegate:self]; 65 [self.editViewController setDelegate:self];
62 [self.viewController setValidatorDelegate:self]; 66 [self.editViewController setValidatorDelegate:self];
63 self.mediator = 67 self.mediator =
64 [[AddressEditMediator alloc] initWithPaymentRequest:self.paymentRequest 68 [[AddressEditMediator alloc] initWithPaymentRequest:self.paymentRequest
65 address:self.address]; 69 address:self.address];
66 [self.mediator setConsumer:self.viewController]; 70 [self.mediator setConsumer:self.editViewController];
67 [self.viewController setDataSource:self.mediator]; 71 [self.editViewController setDataSource:self.mediator];
68 [self.viewController loadModel]; 72 [self.editViewController loadModel];
73
74 self.viewController = [[UINavigationController alloc]
75 initWithRootViewController:self.editViewController];
76 [self.viewController setModalPresentationStyle:UIModalPresentationFormSheet];
77 [self.viewController
78 setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
79 [self.viewController setNavigationBarHidden:YES];
69 80
70 [[self baseViewController] presentViewController:self.viewController 81 [[self baseViewController] presentViewController:self.viewController
71 animated:YES 82 animated:YES
72 completion:nil]; 83 completion:nil];
73 } 84 }
74 85
75 - (void)stop { 86 - (void)stop {
76 [[self.viewController presentingViewController] 87 [[self.viewController presentingViewController]
77 dismissViewControllerAnimated:YES 88 dismissViewControllerAnimated:YES
78 completion:nil]; 89 completion:nil];
79 [self.countrySelectionCoordinator stop]; 90 [self.countrySelectionCoordinator stop];
80 self.countrySelectionCoordinator = nil; 91 self.countrySelectionCoordinator = nil;
92 self.editViewController = nil;
81 self.viewController = nil; 93 self.viewController = nil;
82 } 94 }
83 95
84 #pragma mark - PaymentRequestEditViewControllerValidator 96 #pragma mark - PaymentRequestEditViewControllerValidator
85 97
86 - (NSString*)paymentRequestEditViewController: 98 - (NSString*)paymentRequestEditViewController:
87 (PaymentRequestEditViewController*)controller 99 (PaymentRequestEditViewController*)controller
88 validateField:(EditorField*)field { 100 validateField:(EditorField*)field {
89 if (field.value.length) { 101 if (field.value.length) {
90 switch (field.autofillUIType) { 102 switch (field.autofillUIType) {
(...skipping 17 matching lines...) Expand all
108 return nil; 120 return nil;
109 } 121 }
110 122
111 #pragma mark - PaymentRequestEditViewControllerDelegate 123 #pragma mark - PaymentRequestEditViewControllerDelegate
112 124
113 - (void)paymentRequestEditViewController: 125 - (void)paymentRequestEditViewController:
114 (PaymentRequestEditViewController*)controller 126 (PaymentRequestEditViewController*)controller
115 didSelectField:(EditorField*)field { 127 didSelectField:(EditorField*)field {
116 if (field.autofillUIType == AutofillUITypeProfileHomeAddressCountry) { 128 if (field.autofillUIType == AutofillUITypeProfileHomeAddressCountry) {
117 self.countrySelectionCoordinator = [[CountrySelectionCoordinator alloc] 129 self.countrySelectionCoordinator = [[CountrySelectionCoordinator alloc]
118 initWithBaseViewController:self.viewController]; 130 initWithBaseViewController:self.editViewController];
119 [self.countrySelectionCoordinator setCountries:self.mediator.countries]; 131 [self.countrySelectionCoordinator setCountries:self.mediator.countries];
120 [self.countrySelectionCoordinator 132 [self.countrySelectionCoordinator
121 setSelectedCountryCode:self.mediator.selectedCountryCode]; 133 setSelectedCountryCode:self.mediator.selectedCountryCode];
122 [self.countrySelectionCoordinator setDelegate:self]; 134 [self.countrySelectionCoordinator setDelegate:self];
123 [self.countrySelectionCoordinator start]; 135 [self.countrySelectionCoordinator start];
124 } 136 }
125 } 137 }
126 138
127 - (void)paymentRequestEditViewController: 139 - (void)paymentRequestEditViewController:
128 (PaymentRequestEditViewController*)controller 140 (PaymentRequestEditViewController*)controller
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 (PaymentRequestEditViewController*)controller { 176 (PaymentRequestEditViewController*)controller {
165 [self.delegate addressEditCoordinatorDidCancel:self]; 177 [self.delegate addressEditCoordinatorDidCancel:self];
166 } 178 }
167 179
168 #pragma mark - CountrySelectionCoordinatorDelegate 180 #pragma mark - CountrySelectionCoordinatorDelegate
169 181
170 - (void)countrySelectionCoordinator:(CountrySelectionCoordinator*)coordinator 182 - (void)countrySelectionCoordinator:(CountrySelectionCoordinator*)coordinator
171 didSelectCountryWithCode:(NSString*)countryCode { 183 didSelectCountryWithCode:(NSString*)countryCode {
172 if (self.mediator.selectedCountryCode != countryCode) { 184 if (self.mediator.selectedCountryCode != countryCode) {
173 [self.mediator setSelectedCountryCode:countryCode]; 185 [self.mediator setSelectedCountryCode:countryCode];
174 [self.viewController loadModel]; 186 [self.editViewController loadModel];
175 [self.viewController.collectionView reloadData]; 187 [self.editViewController.collectionView reloadData];
176 } 188 }
177 [self.countrySelectionCoordinator stop]; 189 [self.countrySelectionCoordinator stop];
178 self.countrySelectionCoordinator = nil; 190 self.countrySelectionCoordinator = nil;
179 } 191 }
180 192
181 @end 193 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/payments/address_edit_coordinator_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698