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

Unified Diff: ios/chrome/browser/ui/elements/selector_picker_presentation_controller.mm

Issue 2125813002: Add custom UIPresentationController for picker selector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: name shortening Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698