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

[iOS] Support Dynamic Type for ReadingList empty string

This CL changes the string displayed when the ReadingList is empty so
it doesn't overflow below the bottom and top toolbar when the font is
too big. It does that by limiting the font size.

Bug: 893535
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I03335f2c1fee192a765b6e85011627c0f5ae2019
Reviewed-on: https://chromium-review.googlesource.com/c/1276925
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599153}
parent 5275c357
......@@ -27,9 +27,30 @@ NSString* const kReadLaterTextMarker = @"READ_LATER_TEXT";
// Background view constants.
const CGFloat kLineSpacing = 4;
UIFont* FontWithMaximumForCategory(UIContentSizeCategory category,
UIFontTextStyle font_style) {
if (ContentSizeCategoryIsAccessibilityCategory(category)) {
return [UIFont
preferredFontForTextStyle:font_style
compatibleWithTraitCollection:
[UITraitCollection traitCollectionWithPreferredContentSizeCategory:
UIContentSizeCategoryAccessibilityLarge]];
}
return [UIFont preferredFontForTextStyle:font_style];
}
// Returns the font to use for the message text.
UIFont* GetMessageFont() {
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
return FontWithMaximumForCategory(
[UIApplication sharedApplication].preferredContentSizeCategory,
UIFontTextStyleBody);
}
// Returns the font to use for the message text.
UIFont* GetInstructionFont() {
return FontWithMaximumForCategory(
[UIApplication sharedApplication].preferredContentSizeCategory,
UIFontTextStyleHeadline);
}
// Returns the attributes to use for the message text.
......@@ -54,8 +75,7 @@ NSMutableDictionary* GetMessageAttributes() {
// Later" option.
NSMutableDictionary* GetInstructionAttributes() {
NSMutableDictionary* attributes = GetMessageAttributes();
attributes[NSFontAttributeName] =
[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
attributes[NSFontAttributeName] = GetInstructionFont();
return attributes;
}
......
......@@ -22,6 +22,7 @@
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_commands.h"
#import "ios/chrome/browser/ui/reading_list/reading_list_toolbar_button_manager.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_header_footer_item.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -224,6 +225,15 @@ ReadingListSelectionState GetSelectionStateForSelectedCounts(
[self exitEditingModeAnimated:YES];
}
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
if (!self.dataSource.hasElements &&
self.traitCollection.preferredContentSizeCategory !=
previousTraitCollection.preferredContentSizeCategory) {
[self tableIsEmpty];
}
}
#pragma mark - UITableViewDataSource
- (void)tableView:(UITableView*)tableView
......
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