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, ...@@ -122,7 +122,6 @@ void configureSearchHintLabel(UILabel* searchHintLabel,
[searchHintLabel setTextAlignment:NSTextAlignmentRight]; [searchHintLabel setTextAlignment:NSTextAlignmentRight];
} }
searchHintLabel.textColor = [UIColor colorNamed:kTextfieldPlaceholderColor]; searchHintLabel.textColor = [UIColor colorNamed:kTextfieldPlaceholderColor];
searchHintLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
searchHintLabel.adjustsFontForContentSizeCategory = YES; searchHintLabel.adjustsFontForContentSizeCategory = YES;
searchHintLabel.textAlignment = NSTextAlignmentCenter; searchHintLabel.textAlignment = NSTextAlignmentCenter;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h" #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_constants.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_utils.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.h"
#import "ios/chrome/browser/ui/util/named_guide_util.h" #import "ios/chrome/browser/ui/util/named_guide_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
...@@ -178,6 +179,7 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) { ...@@ -178,6 +179,7 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
self.searchHintLabel = [[UILabel alloc] init]; self.searchHintLabel = [[UILabel alloc] init];
content_suggestions::configureSearchHintLabel(self.searchHintLabel, content_suggestions::configureSearchHintLabel(self.searchHintLabel,
searchField); searchField);
self.searchHintLabel.font = [self hintLabelFont];
self.hintLabelLeadingConstraint = [self.searchHintLabel.leadingAnchor self.hintLabelLeadingConstraint = [self.searchHintLabel.leadingAnchor
constraintGreaterThanOrEqualToAnchor:[searchField leadingAnchor] constraintGreaterThanOrEqualToAnchor:[searchField leadingAnchor]
constant:ntp_header::kHintLabelSidePadding]; constant:ntp_header::kHintLabelSidePadding];
...@@ -409,6 +411,10 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) { ...@@ -409,6 +411,10 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
previousTraitCollection.horizontalSizeClass)) { previousTraitCollection.horizontalSizeClass)) {
self.identityDiscTopConstraint.constant = IdentityDiscToolbarOffset(self); self.identityDiscTopConstraint.constant = IdentityDiscToolbarOffset(self);
} }
if (previousTraitCollection.preferredContentSizeCategory !=
self.traitCollection.preferredContentSizeCategory) {
self.searchHintLabel.font = [self hintLabelFont];
}
} }
#pragma mark - Property accessors #pragma mark - Property accessors
...@@ -435,6 +441,12 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) { ...@@ -435,6 +441,12 @@ CGFloat IdentityDiscToolbarOffset(id<UITraitEnvironment> environment) {
#pragma mark - Private #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. // Scale the the hint label down to at most content_suggestions::kHintTextScale.
- (void)scaleHintLabelForPercent:(CGFloat)percent { - (void)scaleHintLabelForPercent:(CGFloat)percent {
CGFloat scaleValue = CGFloat scaleValue =
......
...@@ -457,9 +457,8 @@ const CGFloat kbadgeViewAnimationDuration = 0.2; ...@@ -457,9 +457,8 @@ const CGFloat kbadgeViewAnimationDuration = 0.2;
// Returns the font size for the location label. // Returns the font size for the location label.
- (UIFont*)locationLabelFont { - (UIFont*)locationLabelFont {
return PreferredFontForTextStyleWithMaxCategory( return LocationBarSteadyViewFont(
UIFontTextStyleBody, self.traitCollection.preferredContentSizeCategory, self.traitCollection.preferredContentSizeCategory);
UIContentSizeCategoryAccessibilityExtraLarge);
} }
@end @end
...@@ -29,4 +29,10 @@ UIFont* PreferredFontForTextStyleWithMaxCategory( ...@@ -29,4 +29,10 @@ UIFont* PreferredFontForTextStyleWithMaxCategory(
UIContentSizeCategory currentCategory, UIContentSizeCategory currentCategory,
UIContentSizeCategory maxCategory); UIContentSizeCategory maxCategory);
// ********************
// Specific cases utils
// ********************
UIFont* LocationBarSteadyViewFont(UIContentSizeCategory currentCategory);
#endif // IOS_CHROME_BROWSER_UI_UTIL_DYNAMIC_TYPE_UTIL_H_ #endif // IOS_CHROME_BROWSER_UI_UTIL_DYNAMIC_TYPE_UTIL_H_
...@@ -71,3 +71,9 @@ UIFont* PreferredFontForTextStyleWithMaxCategory( ...@@ -71,3 +71,9 @@ UIFont* PreferredFontForTextStyleWithMaxCategory(
[UITraitCollection [UITraitCollection
traitCollectionWithPreferredContentSizeCategory:category]]; 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