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/clean/chrome/browser/ui/tools/tools_coordinator.h" | 5 #import "ios/clean/chrome/browser/ui/tools/tools_coordinator.h" |
6 | 6 |
7 #import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h" | |
8 #import "ios/clean/chrome/browser/ui/presenters/menu_presentation_controller.h" | |
9 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" | 7 #import "ios/clean/chrome/browser/ui/tools/menu_view_controller.h" |
10 #import "ios/clean/chrome/browser/ui/tools/tools_mediator.h" | 8 #import "ios/clean/chrome/browser/ui/tools/tools_mediator.h" |
| 9 #import "ios/clean/chrome/browser/ui/tools/tools_menu_transition_controller.h" |
11 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 10 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
12 | 11 |
13 #if !defined(__has_feature) || !__has_feature(objc_arc) | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
14 #error "This file requires ARC support." | 13 #error "This file requires ARC support." |
15 #endif | 14 #endif |
16 | 15 |
17 @interface ToolsCoordinator ()<UIViewControllerTransitioningDelegate> | 16 @interface ToolsCoordinator () |
| 17 @property(nonatomic, strong) ToolsMediator* mediator; |
| 18 @property(nonatomic, strong) |
| 19 ToolsMenuTransitionController* transitionController; |
18 @property(nonatomic, strong) MenuViewController* viewController; | 20 @property(nonatomic, strong) MenuViewController* viewController; |
19 @property(nonatomic, strong) ToolsMediator* mediator; | |
20 @end | 21 @end |
21 | 22 |
22 @implementation ToolsCoordinator | 23 @implementation ToolsCoordinator |
| 24 @synthesize mediator = _mediator; |
| 25 @synthesize transitionController = _transitionController; |
| 26 @synthesize toolsMenuConfiguration = _toolsMenuConfiguration; |
23 @synthesize viewController = _viewController; | 27 @synthesize viewController = _viewController; |
24 @synthesize mediator = _mediator; | |
25 @synthesize toolsMenuConfiguration = _toolsMenuConfiguration; | |
26 @synthesize webState = _webState; | 28 @synthesize webState = _webState; |
27 | 29 |
28 #pragma mark - BrowserCoordinator | 30 #pragma mark - BrowserCoordinator |
29 | 31 |
30 - (void)start { | 32 - (void)start { |
31 self.viewController = [[MenuViewController alloc] init]; | 33 self.viewController = [[MenuViewController alloc] init]; |
32 self.viewController.modalPresentationStyle = UIModalPresentationCustom; | 34 self.viewController.modalPresentationStyle = UIModalPresentationCustom; |
33 self.viewController.transitioningDelegate = self; | 35 self.transitionController = [[ToolsMenuTransitionController alloc] |
| 36 initWithDispatcher:static_cast<id>(self.browser->dispatcher())]; |
| 37 self.viewController.transitioningDelegate = self.transitionController; |
34 self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); | 38 self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); |
35 self.mediator = | 39 self.mediator = |
36 [[ToolsMediator alloc] initWithConsumer:self.viewController | 40 [[ToolsMediator alloc] initWithConsumer:self.viewController |
37 configuration:self.toolsMenuConfiguration]; | 41 configuration:self.toolsMenuConfiguration]; |
38 if (self.webState) { | 42 if (self.webState) { |
39 self.mediator.webState = self.webState; | 43 self.mediator.webState = self.webState; |
40 } | 44 } |
41 [super start]; | 45 [super start]; |
42 } | 46 } |
43 | 47 |
44 #pragma mark - Setters | 48 #pragma mark - Setters |
45 | 49 |
46 - (void)setWebState:(web::WebState*)webState { | 50 - (void)setWebState:(web::WebState*)webState { |
47 _webState = webState; | 51 _webState = webState; |
48 if (self.mediator) { | 52 if (self.mediator) { |
49 self.mediator.webState = self.webState; | 53 self.mediator.webState = self.webState; |
50 } | 54 } |
51 } | 55 } |
52 | 56 |
53 #pragma mark - UIViewControllerTransitioningDelegate | |
54 | |
55 - (id<UIViewControllerAnimatedTransitioning>) | |
56 animationControllerForPresentedController:(UIViewController*)presented | |
57 presentingController:(UIViewController*)presenting | |
58 sourceController:(UIViewController*)source { | |
59 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | |
60 animator.presenting = YES; | |
61 [animator selectDelegate:@[ source, presenting ]]; | |
62 return animator; | |
63 } | |
64 | |
65 - (id<UIViewControllerAnimatedTransitioning>) | |
66 animationControllerForDismissedController:(UIViewController*)dismissed { | |
67 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | |
68 animator.presenting = NO; | |
69 [animator selectDelegate:@[ dismissed.presentingViewController ]]; | |
70 return animator; | |
71 } | |
72 | |
73 - (UIPresentationController*) | |
74 presentationControllerForPresentedViewController:(UIViewController*)presented | |
75 presentingViewController:(UIViewController*)presenting | |
76 sourceViewController:(UIViewController*)source { | |
77 MenuPresentationController* menuPresentation = | |
78 [[MenuPresentationController alloc] | |
79 initWithPresentedViewController:presented | |
80 presentingViewController:presenting]; | |
81 menuPresentation.dispatcher = static_cast<id>(self.browser->dispatcher()); | |
82 return menuPresentation; | |
83 } | |
84 | |
85 @end | 57 @end |
OLD | NEW |