Commit c5f936a6 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Fix Fakebox font size for larger categories

This CL makes sure that the font size used for the NTP fakebox is the
same as the one for the steady view.

Fixed: 934817
Change-Id: I21959edc4b1c1336cf9075522c2bcde6bee246c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1982541
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728151}
parent c125a49d
......@@ -122,7 +122,6 @@ void configureSearchHintLabel(UILabel* searchHintLabel,
[searchHintLabel setTextAlignment:NSTextAlignmentRight];
}
searchHintLabel.textColor = [UIColor colorNamed:kTextfieldPlaceholderColor];
searchHintLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
searchHintLabel.adjustsFontForContentSizeCategory = YES;
searchHintLabel.textAlignment = NSTextAlignmentCenter;
}
......
......@@ -19,6 +19,7 @@
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_utils.h"
#import "ios/chrome/browser/ui/util/dynamic_type_util.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/named_guide_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
......@@ -178,6 +179,7 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
self.searchHintLabel = [[UILabel alloc] init];
content_suggestions::configureSearchHintLabel(self.searchHintLabel,
searchField);
self.searchHintLabel.font = [self hintLabelFont];
self.hintLabelLeadingConstraint = [self.searchHintLabel.leadingAnchor
constraintGreaterThanOrEqualToAnchor:[searchField leadingAnchor]
constant:ntp_header::kHintLabelSidePadding];
......@@ -409,6 +411,10 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
previousTraitCollection.horizontalSizeClass)) {
self.identityDiscTopConstraint.constant = IdentityDiscToolbarOffset(self);
}
if (previousTraitCollection.preferredContentSizeCategory !=
self.traitCollection.preferredContentSizeCategory) {
self.searchHintLabel.font = [self hintLabelFont];
}
}
#pragma mark - Property accessors
......@@ -435,6 +441,12 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
#pragma mark - Private
// Returns the font size for the hint label.
- (UIFont*)hintLabelFont {
return LocationBarSteadyViewFont(
self.traitCollection.preferredContentSizeCategory);
}
// Scale the the hint label down to at most content_suggestions::kHintTextScale.
- (void)scaleHintLabelForPercent:(CGFloat)percent {
CGFloat scaleValue =
......
......@@ -457,9 +457,8 @@ const CGFloat kbadgeViewAnimationDuration = 0.2;
// Returns the font size for the location label.
- (UIFont*)locationLabelFont {
return PreferredFontForTextStyleWithMaxCategory(
UIFontTextStyleBody, self.traitCollection.preferredContentSizeCategory,
UIContentSizeCategoryAccessibilityExtraLarge);
return LocationBarSteadyViewFont(
self.traitCollection.preferredContentSizeCategory);
}
@end
......@@ -29,4 +29,10 @@ UIFont* PreferredFontForTextStyleWithMaxCategory(
UIContentSizeCategory currentCategory,
UIContentSizeCategory maxCategory);
// ********************
// Specific cases utils
// ********************
UIFont* LocationBarSteadyViewFont(UIContentSizeCategory currentCategory);
#endif // IOS_CHROME_BROWSER_UI_UTIL_DYNAMIC_TYPE_UTIL_H_
......@@ -71,3 +71,9 @@ UIFont* PreferredFontForTextStyleWithMaxCategory(
[UITraitCollection
traitCollectionWithPreferredContentSizeCategory:category]];
}
UIFont* LocationBarSteadyViewFont(UIContentSizeCategory currentCategory) {
return PreferredFontForTextStyleWithMaxCategory(
UIFontTextStyleBody, currentCategory,
UIContentSizeCategoryAccessibilityExtraLarge);
}
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