| Index: ios/chrome/browser/ui/elements/selector_picker_presentation_controller.mm
|
| diff --git a/ios/chrome/browser/ui/elements/selector_picker_presentation_controller.mm b/ios/chrome/browser/ui/elements/selector_picker_presentation_controller.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c7093131977ccdcd45573b3f1e4c6c1b81279efc
|
| --- /dev/null
|
| +++ b/ios/chrome/browser/ui/elements/selector_picker_presentation_controller.mm
|
| @@ -0,0 +1,54 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "ios/chrome/browser/ui/elements/selector_picker_presentation_controller.h"
|
| +
|
| +#import "base/mac/objc_property_releaser.h"
|
| +
|
| +@interface SelectorPickerPresentationController () {
|
| + base::mac::ObjCPropertyReleaser
|
| + _propertyReleaser_SelectorPickerPresentationController;
|
| +}
|
| +@property(nonatomic, retain) UIView* dimmingView;
|
| +@end
|
| +
|
| +@implementation SelectorPickerPresentationController
|
| +
|
| +@synthesize dimmingView = _dimmingView;
|
| +
|
| +- (instancetype)initWithPresentedViewController:(UIViewController*)presented
|
| + presentingViewController:(UIViewController*)presenting {
|
| + self = [super initWithPresentedViewController:presented
|
| + presentingViewController:presenting];
|
| + if (self) {
|
| + _propertyReleaser_SelectorPickerPresentationController.Init(
|
| + self, [SelectorPickerPresentationController class]);
|
| + _dimmingView = [[UIView alloc] initWithFrame:CGRectZero];
|
| + _dimmingView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (CGRect)frameOfPresentedViewInContainerView {
|
| + CGSize containerSize = self.containerView.frame.size;
|
| + CGSize pickerSize = [self.presentedView
|
| + systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
|
| + return CGRectMake(0, containerSize.height - pickerSize.height,
|
| + containerSize.width, pickerSize.height);
|
| +}
|
| +
|
| +- (void)containerViewWillLayoutSubviews {
|
| + self.dimmingView.frame = self.containerView.bounds;
|
| + self.presentedView.frame = [self frameOfPresentedViewInContainerView];
|
| +}
|
| +
|
| +- (void)presentationTransitionWillBegin {
|
| + [self.containerView addSubview:self.dimmingView];
|
| +}
|
| +
|
| +- (void)dismissalTransitionDidEnd:(BOOL)completed {
|
| + [self.dimmingView removeFromSuperview];
|
| +}
|
| +
|
| +@end
|
|
|