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

Side by Side Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.mm

Issue 2810603002: [ios clean] Adds ToolsMenu to TabGrid (Closed)
Patch Set: CL Feedback 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
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/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h" 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h"
6 6
7 #import "base/mac/foundation_util.h"
7 #import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h" 8 #import "ios/clean/chrome/browser/ui/tab_grid/ui_stack_view+cr_tab_grid.h"
8 9
9 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support." 11 #error "This file requires ARC support."
11 #endif 12 #endif
12 13
13 namespace { 14 namespace {
14 const CGFloat kToolbarHeight = 44.0f; 15 const CGFloat kToolbarHeight = 44.0f;
15 } 16 }
16 17
18 @interface TabGridToolbar ()
19 @property(nonatomic, weak) UIStackView* toolbarContent;
20 @end
21
17 @implementation TabGridToolbar 22 @implementation TabGridToolbar
18 23
24 @synthesize toolbarContent = _toolbarContent;
25
19 - (instancetype)init { 26 - (instancetype)init {
20 if (self = [super init]) { 27 if (self = [super init]) {
21 UIVisualEffect* blurEffect = 28 UIVisualEffect* blurEffect =
22 [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 29 [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
23 UIVisualEffectView* toolbarView = 30 UIVisualEffectView* toolbarView =
24 [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 31 [[UIVisualEffectView alloc] initWithEffect:blurEffect];
25 toolbarView.autoresizingMask = 32 toolbarView.autoresizingMask =
26 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 33 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
27 [self addSubview:toolbarView]; 34 [self addSubview:toolbarView];
28 35
29 UIStackView* toolbarContent = [UIStackView cr_tabGridToolbarStackView]; 36 _toolbarContent = [UIStackView cr_tabGridToolbarStackView];
edchin 2017/04/12 09:13:37 The ivar is a weak reference so this will not reta
sczs 2017/04/12 15:44:59 Done.
30 [toolbarView.contentView addSubview:toolbarContent]; 37 [toolbarView.contentView addSubview:_toolbarContent];
31 38
32 // Sets the stackview to a fixed height, anchored to the bottom of the 39 // Sets the stackview to a fixed height, anchored to the bottom of the
33 // blur view. 40 // blur view.
34 toolbarContent.translatesAutoresizingMaskIntoConstraints = NO; 41 _toolbarContent.translatesAutoresizingMaskIntoConstraints = NO;
35 [NSLayoutConstraint activateConstraints:@[ 42 [NSLayoutConstraint activateConstraints:@[
36 [toolbarContent.heightAnchor constraintEqualToConstant:kToolbarHeight], 43 [_toolbarContent.heightAnchor constraintEqualToConstant:kToolbarHeight],
37 [toolbarContent.leadingAnchor 44 [_toolbarContent.leadingAnchor
38 constraintEqualToAnchor:toolbarView.contentView.leadingAnchor], 45 constraintEqualToAnchor:toolbarView.contentView.leadingAnchor],
39 [toolbarContent.trailingAnchor 46 [_toolbarContent.trailingAnchor
40 constraintEqualToAnchor:toolbarView.contentView.trailingAnchor], 47 constraintEqualToAnchor:toolbarView.contentView.trailingAnchor],
41 [toolbarContent.bottomAnchor 48 [_toolbarContent.bottomAnchor
42 constraintEqualToAnchor:toolbarView.contentView.bottomAnchor] 49 constraintEqualToAnchor:toolbarView.contentView.bottomAnchor]
43 ]]; 50 ]];
44 } 51 }
45 return self; 52 return self;
46 } 53 }
47 54
55 #pragma mark - ZoomTransitionDelegate
56
57 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
58 UIButton* menuButton = base::mac::ObjCCastStrict<UIButton>(
59 [self.toolbarContent.arrangedSubviews lastObject]);
edchin 2017/04/12 09:13:37 arrangedSubviews is already an array of UIViews. Y
sczs 2017/04/12 15:44:59 Done.
60 CGRect rect = [view convertRect:menuButton.bounds fromView:menuButton];
61 return rect;
edchin 2017/04/12 09:13:37 nit: Use single line instead of two. return [view
sczs 2017/04/12 15:44:59 Done.
62 }
63
48 #pragma mark - UIView 64 #pragma mark - UIView
49 65
50 // Returns an intrinsic height so that explicit height constraints are 66 // Returns an intrinsic height so that explicit height constraints are
51 // not necessary. Status bar conditional logic can be set using this 67 // not necessary. Status bar conditional logic can be set using this
52 // intrinsic size. 68 // intrinsic size.
53 - (CGSize)intrinsicContentSize { 69 - (CGSize)intrinsicContentSize {
54 return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight); 70 return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight);
55 } 71 }
56 72
57 @end 73 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698