OLD | NEW |
---|---|
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 Loading... | |
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) UINavigationController* navigationController; | |
lpromero
2017/06/20 08:46:05
I think I'd go the other way. The nav controller i
Moe
2017/06/20 13:33:00
Done.
| |
39 | |
38 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; | 40 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; |
39 | 41 |
40 @property(nonatomic, strong) AddressEditMediator* mediator; | 42 @property(nonatomic, strong) AddressEditMediator* mediator; |
41 | 43 |
42 @end | 44 @end |
43 | 45 |
44 @implementation AddressEditCoordinator | 46 @implementation AddressEditCoordinator |
45 | 47 |
46 @synthesize address = _address; | 48 @synthesize address = _address; |
47 @synthesize paymentRequest = _paymentRequest; | 49 @synthesize paymentRequest = _paymentRequest; |
48 @synthesize delegate = _delegate; | 50 @synthesize delegate = _delegate; |
49 @synthesize countrySelectionCoordinator = _countrySelectionCoordinator; | 51 @synthesize countrySelectionCoordinator = _countrySelectionCoordinator; |
52 @synthesize navigationController = _navigationController; | |
50 @synthesize viewController = _viewController; | 53 @synthesize viewController = _viewController; |
51 @synthesize mediator = _mediator; | 54 @synthesize mediator = _mediator; |
52 | 55 |
53 - (void)start { | 56 - (void)start { |
54 self.viewController = [[PaymentRequestEditViewController alloc] init]; | 57 self.viewController = [[PaymentRequestEditViewController alloc] init]; |
55 // TODO(crbug.com/602666): Title varies depending on what field is missing. | 58 // TODO(crbug.com/602666): Title varies depending on what field is missing. |
56 // e.g., Add Email vs. Add Phone Number. | 59 // e.g., Add Email vs. Add Phone Number. |
57 NSString* title = self.address | 60 NSString* title = self.address |
58 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_ADDRESS) | 61 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_ADDRESS) |
59 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_ADDRESS); | 62 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_ADDRESS); |
60 [self.viewController setTitle:title]; | 63 [self.viewController setTitle:title]; |
61 [self.viewController setDelegate:self]; | 64 [self.viewController setDelegate:self]; |
62 [self.viewController setValidatorDelegate:self]; | 65 [self.viewController setValidatorDelegate:self]; |
63 self.mediator = | 66 self.mediator = |
64 [[AddressEditMediator alloc] initWithPaymentRequest:self.paymentRequest | 67 [[AddressEditMediator alloc] initWithPaymentRequest:self.paymentRequest |
65 address:self.address]; | 68 address:self.address]; |
66 [self.mediator setConsumer:self.viewController]; | 69 [self.mediator setConsumer:self.viewController]; |
67 [self.viewController setDataSource:self.mediator]; | 70 [self.viewController setDataSource:self.mediator]; |
68 [self.viewController loadModel]; | 71 [self.viewController loadModel]; |
69 | 72 |
70 [[self baseViewController] presentViewController:self.viewController | 73 self.navigationController = [[UINavigationController alloc] |
74 initWithRootViewController:_viewController]; | |
75 [self.navigationController | |
76 setModalPresentationStyle:UIModalPresentationFormSheet]; | |
77 [self.navigationController | |
78 setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; | |
79 [self.navigationController setNavigationBarHidden:YES]; | |
80 | |
81 [[self baseViewController] presentViewController:self.navigationController | |
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.navigationController 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; |
81 self.viewController = nil; | 92 self.viewController = nil; |
93 self.navigationController = 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) { |
91 case AutofillUITypeProfileHomePhoneWholeNumber: { | 103 case AutofillUITypeProfileHomePhoneWholeNumber: { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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.viewController loadModel]; |
175 [self.viewController.collectionView reloadData]; | 187 [self.viewController.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 |
OLD | NEW |