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

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: 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) UINavigationController* navigationController;
73
72 @property(nonatomic, strong) PaymentRequestEditViewController* viewController; 74 @property(nonatomic, strong) PaymentRequestEditViewController* viewController;
73 75
74 @property(nonatomic, strong) CreditCardEditViewControllerMediator* mediator; 76 @property(nonatomic, strong) CreditCardEditViewControllerMediator* mediator;
75 77
76 @end 78 @end
77 79
78 @implementation CreditCardEditCoordinator 80 @implementation CreditCardEditCoordinator
79 81
80 @synthesize creditCard = _creditCard; 82 @synthesize creditCard = _creditCard;
81 @synthesize paymentRequest = _paymentRequest; 83 @synthesize paymentRequest = _paymentRequest;
82 @synthesize delegate = _delegate; 84 @synthesize delegate = _delegate;
83 @synthesize billingAddressSelectionCoordinator = 85 @synthesize billingAddressSelectionCoordinator =
84 _billingAddressSelectionCoordinator; 86 _billingAddressSelectionCoordinator;
87 @synthesize navigationController = _navigationController;
85 @synthesize viewController = _viewController; 88 @synthesize viewController = _viewController;
86 @synthesize mediator = _mediator; 89 @synthesize mediator = _mediator;
87 90
88 - (void)start { 91 - (void)start {
89 _viewController = [[PaymentRequestEditViewController alloc] init]; 92 _viewController = [[PaymentRequestEditViewController alloc] init];
90 // TODO(crbug.com/602666): Title varies depending on the missing fields. 93 // TODO(crbug.com/602666): Title varies depending on the missing fields.
91 NSString* title = _creditCard 94 NSString* title = _creditCard
92 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CARD) 95 ? l10n_util::GetNSString(IDS_PAYMENTS_EDIT_CARD)
93 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD_LABEL); 96 : l10n_util::GetNSString(IDS_PAYMENTS_ADD_CARD_LABEL);
94 [_viewController setTitle:title]; 97 [_viewController setTitle:title];
95 [_viewController setDelegate:self]; 98 [_viewController setDelegate:self];
96 [_viewController setValidatorDelegate:self]; 99 [_viewController setValidatorDelegate:self];
97 _mediator = [[CreditCardEditViewControllerMediator alloc] 100 _mediator = [[CreditCardEditViewControllerMediator alloc]
98 initWithPaymentRequest:_paymentRequest 101 initWithPaymentRequest:_paymentRequest
99 creditCard:_creditCard]; 102 creditCard:_creditCard];
100 [_mediator setConsumer:_viewController]; 103 [_mediator setConsumer:_viewController];
101 [_viewController setDataSource:_mediator]; 104 [_viewController setDataSource:_mediator];
102 [_viewController loadModel]; 105 [_viewController loadModel];
103 106
104 [[self baseViewController] presentViewController:_viewController 107 self.navigationController = [[UINavigationController alloc]
108 initWithRootViewController:_viewController];
109 [self.navigationController
110 setModalPresentationStyle:UIModalPresentationFormSheet];
111 [self.navigationController
112 setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
113 [self.navigationController setNavigationBarHidden:YES];
114
115 [[self baseViewController] presentViewController:self.navigationController
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.navigationController 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.viewController = nil;
127 self.navigationController = 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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