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

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

Issue 2944083003: [Payment Request] Fixes modally presented editors (Closed)
Patch Set: 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/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
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) UINavigationController* navigationController;
35
34 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; 36 @property(nonatomic, strong) PaymentRequestEditViewController* viewController;
35 37
36 @property(nonatomic, strong) ContactInfoEditMediator* mediator; 38 @property(nonatomic, strong) ContactInfoEditMediator* mediator;
37 39
38 @end 40 @end
39 41
40 @implementation ContactInfoEditCoordinator 42 @implementation ContactInfoEditCoordinator
41 43
42 @synthesize profile = _profile; 44 @synthesize profile = _profile;
43 @synthesize paymentRequest = _paymentRequest; 45 @synthesize paymentRequest = _paymentRequest;
44 @synthesize delegate = _delegate; 46 @synthesize delegate = _delegate;
47 @synthesize navigationController = _navigationController;
45 @synthesize viewController = _viewController; 48 @synthesize viewController = _viewController;
46 @synthesize mediator = _mediator; 49 @synthesize mediator = _mediator;
47 50
48 - (void)start { 51 - (void)start {
49 self.viewController = [[PaymentRequestEditViewController alloc] init]; 52 self.viewController = [[PaymentRequestEditViewController alloc] init];
50 // TODO(crbug.com/602666): Title varies depending on what field is missing. 53 // TODO(crbug.com/602666): Title varies depending on what field is missing.
51 // e.g., Add Email vs. Add Phone Number. 54 // e.g., Add Email vs. Add Phone Number.
52 NSString* title = 55 NSString* title =
53 self.profile 56 self.profile
54 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CONTACT_DETAILS_LABEL) 57 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CONTACT_DETAILS_LABEL)
55 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CONTACT_DETAILS_LABEL); 58 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CONTACT_DETAILS_LABEL);
56 [self.viewController setTitle:title]; 59 [self.viewController setTitle:title];
57 [self.viewController setDelegate:self]; 60 [self.viewController setDelegate:self];
58 [self.viewController setValidatorDelegate:self]; 61 [self.viewController setValidatorDelegate:self];
59 self.mediator = [[ContactInfoEditMediator alloc] 62 self.mediator = [[ContactInfoEditMediator alloc]
60 initWithPaymentRequest:self.paymentRequest 63 initWithPaymentRequest:self.paymentRequest
61 profile:self.profile]; 64 profile:self.profile];
62 [self.mediator setConsumer:self.viewController]; 65 [self.mediator setConsumer:self.viewController];
63 [self.viewController setDataSource:self.mediator]; 66 [self.viewController setDataSource:self.mediator];
64 [self.viewController loadModel]; 67 [self.viewController loadModel];
65 68
66 [[self baseViewController] presentViewController:self.viewController 69 self.navigationController = [[UINavigationController alloc]
70 initWithRootViewController:_viewController];
71 [self.navigationController
72 setModalPresentationStyle:UIModalPresentationFormSheet];
73 [self.navigationController
74 setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
75 [self.navigationController setNavigationBarHidden:YES];
76
77 [[self baseViewController] presentViewController:self.navigationController
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.navigationController presentingViewController]
73 dismissViewControllerAnimated:YES 84 dismissViewControllerAnimated:YES
74 completion:nil]; 85 completion:nil];
75 self.viewController = nil; 86 self.viewController = nil;
87 self.navigationController = 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) {
85 case AutofillUITypeProfileHomePhoneWholeNumber: { 97 case AutofillUITypeProfileHomePhoneWholeNumber: {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698