Chromium Code Reviews| OLD | NEW |
|---|---|
| 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, strong) UIStackView* toolbarContent; | |
|
edchin
2017/04/10 05:50:57
Since this is added as a subview, it can be weak.
sczs
2017/04/11 18:47:59
Done.
| |
| 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 self.toolbarContent = [UIStackView cr_tabGridToolbarStackView]; |
| 30 [toolbarView.contentView addSubview:toolbarContent]; | 37 [toolbarView.contentView addSubview:self.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 self.toolbarContent.translatesAutoresizingMaskIntoConstraints = NO; |
|
edchin
2017/04/10 05:50:57
Use direct access in partially constructed states.
marq (ping after 24h)
2017/04/10 11:36:39
It's not explicitly defined, but it's a widely-acc
sczs
2017/04/11 18:47:59
Done.
| |
| 35 [NSLayoutConstraint activateConstraints:@[ | 42 [NSLayoutConstraint activateConstraints:@[ |
| 36 [toolbarContent.heightAnchor constraintEqualToConstant:kToolbarHeight], | 43 [self.toolbarContent.heightAnchor |
| 37 [toolbarContent.leadingAnchor | 44 constraintEqualToConstant:kToolbarHeight], |
| 45 [self.toolbarContent.leadingAnchor | |
| 38 constraintEqualToAnchor:toolbarView.contentView.leadingAnchor], | 46 constraintEqualToAnchor:toolbarView.contentView.leadingAnchor], |
| 39 [toolbarContent.trailingAnchor | 47 [self.toolbarContent.trailingAnchor |
| 40 constraintEqualToAnchor:toolbarView.contentView.trailingAnchor], | 48 constraintEqualToAnchor:toolbarView.contentView.trailingAnchor], |
| 41 [toolbarContent.bottomAnchor | 49 [self.toolbarContent.bottomAnchor |
| 42 constraintEqualToAnchor:toolbarView.contentView.bottomAnchor] | 50 constraintEqualToAnchor:toolbarView.contentView.bottomAnchor] |
| 43 ]]; | 51 ]]; |
| 44 } | 52 } |
| 45 return self; | 53 return self; |
| 46 } | 54 } |
| 47 | 55 |
| 56 #pragma mark - ZoomTransitionDelegate | |
| 57 | |
| 58 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { | |
| 59 UIButton* menuButton = base::mac::ObjCCastStrict<UIButton>( | |
| 60 [self.toolbarContent.arrangedSubviews lastObject]); | |
|
edchin
2017/04/10 05:50:57
Feel free to move the stackview construction and b
sczs
2017/04/11 18:47:59
Acknowledged.
| |
| 61 CGRect rect = [view convertRect:menuButton.bounds fromView:menuButton]; | |
| 62 return rect; | |
| 63 } | |
| 64 | |
| 48 #pragma mark - UIView | 65 #pragma mark - UIView |
| 49 | 66 |
| 50 // Returns an intrinsic height so that explicit height constraints are | 67 // Returns an intrinsic height so that explicit height constraints are |
| 51 // not necessary. Status bar conditional logic can be set using this | 68 // not necessary. Status bar conditional logic can be set using this |
| 52 // intrinsic size. | 69 // intrinsic size. |
| 53 - (CGSize)intrinsicContentSize { | 70 - (CGSize)intrinsicContentSize { |
| 54 return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight); | 71 return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight); |
| 55 } | 72 } |
| 56 | 73 |
| 57 @end | 74 @end |
| OLD | NEW |