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

Side by Side Diff: ios/chrome/browser/translate/before_translate_infobar_controller.mm

Issue 2952403002: [ObjC ARC] Converts ios/chrome/browser/translate:translate to ARC. (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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ios/chrome/browser/translate/before_translate_infobar_controller.h" 5 #include "ios/chrome/browser/translate/before_translate_infobar_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include "base/ios/weak_nsobject.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/mac/scoped_nsobject.h"
13 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
15 #include "components/strings/grit/components_strings.h" 13 #include "components/strings/grit/components_strings.h"
16 #include "components/translate/core/browser/translate_infobar_delegate.h" 14 #include "components/translate/core/browser/translate_infobar_delegate.h"
17 #include "ios/chrome/browser/translate/translate_infobar_tags.h" 15 #include "ios/chrome/browser/translate/translate_infobar_tags.h"
18 #import "ios/chrome/browser/ui/infobars/infobar_view.h" 16 #import "ios/chrome/browser/ui/infobars/infobar_view.h"
19 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h" 17 #import "ios/chrome/browser/ui/infobars/infobar_view_delegate.h"
20 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
22 20
21 #if !defined(__has_feature) || !__has_feature(objc_arc)
22 #error "This file requires ARC support."
23 #endif
24
23 namespace { 25 namespace {
24 26
25 CGFloat kNavigationBarHeight = 44; 27 CGFloat kNavigationBarHeight = 44;
26 CGFloat kUIPickerHeight = 216; 28 CGFloat kUIPickerHeight = 216;
27 CGFloat kUIPickerFontSize = 26; 29 CGFloat kUIPickerFontSize = 26;
28 NSTimeInterval kPickerAnimationDurationInSeconds = 0.2; 30 NSTimeInterval kPickerAnimationDurationInSeconds = 0.2;
29 31
30 } // namespace 32 } // namespace
31 33
32 // The class is a data source and delegate to the UIPickerView that contains the 34 // The class is a data source and delegate to the UIPickerView that contains the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #pragma mark - 71 #pragma mark -
70 #pragma mark UIPickerViewDelegate 72 #pragma mark UIPickerViewDelegate
71 73
72 - (UIView*)pickerView:(UIPickerView*)pickerView 74 - (UIView*)pickerView:(UIPickerView*)pickerView
73 viewForRow:(NSInteger)row 75 viewForRow:(NSInteger)row
74 forComponent:(NSInteger)component 76 forComponent:(NSInteger)component
75 reusingView:(UIView*)view { 77 reusingView:(UIView*)view {
76 DCHECK_EQ(0, component); 78 DCHECK_EQ(0, component);
77 UILabel* label = [view isKindOfClass:[UILabel class]] 79 UILabel* label = [view isKindOfClass:[UILabel class]]
78 ? (UILabel*)view 80 ? (UILabel*)view
79 : [[[UILabel alloc] init] autorelease]; 81 : [[UILabel alloc] init];
80 [label setText:base::SysUTF16ToNSString( 82 [label setText:base::SysUTF16ToNSString(
81 _translateInfoBarDelegate->language_name_at(row))]; 83 _translateInfoBarDelegate->language_name_at(row))];
82 [label setTextAlignment:NSTextAlignmentCenter]; 84 [label setTextAlignment:NSTextAlignmentCenter];
83 UIFont* font = [UIFont systemFontOfSize:kUIPickerFontSize]; 85 UIFont* font = [UIFont systemFontOfSize:kUIPickerFontSize];
84 BOOL enabled = YES; 86 BOOL enabled = YES;
85 if (row == _initialRow) 87 if (row == _initialRow)
86 font = [UIFont boldSystemFontOfSize:kUIPickerFontSize]; 88 font = [UIFont boldSystemFontOfSize:kUIPickerFontSize];
87 else if (row == _disabledRow) 89 else if (row == _disabledRow)
88 enabled = NO; 90 enabled = NO;
89 [label setFont:font]; 91 [label setFont:font];
(...skipping 15 matching lines...) Expand all
105 - (void)dismissLanguageSelectionView; 107 - (void)dismissLanguageSelectionView;
106 // Changes the text on the view to match the language. 108 // Changes the text on the view to match the language.
107 - (void)updateInfobarLabelOnView:(InfoBarView*)view; 109 - (void)updateInfobarLabelOnView:(InfoBarView*)view;
108 110
109 @end 111 @end
110 112
111 @implementation BeforeTranslateInfoBarController { 113 @implementation BeforeTranslateInfoBarController {
112 translate::TranslateInfoBarDelegate* _translateInfoBarDelegate; // weak 114 translate::TranslateInfoBarDelegate* _translateInfoBarDelegate; // weak
113 // A fullscreen view that catches all touch events and contains a UIPickerView 115 // A fullscreen view that catches all touch events and contains a UIPickerView
114 // and a UINavigationBar. 116 // and a UINavigationBar.
115 base::scoped_nsobject<UIView> _languageSelectionView; 117 UIView* _languageSelectionView;
116 // Stores whether the user is currently choosing in the UIPickerView the 118 // Stores whether the user is currently choosing in the UIPickerView the
117 // original language, or the target language. 119 // original language, or the target language.
118 NSUInteger _languageSelectionType; 120 NSUInteger _languageSelectionType;
119 // The language picker. 121 // The language picker.
120 base::scoped_nsobject<UIPickerView> _languagePicker; 122 UIPickerView* _languagePicker;
121 // Navigation bar associated with the picker with "Done" and "Cancel" buttons. 123 // Navigation bar associated with the picker with "Done" and "Cancel" buttons.
122 base::scoped_nsobject<UINavigationBar> _navigationBar; 124 UINavigationBar* _navigationBar;
123 // The controller of the languagePicker. Needs to be an ivar because 125 // The controller of the languagePicker. Needs to be an ivar because
124 // |_languagePicker| does not retain it. 126 // |_languagePicker| does not retain it.
125 base::scoped_nsobject<LanguagePickerController> _languagePickerController; 127 LanguagePickerController* _languagePickerController;
126 } 128 }
127 129
128 #pragma mark - 130 #pragma mark -
129 #pragma mark InfoBarControllerProtocol 131 #pragma mark InfoBarControllerProtocol
130 132
131 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate 133 - (InfoBarView*)viewForDelegate:(infobars::InfoBarDelegate*)delegate
132 frame:(CGRect)frame { 134 frame:(CGRect)frame {
133 base::scoped_nsobject<InfoBarView> infoBarView; 135 InfoBarView* infoBarView;
134 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate(); 136 _translateInfoBarDelegate = delegate->AsTranslateInfoBarDelegate();
135 infoBarView.reset( 137 infoBarView =
136 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate]); 138 [[InfoBarView alloc] initWithFrame:frame delegate:self.delegate];
137 // Icon 139 // Icon
138 gfx::Image icon = _translateInfoBarDelegate->GetIcon(); 140 gfx::Image icon = _translateInfoBarDelegate->GetIcon();
139 if (!icon.IsEmpty()) 141 if (!icon.IsEmpty())
140 [infoBarView addLeftIcon:icon.ToUIImage()]; 142 [infoBarView addLeftIcon:icon.ToUIImage()];
141 143
142 // Main text. 144 // Main text.
143 [self updateInfobarLabelOnView:infoBarView]; 145 [self updateInfobarLabelOnView:infoBarView];
144 146
145 // Close button. 147 // Close button.
146 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::BEFORE_DENY 148 [infoBarView addCloseButtonWithTag:TranslateInfoBarIOSTag::BEFORE_DENY
147 target:self 149 target:self
148 action:@selector(infoBarButtonDidPress:)]; 150 action:@selector(infoBarButtonDidPress:)];
149 // Other buttons. 151 // Other buttons.
150 NSString* buttonAccept = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_ACCEPT); 152 NSString* buttonAccept = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_ACCEPT);
151 NSString* buttonDeny = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_DENY); 153 NSString* buttonDeny = l10n_util::GetNSString(IDS_TRANSLATE_INFOBAR_DENY);
152 [infoBarView addButton1:buttonAccept 154 [infoBarView addButton1:buttonAccept
153 tag1:TranslateInfoBarIOSTag::BEFORE_ACCEPT 155 tag1:TranslateInfoBarIOSTag::BEFORE_ACCEPT
154 button2:buttonDeny 156 button2:buttonDeny
155 tag2:TranslateInfoBarIOSTag::BEFORE_DENY 157 tag2:TranslateInfoBarIOSTag::BEFORE_DENY
156 target:self 158 target:self
157 action:@selector(infoBarButtonDidPress:)]; 159 action:@selector(infoBarButtonDidPress:)];
158 return [[infoBarView retain] autorelease]; 160 return infoBarView;
159 } 161 }
160 162
161 - (void)updateInfobarLabelOnView:(InfoBarView*)view { 163 - (void)updateInfobarLabelOnView:(InfoBarView*)view {
162 NSString* originalLanguage = base::SysUTF16ToNSString( 164 NSString* originalLanguage = base::SysUTF16ToNSString(
163 _translateInfoBarDelegate->original_language_name()); 165 _translateInfoBarDelegate->original_language_name());
164 NSString* targetLanguage = base::SysUTF16ToNSString( 166 NSString* targetLanguage = base::SysUTF16ToNSString(
165 _translateInfoBarDelegate->target_language_name()); 167 _translateInfoBarDelegate->target_language_name());
166 base::string16 originalLanguageWithLink = 168 base::string16 originalLanguageWithLink =
167 base::SysNSStringToUTF16([[view class] 169 base::SysNSStringToUTF16([[view class]
168 stringAsLink:originalLanguage 170 stringAsLink:originalLanguage
169 tag:TranslateInfoBarIOSTag::BEFORE_SOURCE_LANGUAGE]); 171 tag:TranslateInfoBarIOSTag::BEFORE_SOURCE_LANGUAGE]);
170 base::string16 targetLanguageWithLink = base::SysNSStringToUTF16([[view class] 172 base::string16 targetLanguageWithLink = base::SysNSStringToUTF16([[view class]
171 stringAsLink:targetLanguage 173 stringAsLink:targetLanguage
172 tag:TranslateInfoBarIOSTag::BEFORE_TARGET_LANGUAGE]); 174 tag:TranslateInfoBarIOSTag::BEFORE_TARGET_LANGUAGE]);
173 NSString* label = 175 NSString* label =
174 l10n_util::GetNSStringF(IDS_TRANSLATE_INFOBAR_BEFORE_MESSAGE_IOS, 176 l10n_util::GetNSStringF(IDS_TRANSLATE_INFOBAR_BEFORE_MESSAGE_IOS,
175 originalLanguageWithLink, targetLanguageWithLink); 177 originalLanguageWithLink, targetLanguageWithLink);
176 178
177 base::WeakNSObject<BeforeTranslateInfoBarController> weakSelf(self); 179 __weak BeforeTranslateInfoBarController* weakSelf = self;
178 [view addLabel:label 180 [view addLabel:label
179 action:^(NSUInteger tag) { 181 action:^(NSUInteger tag) {
180 [weakSelf infobarLinkDidPress:tag]; 182 [weakSelf infobarLinkDidPress:tag];
181 }]; 183 }];
182 } 184 }
183 185
184 - (void)languageSelectionDone { 186 - (void)languageSelectionDone {
185 size_t selectedRow = [_languagePicker selectedRowInComponent:0]; 187 size_t selectedRow = [_languagePicker selectedRowInComponent:0];
186 std::string lang = _translateInfoBarDelegate->language_code_at(selectedRow); 188 std::string lang = _translateInfoBarDelegate->language_code_at(selectedRow);
187 if (_languageSelectionType == 189 if (_languageSelectionType ==
(...skipping 14 matching lines...) Expand all
202 DCHECK_EQ(_languagePicker == nil, _navigationBar == nil); 204 DCHECK_EQ(_languagePicker == nil, _navigationBar == nil);
203 if (_languagePicker == nil) 205 if (_languagePicker == nil)
204 return; 206 return;
205 // Sets the picker's delegate and data source to nil, because the 207 // Sets the picker's delegate and data source to nil, because the
206 // |_languagePickerController| may be destroyed before the picker is hidden, 208 // |_languagePickerController| may be destroyed before the picker is hidden,
207 // and even though the interactions with the picker are disabled, it might 209 // and even though the interactions with the picker are disabled, it might
208 // still be turning and requesting data from the data source or calling the 210 // still be turning and requesting data from the data source or calling the
209 // delegate. 211 // delegate.
210 [_languagePicker setDataSource:nil]; 212 [_languagePicker setDataSource:nil];
211 [_languagePicker setDelegate:nil]; 213 [_languagePicker setDelegate:nil];
212 _languagePickerController.reset(); 214 _languagePickerController = nil;
213 // Animate the picker away. 215 // Animate the picker away.
214 CGRect languagePickerFrame = [_languagePicker frame]; 216 CGRect languagePickerFrame = [_languagePicker frame];
215 CGRect navigationBarFrame = [_navigationBar frame]; 217 CGRect navigationBarFrame = [_navigationBar frame];
216 const CGFloat animationHeight = 218 const CGFloat animationHeight =
217 languagePickerFrame.size.height + navigationBarFrame.size.height; 219 languagePickerFrame.size.height + navigationBarFrame.size.height;
218 languagePickerFrame.origin.y += animationHeight; 220 languagePickerFrame.origin.y += animationHeight;
219 navigationBarFrame.origin.y += animationHeight; 221 navigationBarFrame.origin.y += animationHeight;
220 auto blockLanguagePicker(_languagePicker); 222 UIPickerView* blockLanguagePicker = _languagePicker;
221 auto blockNavigationBar(_navigationBar); 223 UINavigationBar* blockNavigationBar = _navigationBar;
222 _languagePicker.reset(); 224 _languagePicker = nil;
223 _navigationBar.reset(); 225 _navigationBar = nil;
224 void (^animations)(void) = ^{ 226 void (^animations)(void) = ^{
225 blockLanguagePicker.get().frame = languagePickerFrame; 227 blockLanguagePicker.frame = languagePickerFrame;
226 blockNavigationBar.get().frame = navigationBarFrame; 228 blockNavigationBar.frame = navigationBarFrame;
227 }; 229 };
228 auto blockSelectionView(_languageSelectionView); 230 UIView* blockSelectionView = _languageSelectionView;
229 _languageSelectionView.reset(); 231 _languageSelectionView = nil;
230 void (^completion)(BOOL finished) = ^(BOOL finished) { 232 void (^completion)(BOOL finished) = ^(BOOL finished) {
231 [blockSelectionView removeFromSuperview]; 233 [blockSelectionView removeFromSuperview];
232 }; 234 };
233 [UIView animateWithDuration:kPickerAnimationDurationInSeconds 235 [UIView animateWithDuration:kPickerAnimationDurationInSeconds
234 animations:animations 236 animations:animations
235 completion:completion]; 237 completion:completion];
236 } 238 }
237 239
238 #pragma mark - Handling of User Events 240 #pragma mark - Handling of User Events
239 241
(...skipping 25 matching lines...) Expand all
265 // UINavigationBar. 267 // UINavigationBar.
266 UIView* parentView = 268 UIView* parentView =
267 [[UIApplication sharedApplication] keyWindow].rootViewController.view; 269 [[UIApplication sharedApplication] keyWindow].rootViewController.view;
268 // Convert the parent frame to handle device rotation. 270 // Convert the parent frame to handle device rotation.
269 CGRect parentFrame = 271 CGRect parentFrame =
270 CGRectApplyAffineTransform([parentView frame], [parentView transform]); 272 CGRectApplyAffineTransform([parentView frame], [parentView transform]);
271 const CGFloat totalPickerHeight = kUIPickerHeight + kNavigationBarHeight; 273 const CGFloat totalPickerHeight = kUIPickerHeight + kNavigationBarHeight;
272 CGRect languageSelectionViewFrame = 274 CGRect languageSelectionViewFrame =
273 CGRectMake(0, parentFrame.size.height - totalPickerHeight, 275 CGRectMake(0, parentFrame.size.height - totalPickerHeight,
274 parentFrame.size.width, totalPickerHeight); 276 parentFrame.size.width, totalPickerHeight);
275 _languageSelectionView.reset( 277 _languageSelectionView =
276 [[UIView alloc] initWithFrame:languageSelectionViewFrame]); 278 [[UIView alloc] initWithFrame:languageSelectionViewFrame];
277 [_languageSelectionView 279 [_languageSelectionView
278 setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 280 setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
279 UIViewAutoresizingFlexibleTopMargin]; 281 UIViewAutoresizingFlexibleTopMargin];
280 [parentView addSubview:_languageSelectionView]; 282 [parentView addSubview:_languageSelectionView];
281 283
282 // Creates the navigation bar and its buttons. 284 // Creates the navigation bar and its buttons.
283 CGRect finalPickerFrame = CGRectMake( 285 CGRect finalPickerFrame = CGRectMake(
284 0, [_languageSelectionView frame].size.height - kUIPickerHeight, 286 0, [_languageSelectionView frame].size.height - kUIPickerHeight,
285 [_languageSelectionView frame].size.width, kUIPickerHeight); 287 [_languageSelectionView frame].size.width, kUIPickerHeight);
286 CGRect finalNavigationBarFrame = CGRectMake( 288 CGRect finalNavigationBarFrame = CGRectMake(
287 0, 0, [_languageSelectionView frame].size.width, kNavigationBarHeight); 289 0, 0, [_languageSelectionView frame].size.width, kNavigationBarHeight);
288 // The language picker animates from the bottom of the screen. 290 // The language picker animates from the bottom of the screen.
289 CGRect initialPickerFrame = finalPickerFrame; 291 CGRect initialPickerFrame = finalPickerFrame;
290 initialPickerFrame.origin.y += totalPickerHeight; 292 initialPickerFrame.origin.y += totalPickerHeight;
291 CGRect initialNavigationBarFrame = finalNavigationBarFrame; 293 CGRect initialNavigationBarFrame = finalNavigationBarFrame;
292 initialNavigationBarFrame.origin.y += totalPickerHeight; 294 initialNavigationBarFrame.origin.y += totalPickerHeight;
293 295
294 _navigationBar.reset( 296 _navigationBar =
295 [[UINavigationBar alloc] initWithFrame:initialNavigationBarFrame]); 297 [[UINavigationBar alloc] initWithFrame:initialNavigationBarFrame];
296 const UIViewAutoresizing resizingMask = 298 const UIViewAutoresizing resizingMask =
297 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; 299 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
298 [_navigationBar setAutoresizingMask:resizingMask]; 300 [_navigationBar setAutoresizingMask:resizingMask];
299 base::scoped_nsobject<UIBarButtonItem> doneButton([[UIBarButtonItem alloc] 301 UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]
300 initWithBarButtonSystemItem:UIBarButtonSystemItemDone 302 initWithBarButtonSystemItem:UIBarButtonSystemItemDone
301 target:self 303 target:self
302 action:@selector(languageSelectionDone)]); 304 action:@selector(languageSelectionDone)];
303 base::scoped_nsobject<UIBarButtonItem> cancelButton([[UIBarButtonItem alloc] 305 UIBarButtonItem* cancelButton = [[UIBarButtonItem alloc]
304 initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 306 initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
305 target:self 307 target:self
306 action:@selector(dismissLanguageSelectionView)]); 308 action:@selector(dismissLanguageSelectionView)];
307 base::scoped_nsobject<UINavigationItem> item( 309 UINavigationItem* item = [[UINavigationItem alloc] initWithTitle:@""];
308 [[UINavigationItem alloc] initWithTitle:@""]);
309 [item setRightBarButtonItem:doneButton]; 310 [item setRightBarButtonItem:doneButton];
310 [item setLeftBarButtonItem:cancelButton]; 311 [item setLeftBarButtonItem:cancelButton];
311 [item setHidesBackButton:YES]; 312 [item setHidesBackButton:YES];
312 [_navigationBar pushNavigationItem:item animated:NO]; 313 [_navigationBar pushNavigationItem:item animated:NO];
313 314
314 // Creates the PickerView and its controller. 315 // Creates the PickerView and its controller.
315 NSInteger selectedRow; 316 NSInteger selectedRow;
316 NSInteger disabledRow; 317 NSInteger disabledRow;
317 NSInteger originalLanguageIndex = -1; 318 NSInteger originalLanguageIndex = -1;
318 NSInteger targetLanguageIndex = -1; 319 NSInteger targetLanguageIndex = -1;
(...skipping 12 matching lines...) Expand all
331 DCHECK_GT(targetLanguageIndex, -1); 332 DCHECK_GT(targetLanguageIndex, -1);
332 333
333 if (_languageSelectionType == 334 if (_languageSelectionType ==
334 TranslateInfoBarIOSTag::BEFORE_SOURCE_LANGUAGE) { 335 TranslateInfoBarIOSTag::BEFORE_SOURCE_LANGUAGE) {
335 selectedRow = originalLanguageIndex; 336 selectedRow = originalLanguageIndex;
336 disabledRow = targetLanguageIndex; 337 disabledRow = targetLanguageIndex;
337 } else { 338 } else {
338 selectedRow = targetLanguageIndex; 339 selectedRow = targetLanguageIndex;
339 disabledRow = originalLanguageIndex; 340 disabledRow = originalLanguageIndex;
340 } 341 }
341 _languagePickerController.reset([[LanguagePickerController alloc] 342 _languagePickerController = [[LanguagePickerController alloc]
342 initWithDelegate:_translateInfoBarDelegate 343 initWithDelegate:_translateInfoBarDelegate
343 initialRow:selectedRow 344 initialRow:selectedRow
344 disabledRow:disabledRow]); 345 disabledRow:disabledRow];
345 _languagePicker.reset( 346 _languagePicker = [[UIPickerView alloc] initWithFrame:initialPickerFrame];
346 [[UIPickerView alloc] initWithFrame:initialPickerFrame]);
347 [_languagePicker setAutoresizingMask:resizingMask]; 347 [_languagePicker setAutoresizingMask:resizingMask];
348 [_languagePicker setShowsSelectionIndicator:YES]; 348 [_languagePicker setShowsSelectionIndicator:YES];
349 [_languagePicker setDataSource:_languagePickerController]; 349 [_languagePicker setDataSource:_languagePickerController];
350 [_languagePicker setDelegate:_languagePickerController]; 350 [_languagePicker setDelegate:_languagePickerController];
351 [_languagePicker setShowsSelectionIndicator:YES]; 351 [_languagePicker setShowsSelectionIndicator:YES];
352 [_languagePicker setBackgroundColor:[self.view backgroundColor]]; 352 [_languagePicker setBackgroundColor:[self.view backgroundColor]];
353 [_languagePicker selectRow:selectedRow inComponent:0 animated:NO]; 353 [_languagePicker selectRow:selectedRow inComponent:0 animated:NO];
354 354
355 auto blockLanguagePicker(_languagePicker); 355 UIPickerView* blockLanguagePicker = _languagePicker;
356 auto blockNavigationBar(_navigationBar); 356 UINavigationBar* blockNavigationBar = _navigationBar;
357 [UIView animateWithDuration:kPickerAnimationDurationInSeconds 357 [UIView animateWithDuration:kPickerAnimationDurationInSeconds
358 animations:^{ 358 animations:^{
359 blockLanguagePicker.get().frame = finalPickerFrame; 359 blockLanguagePicker.frame = finalPickerFrame;
360 blockNavigationBar.get().frame = finalNavigationBarFrame; 360 blockNavigationBar.frame = finalNavigationBarFrame;
361 }]; 361 }];
362 362
363 // Add the subviews. 363 // Add the subviews.
364 [_languageSelectionView addSubview:_languagePicker]; 364 [_languageSelectionView addSubview:_languagePicker];
365 [_languageSelectionView addSubview:_navigationBar]; 365 [_languageSelectionView addSubview:_navigationBar];
366 } 366 }
367 367
368 - (void)removeView { 368 - (void)removeView {
369 [super removeView]; 369 [super removeView];
370 [self dismissLanguageSelectionView]; 370 [self dismissLanguageSelectionView];
371 } 371 }
372 372
373 - (void)detachView { 373 - (void)detachView {
374 [super detachView]; 374 [super detachView];
375 [self dismissLanguageSelectionView]; 375 [self dismissLanguageSelectionView];
376 } 376 }
377 377
378 @end 378 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698