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/contact_info_edit_coordinator.h" | 5 #import "ios/chrome/browser/ui/payments/contact_info_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 13 matching lines...) Expand all Loading... |
24 #if !defined(__has_feature) || !__has_feature(objc_arc) | 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
25 #error "This file requires ARC support." | 25 #error "This file requires ARC support." |
26 #endif | 26 #endif |
27 | 27 |
28 namespace { | 28 namespace { |
29 using ::AutofillTypeFromAutofillUIType; | 29 using ::AutofillTypeFromAutofillUIType; |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 @interface ContactInfoEditCoordinator () | 32 @interface ContactInfoEditCoordinator () |
33 | 33 |
34 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; | 34 @property(nonatomic, strong) UINavigationController* viewController; |
| 35 |
| 36 @property(nonatomic, strong) |
| 37 PaymentRequestEditViewController* editViewController; |
35 | 38 |
36 @property(nonatomic, strong) ContactInfoEditMediator* mediator; | 39 @property(nonatomic, strong) ContactInfoEditMediator* mediator; |
37 | 40 |
38 @end | 41 @end |
39 | 42 |
40 @implementation ContactInfoEditCoordinator | 43 @implementation ContactInfoEditCoordinator |
41 | 44 |
42 @synthesize profile = _profile; | 45 @synthesize profile = _profile; |
43 @synthesize paymentRequest = _paymentRequest; | 46 @synthesize paymentRequest = _paymentRequest; |
44 @synthesize delegate = _delegate; | 47 @synthesize delegate = _delegate; |
45 @synthesize viewController = _viewController; | 48 @synthesize viewController = _viewController; |
| 49 @synthesize editViewController = _editViewController; |
46 @synthesize mediator = _mediator; | 50 @synthesize mediator = _mediator; |
47 | 51 |
48 - (void)start { | 52 - (void)start { |
49 self.viewController = [[PaymentRequestEditViewController alloc] init]; | 53 self.editViewController = [[PaymentRequestEditViewController alloc] init]; |
50 // TODO(crbug.com/602666): Title varies depending on what field is missing. | 54 // TODO(crbug.com/602666): Title varies depending on what field is missing. |
51 // e.g., Add Email vs. Add Phone Number. | 55 // e.g., Add Email vs. Add Phone Number. |
52 NSString* title = | 56 NSString* title = |
53 self.profile | 57 self.profile |
54 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CONTACT_DETAILS_LABEL) | 58 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CONTACT_DETAILS_LABEL) |
55 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CONTACT_DETAILS_LABEL); | 59 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CONTACT_DETAILS_LABEL); |
56 [self.viewController setTitle:title]; | 60 [self.editViewController setTitle:title]; |
57 [self.viewController setDelegate:self]; | 61 [self.editViewController setDelegate:self]; |
58 [self.viewController setValidatorDelegate:self]; | 62 [self.editViewController setValidatorDelegate:self]; |
59 self.mediator = [[ContactInfoEditMediator alloc] | 63 self.mediator = [[ContactInfoEditMediator alloc] |
60 initWithPaymentRequest:self.paymentRequest | 64 initWithPaymentRequest:self.paymentRequest |
61 profile:self.profile]; | 65 profile:self.profile]; |
62 [self.mediator setConsumer:self.viewController]; | 66 [self.mediator setConsumer:self.editViewController]; |
63 [self.viewController setDataSource:self.mediator]; | 67 [self.editViewController setDataSource:self.mediator]; |
64 [self.viewController loadModel]; | 68 [self.editViewController loadModel]; |
| 69 |
| 70 self.viewController = [[UINavigationController alloc] |
| 71 initWithRootViewController:self.editViewController]; |
| 72 [self.viewController setModalPresentationStyle:UIModalPresentationFormSheet]; |
| 73 [self.viewController |
| 74 setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; |
| 75 [self.viewController setNavigationBarHidden:YES]; |
65 | 76 |
66 [[self baseViewController] presentViewController:self.viewController | 77 [[self baseViewController] presentViewController:self.viewController |
67 animated:YES | 78 animated:YES |
68 completion:nil]; | 79 completion:nil]; |
69 } | 80 } |
70 | 81 |
71 - (void)stop { | 82 - (void)stop { |
72 [[self.viewController presentingViewController] | 83 [[self.viewController presentingViewController] |
73 dismissViewControllerAnimated:YES | 84 dismissViewControllerAnimated:YES |
74 completion:nil]; | 85 completion:nil]; |
| 86 self.editViewController = nil; |
75 self.viewController = nil; | 87 self.viewController = nil; |
76 } | 88 } |
77 | 89 |
78 #pragma mark - PaymentRequestEditViewControllerValidator | 90 #pragma mark - PaymentRequestEditViewControllerValidator |
79 | 91 |
80 - (NSString*)paymentRequestEditViewController: | 92 - (NSString*)paymentRequestEditViewController: |
81 (PaymentRequestEditViewController*)controller | 93 (PaymentRequestEditViewController*)controller |
82 validateField:(EditorField*)field { | 94 validateField:(EditorField*)field { |
83 if (field.value.length) { | 95 if (field.value.length) { |
84 switch (field.autofillUIType) { | 96 switch (field.autofillUIType) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 [self.delegate contactInfoEditCoordinator:self | 160 [self.delegate contactInfoEditCoordinator:self |
149 didFinishEditingProfile:self.profile]; | 161 didFinishEditingProfile:self.profile]; |
150 } | 162 } |
151 | 163 |
152 - (void)paymentRequestEditViewControllerDidCancel: | 164 - (void)paymentRequestEditViewControllerDidCancel: |
153 (PaymentRequestEditViewController*)controller { | 165 (PaymentRequestEditViewController*)controller { |
154 [self.delegate contactInfoEditCoordinatorDidCancel:self]; | 166 [self.delegate contactInfoEditCoordinatorDidCancel:self]; |
155 } | 167 } |
156 | 168 |
157 @end | 169 @end |
OLD | NEW |