| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/elements/selector_picker_presentation_controller.
h" | 5 #import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.
h" |
| 6 | 6 |
| 7 #import "base/mac/objc_property_releaser.h" | 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 8 #error "This file requires ARC support." |
| 9 #endif |
| 8 | 10 |
| 9 @interface SelectorPickerPresentationController () { | 11 @interface SelectorPickerPresentationController () |
| 10 base::mac::ObjCPropertyReleaser | 12 @property(nonatomic, strong) UIView* dimmingView; |
| 11 _propertyReleaser_SelectorPickerPresentationController; | |
| 12 } | |
| 13 @property(nonatomic, retain) UIView* dimmingView; | |
| 14 @end | 13 @end |
| 15 | 14 |
| 16 @implementation SelectorPickerPresentationController | 15 @implementation SelectorPickerPresentationController |
| 17 | 16 |
| 18 @synthesize dimmingView = _dimmingView; | 17 @synthesize dimmingView = _dimmingView; |
| 19 | 18 |
| 20 - (instancetype)initWithPresentedViewController:(UIViewController*)presented | 19 - (instancetype)initWithPresentedViewController:(UIViewController*)presented |
| 21 presentingViewController:(UIViewController*)presenting { | 20 presentingViewController:(UIViewController*)presenting { |
| 22 self = [super initWithPresentedViewController:presented | 21 self = [super initWithPresentedViewController:presented |
| 23 presentingViewController:presenting]; | 22 presentingViewController:presenting]; |
| 24 if (self) { | 23 if (self) { |
| 25 _propertyReleaser_SelectorPickerPresentationController.Init( | |
| 26 self, [SelectorPickerPresentationController class]); | |
| 27 _dimmingView = [[UIView alloc] initWithFrame:CGRectZero]; | 24 _dimmingView = [[UIView alloc] initWithFrame:CGRectZero]; |
| 28 _dimmingView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; | 25 _dimmingView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; |
| 29 } | 26 } |
| 30 return self; | 27 return self; |
| 31 } | 28 } |
| 32 | 29 |
| 33 - (CGRect)frameOfPresentedViewInContainerView { | 30 - (CGRect)frameOfPresentedViewInContainerView { |
| 34 CGSize containerSize = self.containerView.frame.size; | 31 CGSize containerSize = self.containerView.frame.size; |
| 35 CGSize pickerSize = [self.presentedView | 32 CGSize pickerSize = [self.presentedView |
| 36 systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; | 33 systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; |
| 37 return CGRectMake(0, containerSize.height - pickerSize.height, | 34 return CGRectMake(0, containerSize.height - pickerSize.height, |
| 38 containerSize.width, pickerSize.height); | 35 containerSize.width, pickerSize.height); |
| 39 } | 36 } |
| 40 | 37 |
| 41 - (void)containerViewWillLayoutSubviews { | 38 - (void)containerViewWillLayoutSubviews { |
| 42 self.dimmingView.frame = self.containerView.bounds; | 39 self.dimmingView.frame = self.containerView.bounds; |
| 43 self.presentedView.frame = [self frameOfPresentedViewInContainerView]; | 40 self.presentedView.frame = [self frameOfPresentedViewInContainerView]; |
| 44 } | 41 } |
| 45 | 42 |
| 46 - (void)presentationTransitionWillBegin { | 43 - (void)presentationTransitionWillBegin { |
| 47 [self.containerView addSubview:self.dimmingView]; | 44 [self.containerView addSubview:self.dimmingView]; |
| 48 } | 45 } |
| 49 | 46 |
| 50 - (void)dismissalTransitionDidEnd:(BOOL)completed { | 47 - (void)dismissalTransitionDidEnd:(BOOL)completed { |
| 51 [self.dimmingView removeFromSuperview]; | 48 [self.dimmingView removeFromSuperview]; |
| 52 } | 49 } |
| 53 | 50 |
| 54 @end | 51 @end |
| OLD | NEW |