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

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: 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
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)viewWillLayoutSubviews {
100 // We need to dismiss the ToolsMenu everytime the Toolbar position changes
101 // (e.g. Size changes, rotation changes, etc.)
102 [self.dispatcher closeToolsMenu];
marq (ping after 24h) 2017/05/09 12:13:26 I'm pretty sure this isn't what we want. What if s
sczs 2017/05/10 02:25:46 Completely right, thanks for pointing this out. I
103 }
104
97 #pragma mark - Components Setup 105 #pragma mark - Components Setup
98 106
99 - (void)setUpToolbarButtons { 107 - (void)setUpToolbarButtons {
100 // Back button. 108 // Back button.
101 self.backButton = [ToolbarButton backToolbarButton]; 109 self.backButton = [ToolbarButton backToolbarButton];
102 self.backButton.visibilityMask = ToolbarComponentVisibilityCompactWidth | 110 self.backButton.visibilityMask = ToolbarComponentVisibilityCompactWidth |
103 ToolbarComponentVisibilityRegularWidth; 111 ToolbarComponentVisibilityRegularWidth;
104 [self.backButton addTarget:self 112 [self.backButton addTarget:self
105 action:@selector(goBack:) 113 action:@selector(goBack:)
106 forControlEvents:UIControlEventTouchUpInside]; 114 forControlEvents:UIControlEventTouchUpInside];
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 - (void)updateAllButtonsVisibility { 315 - (void)updateAllButtonsVisibility {
308 for (UIView* view in self.stackView.arrangedSubviews) { 316 for (UIView* view in self.stackView.arrangedSubviews) {
309 if ([view isKindOfClass:[ToolbarButton class]]) { 317 if ([view isKindOfClass:[ToolbarButton class]]) {
310 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view); 318 ToolbarButton* button = base::mac::ObjCCastStrict<ToolbarButton>(view);
311 [button setHiddenForCurrentStateAndSizeClass]; 319 [button setHiddenForCurrentStateAndSizeClass];
312 } 320 }
313 } 321 }
314 } 322 }
315 323
316 @end 324 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698