| 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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ | 7 // ============================================================================ |
| 8 | 8 |
| 9 #import "ios/clean/chrome/browser/ui/presenters/menu_presentation_controller.h" | 9 #import "ios/clean/chrome/browser/ui/presenters/menu_presentation_controller.h" |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 self.presentationFrame.size = menuSize; | 43 self.presentationFrame.size = menuSize; |
| 44 self.presentationFrame.origin = CGPointMake( | 44 self.presentationFrame.origin = CGPointMake( |
| 45 (self.containerView.bounds.size.width - menuSize.width) / 2.0, | 45 (self.containerView.bounds.size.width - menuSize.width) / 2.0, |
| 46 (self.containerView.bounds.size.height - menuSize.height) / 2.0); | 46 (self.containerView.bounds.size.height - menuSize.height) / 2.0); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 return self.presentationFrame; | 49 return self.presentationFrame; |
| 50 } | 50 } |
| 51 | 51 |
| 52 - (void)presentationTransitionWillBegin { | 52 - (void)presentationTransitionWillBegin { |
| 53 self.presentedView.layer.borderWidth = 1.0; | 53 self.presentedView.layer.shadowRadius = 5.0f; |
| 54 self.presentedView.layer.shadowRadius = 1.0; | 54 self.presentedView.layer.shadowOpacity = 0.4f; |
| 55 self.presentedView.layer.borderColor = [UIColor blackColor].CGColor; | 55 self.presentedView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); |
| 56 self.presentedView.layer.cornerRadius = 2.0f; |
| 56 | 57 |
| 57 self.dismissRecognizer = | 58 self.dismissRecognizer = |
| 58 [[UITapGestureRecognizer alloc] initWithTarget:self | 59 [[UITapGestureRecognizer alloc] initWithTarget:self |
| 59 action:@selector(tapToDismiss:)]; | 60 action:@selector(tapToDismiss:)]; |
| 60 [self.containerView addGestureRecognizer:self.dismissRecognizer]; | 61 [self.containerView addGestureRecognizer:self.dismissRecognizer]; |
| 61 } | 62 } |
| 62 | 63 |
| 63 #pragma mark - Private methods. | 64 #pragma mark - Private methods. |
| 64 | 65 |
| 65 - (void)tapToDismiss:(UIGestureRecognizer*)recognizer { | 66 - (void)tapToDismiss:(UIGestureRecognizer*)recognizer { |
| 66 [self.toolbarCommandHandler closeToolsMenu]; | 67 [self.toolbarCommandHandler closeToolsMenu]; |
| 67 } | 68 } |
| 68 | 69 |
| 69 // Checks if the presenting view controller conforms to | 70 // Checks if the presenting view controller conforms to |
| 70 // MenuPresentationDelegate and, if so, sets that view controller as the | 71 // MenuPresentationDelegate and, if so, sets that view controller as the |
| 71 // presentation delegate. This can't be done at init time, becuase the | 72 // presentation delegate. This can't be done at init time, becuase the |
| 72 // presenting view controller may not have been determined by UIKit yet. | 73 // presenting view controller may not have been determined by UIKit yet. |
| 73 - (void)updatePresentationDelegate { | 74 - (void)updatePresentationDelegate { |
| 74 if ([self.presentingViewController | 75 if ([self.presentingViewController |
| 75 conformsToProtocol:@protocol(MenuPresentationDelegate)]) { | 76 conformsToProtocol:@protocol(MenuPresentationDelegate)]) { |
| 76 self.presentationDelegate = static_cast<id<MenuPresentationDelegate>>( | 77 self.presentationDelegate = static_cast<id<MenuPresentationDelegate>>( |
| 77 self.presentingViewController); | 78 self.presentingViewController); |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 81 @end | 82 @end |
| OLD | NEW |