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

Side by Side Diff: ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm

Issue 2869903002: [ios clean] Dismisses ToolsMenu on Layout changes. (Closed)
Patch Set: Uses viewWillTransitionToSize Created 3 years, 7 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/tab_grid/tab_grid_view_controller.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 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/toolbar/toolbar_view_controller.h" 5 #import "ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.h"
6 6
7 #import "base/mac/foundation_util.h" 7 #import "base/mac/foundation_util.h"
8 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h" 8 #import "ios/clean/chrome/browser/ui/actions/tab_strip_actions.h"
9 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h" 9 #import "ios/clean/chrome/browser/ui/commands/navigation_commands.h"
10 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" 10 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 - (instancetype)init { 53 - (instancetype)init {
54 self = [super init]; 54 self = [super init];
55 if (self) { 55 if (self) {
56 [self setUpToolbarButtons]; 56 [self setUpToolbarButtons];
57 [self setUpLocationBarContainer]; 57 [self setUpLocationBarContainer];
58 } 58 }
59 return self; 59 return self;
60 } 60 }
61 61
62 #pragma mark - View lifecyle
63
62 - (void)viewDidLoad { 64 - (void)viewDidLoad {
63 self.view.backgroundColor = [UIColor lightGrayColor]; 65 self.view.backgroundColor = [UIColor lightGrayColor];
64 66
65 [self addChildViewController:self.locationBarViewController 67 [self addChildViewController:self.locationBarViewController
66 toSubview:self.locationBarContainer]; 68 toSubview:self.locationBarContainer];
67 69
68 // Stack view to contain toolbar items. 70 // Stack view to contain toolbar items.
69 self.stackView = [[UIStackView alloc] initWithArrangedSubviews:@[ 71 self.stackView = [[UIStackView alloc] initWithArrangedSubviews:@[
70 self.backButton, self.forwardButton, self.reloadButton, self.stopButton, 72 self.backButton, self.forwardButton, self.reloadButton, self.stopButton,
71 self.locationBarContainer, self.shareButton, self.tabSwitchStripButton, 73 self.locationBarContainer, self.shareButton, self.tabSwitchStripButton,
(...skipping 15 matching lines...) Expand all
87 constant:-kVerticalMargin], 89 constant:-kVerticalMargin],
88 [self.stackView.leadingAnchor 90 [self.stackView.leadingAnchor
89 constraintEqualToAnchor:self.view.leadingAnchor 91 constraintEqualToAnchor:self.view.leadingAnchor
90 constant:kHorizontalMargin], 92 constant:kHorizontalMargin],
91 [self.stackView.trailingAnchor 93 [self.stackView.trailingAnchor
92 constraintEqualToAnchor:self.view.trailingAnchor 94 constraintEqualToAnchor:self.view.trailingAnchor
93 constant:-kHorizontalMargin], 95 constant:-kHorizontalMargin],
94 ]]; 96 ]];
95 } 97 }
96 98
99 - (void)viewWillTransitionToSize:(CGSize)size
100 withTransitionCoordinator:
101 (id<UIViewControllerTransitionCoordinator>)coordinator {
102 // We need to dismiss the ToolsMenu everytime the Toolbar frame changes
103 // (e.g. Size changes, rotation changes, etc.)
104 [self.dispatcher closeToolsMenu];
105 }
106
97 #pragma mark - Components Setup 107 #pragma mark - Components Setup
98 108
99 - (void)setUpToolbarButtons { 109 - (void)setUpToolbarButtons {
100 // Back button. 110 // Back button.
101 self.backButton = [ToolbarButton backToolbarButton]; 111 self.backButton = [ToolbarButton backToolbarButton];
102 self.backButton.visibilityMask = ToolbarComponentVisibilityCompactWidth | 112 self.backButton.visibilityMask = ToolbarComponentVisibilityCompactWidth |
103 ToolbarComponentVisibilityRegularWidth; 113 ToolbarComponentVisibilityRegularWidth;
104 [self.backButton addTarget:self 114 [self.backButton addTarget:self
105 action:@selector(goBack:) 115 action:@selector(goBack:)
106 forControlEvents:UIControlEventTouchUpInside]; 116 forControlEvents:UIControlEventTouchUpInside];
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 - (void)updateAllButtonsVisibility { 317 - (void)updateAllButtonsVisibility {
308 for (UIView* view in self.stackView.arrangedSubviews) { 318 for (UIView* view in self.stackView.arrangedSubviews) {
309 if ([view isKindOfClass:[ToolbarButton class]]) { 319 if ([view isKindOfClass:[ToolbarButton class]]) {
310 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view); 320 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view);
311 [button setHiddenForCurrentStateAndSizeClass]; 321 [button setHiddenForCurrentStateAndSizeClass];
312 } 322 }
313 } 323 }
314 } 324 }
315 325
316 @end 326 @end
OLDNEW
« no previous file with comments | « ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698