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

[ios] Dynamic type in tab grid

Dynamic type is now used in the:
- grid cell title
- toolbar text buttons
- empty state texts

The dynamic type used in the grid cell title
and the empty state text do not adhere to spec
because they are not semi-bolded.

Bug: 819667
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ie8ccccc68ec783ce6277c1cb57a26ba5895de8fd
Reviewed-on: https://chromium-review.googlesource.com/963180
Commit-Queue: edchin <edchin@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543323}
parent 2464913f
...@@ -198,7 +198,8 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -198,7 +198,8 @@ const CGFloat kBorderWidth = 6.0f;
UILabel* titleLabel = [[UILabel alloc] init]; UILabel* titleLabel = [[UILabel alloc] init];
titleLabel.translatesAutoresizingMaskIntoConstraints = NO; titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
titleLabel.font = [UIFont boldSystemFontOfSize:12.0f]; titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
titleLabel.adjustsFontForContentSizeCategory = YES;
UIButton* closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton* closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.translatesAutoresizingMaskIntoConstraints = NO; closeButton.translatesAutoresizingMaskIntoConstraints = NO;
...@@ -233,9 +234,13 @@ const CGFloat kBorderWidth = 6.0f; ...@@ -233,9 +234,13 @@ const CGFloat kBorderWidth = 6.0f;
constant:-6.0f], constant:-6.0f],
]; ];
[NSLayoutConstraint activateConstraints:constraints]; [NSLayoutConstraint activateConstraints:constraints];
[titleLabel setContentHuggingPriority:UILayoutPriorityDefaultLow
forAxis:UILayoutConstraintAxisHorizontal];
[titleLabel [titleLabel
setContentCompressionResistancePriority:UILayoutPriorityDefaultLow setContentCompressionResistancePriority:UILayoutPriorityDefaultLow
forAxis:UILayoutConstraintAxisHorizontal]; forAxis:UILayoutConstraintAxisHorizontal];
[closeButton setContentHuggingPriority:UILayoutPriorityRequired
forAxis:UILayoutConstraintAxisHorizontal];
return topBar; return topBar;
} }
......
...@@ -31,8 +31,16 @@ const CGFloat kToolbarHeight = 44.0f; ...@@ -31,8 +31,16 @@ const CGFloat kToolbarHeight = 44.0f;
UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem];
leadingButton.translatesAutoresizingMaskIntoConstraints = NO; leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
leadingButton.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
leadingButton.titleLabel.adjustsFontForContentSizeCategory = YES;
leadingButton.tintColor = [UIColor whiteColor];
UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem];
trailingButton.translatesAutoresizingMaskIntoConstraints = NO; trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
trailingButton.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleBody];
trailingButton.titleLabel.adjustsFontForContentSizeCategory = YES;
trailingButton.tintColor = [UIColor whiteColor];
UIButton* centerButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* centerButton = [UIButton buttonWithType:UIButtonTypeSystem];
centerButton.translatesAutoresizingMaskIntoConstraints = NO; centerButton.translatesAutoresizingMaskIntoConstraints = NO;
......
...@@ -32,6 +32,9 @@ const CGFloat kSegmentedControlHeight = 30.0f; ...@@ -32,6 +32,9 @@ const CGFloat kSegmentedControlHeight = 30.0f;
UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* leadingButton = [UIButton buttonWithType:UIButtonTypeSystem];
leadingButton.translatesAutoresizingMaskIntoConstraints = NO; leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
leadingButton.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
leadingButton.titleLabel.adjustsFontForContentSizeCategory = YES;
leadingButton.tintColor = [UIColor whiteColor]; leadingButton.tintColor = [UIColor whiteColor];
UILabel* segmentedControl = [[UILabel alloc] init]; UILabel* segmentedControl = [[UILabel alloc] init];
...@@ -43,6 +46,9 @@ const CGFloat kSegmentedControlHeight = 30.0f; ...@@ -43,6 +46,9 @@ const CGFloat kSegmentedControlHeight = 30.0f;
UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem]; UIButton* trailingButton = [UIButton buttonWithType:UIButtonTypeSystem];
trailingButton.translatesAutoresizingMaskIntoConstraints = NO; trailingButton.translatesAutoresizingMaskIntoConstraints = NO;
trailingButton.titleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleBody];
trailingButton.titleLabel.adjustsFontForContentSizeCategory = YES;
trailingButton.tintColor = [UIColor whiteColor]; trailingButton.tintColor = [UIColor whiteColor];
[toolbar.contentView addSubview:leadingButton]; [toolbar.contentView addSubview:leadingButton];
......
...@@ -383,21 +383,29 @@ typedef NS_ENUM(NSUInteger, TabGridConfiguration) { ...@@ -383,21 +383,29 @@ typedef NS_ENUM(NSUInteger, TabGridConfiguration) {
topLabel.translatesAutoresizingMaskIntoConstraints = NO; topLabel.translatesAutoresizingMaskIntoConstraints = NO;
topLabel.text = topText; topLabel.text = topText;
topLabel.textColor = [UIColor whiteColor]; topLabel.textColor = [UIColor whiteColor];
topLabel.font = [UIFont boldSystemFontOfSize:20.0f]; topLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
topLabel.adjustsFontForContentSizeCategory = YES;
topLabel.numberOfLines = 0;
topLabel.textAlignment = NSTextAlignmentCenter;
[view addSubview:topLabel]; [view addSubview:topLabel];
UILabel* bottomLabel = [[UILabel alloc] init]; UILabel* bottomLabel = [[UILabel alloc] init];
bottomLabel.translatesAutoresizingMaskIntoConstraints = NO; bottomLabel.translatesAutoresizingMaskIntoConstraints = NO;
bottomLabel.text = bottomText; bottomLabel.text = bottomText;
bottomLabel.textColor = [UIColor whiteColor]; bottomLabel.textColor = [UIColor whiteColor];
bottomLabel.font = [UIFont systemFontOfSize:18.0f]; bottomLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
bottomLabel.adjustsFontForContentSizeCategory = YES;
bottomLabel.numberOfLines = 0;
bottomLabel.textAlignment = NSTextAlignmentCenter;
[view addSubview:bottomLabel]; [view addSubview:bottomLabel];
NSArray* constraints = @[ NSArray* constraints = @[
[topLabel.centerXAnchor constraintEqualToAnchor:view.centerXAnchor], [topLabel.leadingAnchor constraintEqualToAnchor:view.leadingAnchor],
[bottomLabel.centerXAnchor constraintEqualToAnchor:view.centerXAnchor], [topLabel.trailingAnchor constraintEqualToAnchor:view.trailingAnchor],
[topLabel.centerYAnchor constraintEqualToAnchor:view.centerYAnchor [topLabel.bottomAnchor constraintEqualToAnchor:view.centerYAnchor
constant:-10.0f], constant:-10.0f],
[bottomLabel.centerYAnchor constraintEqualToAnchor:view.centerYAnchor [bottomLabel.topAnchor constraintEqualToAnchor:view.centerYAnchor
constant:10.0f], constant:10.0f],
[bottomLabel.leadingAnchor constraintEqualToAnchor:view.leadingAnchor],
[bottomLabel.trailingAnchor constraintEqualToAnchor:view.trailingAnchor],
]; ];
[NSLayoutConstraint activateConstraints:constraints]; [NSLayoutConstraint activateConstraints:constraints];
return view; return view;
......
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