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

Side by Side Diff: ios/chrome/browser/ui/presenters/menu_presentation_controller.mm

Issue 2592983003: [Clean Skeleton] Migrate code to clean/ (Closed)
Patch Set: Rebased Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // ====== New Architecture =====
6 // = This code is only used in the new iOS Chrome architecture. =
7 // ============================================================================
8
9 #import "ios/chrome/browser/ui/presenters/menu_presentation_controller.h"
10
11 #import <QuartzCore/QuartzCore.h>
12
13 #include "ios/chrome/browser/ui/presenters/menu_presentation_delegate.h"
14
15 #if !defined(__has_feature) || !__has_feature(objc_arc)
16 #error "This file requires ARC support."
17 #endif
18
19 @interface MenuPresentationController ()
20 @property(nonatomic, weak) id<MenuPresentationDelegate> presentationDelegate;
21 @property(nonatomic, assign) CGRect presentationFrame;
22 @end
23
24 @implementation MenuPresentationController
25 @synthesize presentationDelegate = _presentationDelegate;
26 @synthesize presentationFrame = _presentationFrame;
27
28 #pragma mark - UIPresentationDelegate
29
30 - (CGRect)frameOfPresentedViewInContainerView {
31 if (CGRectIsEmpty(self.presentationFrame)) {
32 [self updatePresentationDelegate];
33 if (self.presentationDelegate) {
34 self.presentationFrame =
35 [self.presentationDelegate frameForMenuPresentation:self];
36 } else {
37 // Placeholder default frame: something rectangular, 50 points in and
38 // down.
39 self.presentationFrame = CGRectMake(50, 50, 250, 300);
40 }
41 }
42 return self.presentationFrame;
43 }
44
45 - (void)presentationTransitionWillBegin {
46 self.presentedView.layer.borderWidth = 1.0;
47 self.presentedView.layer.shadowRadius = 1.0;
48 self.presentedView.layer.borderColor = [UIColor blackColor].CGColor;
49 }
50
51 #pragma mark - Private methods.
52
53 // Checks if the presenting view controller conforms to
54 // MenuPresentationDelegate and, if so, sets that view controller as the
55 // presentation delegate. This can't be done at init time, becuase the
56 // presenting view controller may not have been determined by UIKit yet.
57 - (void)updatePresentationDelegate {
58 if ([self.presentingViewController
59 conformsToProtocol:@protocol(MenuPresentationDelegate)]) {
60 self.presentationDelegate = static_cast<id<MenuPresentationDelegate>>(
61 self.presentingViewController);
62 }
63 }
64
65 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698