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

Side by Side Diff: ios/showcase/toolbar/sc_toolbar_coordinator.mm

Issue 2785213003: [ios] Use dispatcher for ToolsMenu commands. (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « ios/clean/chrome/browser/ui/tools/tools_coordinator.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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/showcase/toolbar/sc_toolbar_coordinator.h" 5 #import "ios/showcase/toolbar/sc_toolbar_coordinator.h"
6 6
7 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" 7 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
8 #import "ios/clean/chrome/browser/ui/commands/toolbar_commands.h" 8 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h" 9 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h"
10 #import "ios/showcase/common/protocol_alerter.h" 10 #import "ios/showcase/common/protocol_alerter.h"
11 11
12 #if !defined(__has_feature) || !__has_feature(objc_arc) 12 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support." 13 #error "This file requires ARC support."
14 #endif 14 #endif
15 15
16 namespace { 16 namespace {
17 // Toolbar height. 17 // Toolbar height.
18 CGFloat kToolbarHeight = 50.0f; 18 CGFloat kToolbarHeight = 50.0f;
19 } // namespace 19 } // namespace
20 20
21 @interface SCToolbarCoordinator () 21 @interface SCToolbarCoordinator ()
22 @property(nonatomic, strong) ProtocolAlerter* alerter; 22 @property(nonatomic, strong) ProtocolAlerter* alerter;
23 @end 23 @end
24 24
25 @implementation SCToolbarCoordinator 25 @implementation SCToolbarCoordinator
26 @synthesize baseViewController = _baseViewController; 26 @synthesize baseViewController = _baseViewController;
27 @synthesize alerter = _alerter; 27 @synthesize alerter = _alerter;
28 28
29 - (void)start { 29 - (void)start {
30 self.alerter = [[ProtocolAlerter alloc] initWithProtocols:@[ 30 self.alerter = [[ProtocolAlerter alloc] initWithProtocols:@[
31 @protocol(ToolbarCommands), @protocol(NavigationCommands) 31 @protocol(ToolsMenuCommands), @protocol(NavigationCommands)
32 ]]; 32 ]];
33 self.alerter.baseViewController = self.baseViewController; 33 self.alerter.baseViewController = self.baseViewController;
34 34
35 UIViewController* containerViewController = [[UIViewController alloc] init]; 35 UIViewController* containerViewController = [[UIViewController alloc] init];
36 containerViewController.view.backgroundColor = [UIColor whiteColor]; 36 containerViewController.view.backgroundColor = [UIColor whiteColor];
37 containerViewController.title = @"Toolbar"; 37 containerViewController.title = @"Toolbar";
38 38
39 UIView* containerView = [[UIView alloc] init]; 39 UIView* containerView = [[UIView alloc] init];
40 [containerViewController.view addSubview:containerView]; 40 [containerViewController.view addSubview:containerView];
41 containerView.backgroundColor = [UIColor redColor]; 41 containerView.backgroundColor = [UIColor redColor];
42 containerView.translatesAutoresizingMaskIntoConstraints = NO; 42 containerView.translatesAutoresizingMaskIntoConstraints = NO;
43 43
44 ToolbarViewController* toolbarViewController = 44 ToolbarViewController* toolbarViewController =
45 [[ToolbarViewController alloc] init]; 45 [[ToolbarViewController alloc] init];
46 toolbarViewController.dispatcher = 46 toolbarViewController.dispatcher =
47 static_cast<id<ToolbarCommands, NavigationCommands>>(self.alerter); 47 static_cast<id<ToolsMenuCommands, NavigationCommands>>(self.alerter);
48 [containerViewController addChildViewController:toolbarViewController]; 48 [containerViewController addChildViewController:toolbarViewController];
49 toolbarViewController.view.frame = containerView.frame; 49 toolbarViewController.view.frame = containerView.frame;
50 [containerView addSubview:toolbarViewController.view]; 50 [containerView addSubview:toolbarViewController.view];
51 [toolbarViewController didMoveToParentViewController:containerViewController]; 51 [toolbarViewController didMoveToParentViewController:containerViewController];
52 52
53 [NSLayoutConstraint activateConstraints:@[ 53 [NSLayoutConstraint activateConstraints:@[
54 [containerView.heightAnchor constraintEqualToConstant:kToolbarHeight], 54 [containerView.heightAnchor constraintEqualToConstant:kToolbarHeight],
55 [containerView.leadingAnchor 55 [containerView.leadingAnchor
56 constraintEqualToAnchor:containerViewController.view.leadingAnchor], 56 constraintEqualToAnchor:containerViewController.view.leadingAnchor],
57 [containerView.trailingAnchor 57 [containerView.trailingAnchor
58 constraintEqualToAnchor:containerViewController.view.trailingAnchor], 58 constraintEqualToAnchor:containerViewController.view.trailingAnchor],
59 [containerView.centerYAnchor 59 [containerView.centerYAnchor
60 constraintEqualToAnchor:containerViewController.view.centerYAnchor], 60 constraintEqualToAnchor:containerViewController.view.centerYAnchor],
61 ]]; 61 ]];
62 62
63 [self.baseViewController pushViewController:containerViewController 63 [self.baseViewController pushViewController:containerViewController
64 animated:YES]; 64 animated:YES];
65 } 65 }
66 66
67 @end 67 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tools/tools_coordinator.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698