Commit a504f941 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Clean up tab grid toolbars

Removes dead and unnecessary code.

Bug: 818198
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I468a5018ec794b4c921f569362d37f1da3d1d6a5
Reviewed-on: https://chromium-review.googlesource.com/963319Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543253}
parent 492b6c2f
......@@ -7,25 +7,15 @@
#import <UIKit/UIKit.h>
// Pre-set color configurations.
typedef NS_ENUM(NSUInteger, TabGridBottomToolbarTheme) {
TabGridBottomToolbarThemeInvalid = 0,
TabGridBottomToolbarThemeWhiteRoundButton,
TabGridBottomToolbarThemeBlueRoundButton,
TabGridBottomToolbarThemePartiallyDisabled,
};
// Toolbar view with two text buttons and a center round button. The contents
// have a fixed height and are pinned to the top of this view, therefore it is
// intended to be used as a bottom toolbar.
// Toolbar view with three buttons. The contents have a fixed height and are
// pinned to the top of this view, therefore it is intended to be used as a
// bottom toolbar.
@interface TabGridBottomToolbar : UIView
// The color configuration of the toolbar.
@property(nonatomic, assign) TabGridBottomToolbarTheme theme;
// These components are publicly available to allow the user to set their
// contents, visibility and actions.
@property(nonatomic, weak, readonly) UIButton* leadingButton;
@property(nonatomic, weak, readonly) UIButton* trailingButton;
@property(nonatomic, weak, readonly) UIButton* roundButton;
@property(nonatomic, weak, readonly) UIButton* centerButton;
- (instancetype)init NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
......
......@@ -13,15 +13,12 @@
namespace {
// Height of the toolbar.
const CGFloat kToolbarHeight = 44.0f;
// Diameter of the center round button.
const CGFloat kRoundButtonDiameter = 44.0f;
} // namespace
@implementation TabGridBottomToolbar
@synthesize theme = _theme;
@synthesize leadingButton = _leadingButton;
@synthesize trailingButton = _trailingButton;
@synthesize roundButton = _roundButton;
@synthesize centerButton = _centerButton;
- (instancetype)init {
if (self = [super initWithFrame:CGRectZero]) {
......@@ -34,25 +31,17 @@ const CGFloat kRoundButtonDiameter = 44.0f;
UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem];
leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
[leadingButton setTitle:@"Button" forState:UIControlStateNormal];
UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem];
trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
[trailingButton setTitle:@"Button" forState:UIControlStateNormal];
UIButton* roundButton = [UIButton buttonWithType:UIButtonTypeSystem];
roundButton.translatesAutoresizingMaskIntoConstraints = NO;
[roundButton setTitle:@"Btn" forState:UIControlStateNormal];
roundButton.layer.cornerRadius = 22.f;
roundButton.layer.masksToBounds = YES;
UIButton* centerButton = [UIButton buttonWithType:UIButtonTypeSystem];
centerButton.translatesAutoresizingMaskIntoConstraints = NO;
[toolbar.contentView addSubview:leadingButton];
[toolbar.contentView addSubview:trailingButton];
[toolbar.contentView addSubview:roundButton];
[toolbar.contentView addSubview:centerButton];
_leadingButton = leadingButton;
_trailingButton = trailingButton;
_roundButton = roundButton;
_centerButton = centerButton;
NSArray* constraints = @[
[toolbar.topAnchor constraintEqualToAnchor:self.topAnchor],
......@@ -63,10 +52,9 @@ const CGFloat kRoundButtonDiameter = 44.0f;
[leadingButton.leadingAnchor
constraintEqualToAnchor:toolbar.layoutMarginsGuide.leadingAnchor],
[leadingButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor],
[roundButton.widthAnchor constraintEqualToConstant:kRoundButtonDiameter],
[roundButton.heightAnchor constraintEqualToConstant:kRoundButtonDiameter],
[roundButton.centerXAnchor constraintEqualToAnchor:toolbar.centerXAnchor],
[roundButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor],
[centerButton.centerXAnchor
constraintEqualToAnchor:toolbar.centerXAnchor],
[centerButton.topAnchor constraintEqualToAnchor:toolbar.topAnchor],
[trailingButton.heightAnchor constraintEqualToConstant:kToolbarHeight],
[trailingButton.trailingAnchor
constraintEqualToAnchor:toolbar.layoutMarginsGuide.trailingAnchor],
......@@ -81,42 +69,4 @@ const CGFloat kRoundButtonDiameter = 44.0f;
return CGSizeMake(UIViewNoIntrinsicMetric, kToolbarHeight);
}
#pragma mark - Public
- (void)setTheme:(TabGridBottomToolbarTheme)theme {
if (_theme == theme)
return;
switch (theme) {
case TabGridBottomToolbarThemeWhiteRoundButton:
self.trailingButton.enabled = YES;
self.roundButton.enabled = YES;
self.roundButton.backgroundColor = [UIColor whiteColor];
self.roundButton.tintColor = [UIColor blackColor];
self.leadingButton.tintColor = [UIColor whiteColor];
self.trailingButton.tintColor = [UIColor whiteColor];
break;
case TabGridBottomToolbarThemeBlueRoundButton:
self.trailingButton.enabled = YES;
self.roundButton.enabled = YES;
self.roundButton.backgroundColor =
[UIColor colorWithRed:0.0 green:122.0 / 255.0 blue:1.0 alpha:1.0];
self.roundButton.tintColor = [UIColor whiteColor];
self.leadingButton.tintColor = [UIColor whiteColor];
self.trailingButton.tintColor = [UIColor whiteColor];
break;
case TabGridBottomToolbarThemePartiallyDisabled:
self.trailingButton.enabled = NO;
self.roundButton.enabled = NO;
self.roundButton.backgroundColor = [UIColor grayColor];
self.roundButton.tintColor = [UIColor blackColor];
self.leadingButton.tintColor = [UIColor whiteColor];
self.trailingButton.tintColor = [UIColor whiteColor];
break;
default:
NOTREACHED() << "Invalid theme for TabGridBottomToolbar.";
break;
}
_theme = theme;
}
@end
......@@ -33,7 +33,6 @@ const CGFloat kSegmentedControlHeight = 30.0f;
UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem];
leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
leadingButton.tintColor = [UIColor whiteColor];
[leadingButton setTitle:@"Button" forState:UIControlStateNormal];
UILabel* segmentedControl = [[UILabel alloc] init];
segmentedControl.translatesAutoresizingMaskIntoConstraints = NO;
......@@ -45,7 +44,6 @@ const CGFloat kSegmentedControlHeight = 30.0f;
UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem];
trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
trailingButton.tintColor = [UIColor whiteColor];
[trailingButton setTitle:@"Button" forState:UIControlStateNormal];
[toolbar.contentView addSubview:leadingButton];
[toolbar.contentView addSubview:trailingButton];
......
......@@ -495,7 +495,7 @@ typedef NS_ENUM(NSUInteger, TabGridConfiguration) {
self.floatingButton.hidden = YES;
self.doneButton = self.bottomToolbar.leadingButton;
self.closeAllButton = self.bottomToolbar.trailingButton;
self.newTabButton = self.bottomToolbar.roundButton;
self.newTabButton = self.bottomToolbar.centerButton;
break;
case TabGridConfigurationFloatingButton:
self.topToolbar.leadingButton.hidden = NO;
......
......@@ -19,22 +19,18 @@
TabGridTopToolbar* topToolbar = [[TabGridTopToolbar alloc] init];
topToolbar.translatesAutoresizingMaskIntoConstraints = NO;
[topToolbar.leadingButton setTitle:@"Leading" forState:UIControlStateNormal];
[topToolbar.trailingButton setTitle:@"Trailing"
forState:UIControlStateNormal];
[self.view addSubview:topToolbar];
TabGridBottomToolbar* bottomToolbar1 = [[TabGridBottomToolbar alloc] init];
bottomToolbar1.translatesAutoresizingMaskIntoConstraints = NO;
bottomToolbar1.theme = TabGridBottomToolbarThemeWhiteRoundButton;
[self.view addSubview:bottomToolbar1];
TabGridBottomToolbar* bottomToolbar2 = [[TabGridBottomToolbar alloc] init];
bottomToolbar2.translatesAutoresizingMaskIntoConstraints = NO;
bottomToolbar2.theme = TabGridBottomToolbarThemeBlueRoundButton;
[self.view addSubview:bottomToolbar2];
TabGridBottomToolbar* bottomToolbar3 = [[TabGridBottomToolbar alloc] init];
bottomToolbar3.translatesAutoresizingMaskIntoConstraints = NO;
bottomToolbar3.theme = TabGridBottomToolbarThemePartiallyDisabled;
[self.view addSubview:bottomToolbar3];
TabGridBottomToolbar* bottomToolbar = [[TabGridBottomToolbar alloc] init];
bottomToolbar.translatesAutoresizingMaskIntoConstraints = NO;
[bottomToolbar.leadingButton setTitle:@"Leading"
forState:UIControlStateNormal];
[bottomToolbar.trailingButton setTitle:@"Trailing"
forState:UIControlStateNormal];
[self.view addSubview:bottomToolbar];
NSArray* constraints = @[
[topToolbar.topAnchor constraintEqualToAnchor:self.view.topAnchor
......@@ -44,32 +40,14 @@
constraintEqualToAnchor:self.view.trailingAnchor],
[topToolbar.heightAnchor
constraintEqualToConstant:topToolbar.intrinsicContentSize.height],
[bottomToolbar1.topAnchor constraintEqualToAnchor:topToolbar.bottomAnchor
constant:10.0f],
[bottomToolbar1.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
[bottomToolbar1.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[bottomToolbar1.heightAnchor
constraintEqualToConstant:bottomToolbar1.intrinsicContentSize.height],
[bottomToolbar2.topAnchor
constraintEqualToAnchor:bottomToolbar1.bottomAnchor
constant:10.0f],
[bottomToolbar2.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
[bottomToolbar2.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[bottomToolbar2.heightAnchor
constraintEqualToConstant:bottomToolbar2.intrinsicContentSize.height],
[bottomToolbar3.topAnchor
constraintEqualToAnchor:bottomToolbar2.bottomAnchor
constant:10.0f],
[bottomToolbar3.leadingAnchor
[bottomToolbar.topAnchor constraintEqualToAnchor:topToolbar.bottomAnchor
constant:10.0f],
[bottomToolbar.leadingAnchor
constraintEqualToAnchor:self.view.leadingAnchor],
[bottomToolbar3.trailingAnchor
[bottomToolbar.trailingAnchor
constraintEqualToAnchor:self.view.trailingAnchor],
[bottomToolbar3.heightAnchor
constraintEqualToConstant:bottomToolbar3.intrinsicContentSize.height],
[bottomToolbar.heightAnchor
constraintEqualToConstant:bottomToolbar.intrinsicContentSize.height],
];
[NSLayoutConstraint activateConstraints:constraints];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment