OLD | NEW |
| (Empty) |
1 // Copyright 2017 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 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_container_coordinator.h
" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "base/memory/ptr_util.h" | |
10 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" | |
11 #import "ios/clean/chrome/browser/ui/animators/zoom_transition_animator.h" | |
12 #import "ios/clean/chrome/browser/ui/tab/tab_coordinator.h" | |
13 #import "ios/clean/chrome/browser/ui/tab_strip/tab_strip_container_view_controll
er.h" | |
14 #import "ios/shared/chrome/browser/coordinator_context/coordinator_context.h" | |
15 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" | |
16 | |
17 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
18 #error "This file requires ARC support." | |
19 #endif | |
20 | |
21 @interface TabStripContainerCoordinator ()< | |
22 UIViewControllerTransitioningDelegate> | |
23 @property(nonatomic, strong) TabStripContainerViewController* viewController; | |
24 @end | |
25 | |
26 @implementation TabStripContainerCoordinator | |
27 | |
28 @synthesize presentationKey = _presentationKey; | |
29 @synthesize viewController = _viewController; | |
30 @synthesize webState = _webState; | |
31 | |
32 - (void)start { | |
33 self.viewController = [[TabStripContainerViewController alloc] init]; | |
34 self.viewController.transitioningDelegate = self; | |
35 self.viewController.modalPresentationStyle = UIModalPresentationCustom; | |
36 | |
37 TabCoordinator* tabCoordinator = [[TabCoordinator alloc] init]; | |
38 tabCoordinator.webState = self.webState; | |
39 [self addChildCoordinator:tabCoordinator]; | |
40 // Unset the base view controller, so |tabCoordinator| doesn't present | |
41 // its view controller. | |
42 tabCoordinator.context.baseViewController = nil; | |
43 [tabCoordinator start]; | |
44 | |
45 // PLACEHOLDER: Replace this placeholder with an actual tab strip view | |
46 // controller. | |
47 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; | |
48 [button addTarget:nil | |
49 action:@selector(showTabGrid:) | |
50 forControlEvents:UIControlEventTouchUpInside]; | |
51 [button setTitle:@"Tab grid" forState:UIControlStateNormal]; | |
52 button.frame = CGRectMake(10, 10, 100, 100); | |
53 | |
54 UIViewController* tabStripViewController = [[UIViewController alloc] init]; | |
55 tabStripViewController.view.backgroundColor = [UIColor blackColor]; | |
56 [tabStripViewController.view addSubview:button]; | |
57 self.viewController.tabStripViewController = tabStripViewController; | |
58 self.viewController.contentViewController = tabCoordinator.viewController; | |
59 | |
60 [self.context.baseViewController presentViewController:self.viewController | |
61 animated:self.context.animated | |
62 completion:nil]; | |
63 [super start]; | |
64 } | |
65 | |
66 - (void)stop { | |
67 [super stop]; | |
68 [self.viewController.presentingViewController | |
69 dismissViewControllerAnimated:self.context.animated | |
70 completion:nil]; | |
71 self.viewController = nil; | |
72 } | |
73 | |
74 - (BOOL)canAddOverlayCoordinator:(BrowserCoordinator*)overlayCoordinator { | |
75 // This coordinator will always accept overlay coordinators. | |
76 return YES; | |
77 } | |
78 | |
79 #pragma mark - UIViewControllerTransitioningDelegate | |
80 | |
81 - (id<UIViewControllerAnimatedTransitioning>) | |
82 animationControllerForPresentedController:(UIViewController*)presented | |
83 presentingController:(UIViewController*)presenting | |
84 sourceController:(UIViewController*)source { | |
85 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | |
86 animator.presenting = YES; | |
87 animator.presentationKey = self.presentationKey; | |
88 [animator selectDelegate:@[ source, presenting ]]; | |
89 return animator; | |
90 } | |
91 | |
92 - (id<UIViewControllerAnimatedTransitioning>) | |
93 animationControllerForDismissedController:(UIViewController*)dismissed { | |
94 ZoomTransitionAnimator* animator = [[ZoomTransitionAnimator alloc] init]; | |
95 animator.presenting = NO; | |
96 animator.presentationKey = self.presentationKey; | |
97 [animator selectDelegate:@[ dismissed.presentingViewController ]]; | |
98 return animator; | |
99 } | |
100 | |
101 @end | |
OLD | NEW |