[WhatsNew][iOS] Add an informative subtitle in What's New.
This CL adds a subtitle as a header in What's New for Price Insights.
In addition, it removes WhatsNewTableViewFakeHeaderItem, which was
no longer used.
Screenshot: https://screenshot.googleplex.com/5vJ85QMiHAAEqHP.png
Bug: chromium:
Change-Id: I598f92edbd3078aa79c0f045b90eda72856be075
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6002529
Reviewed-by: Gayane Petrosyan <gayane@google.com>
Commit-Queue: Cheick Cisse <cheickcisse@google.com>
Cr-Commit-Position: refs/heads/main@{#1380865}
diff --git a/ios/chrome/browser/ui/whats_new/cells/BUILD.gn b/ios/chrome/browser/ui/whats_new/cells/BUILD.gn
index 1a429830..f226861d 100644
--- a/ios/chrome/browser/ui/whats_new/cells/BUILD.gn
+++ b/ios/chrome/browser/ui/whats_new/cells/BUILD.gn
@@ -4,10 +4,10 @@
source_set("cells") {
sources = [
- "whats_new_table_view_fake_header_item.h",
- "whats_new_table_view_fake_header_item.mm",
"whats_new_table_view_item.h",
"whats_new_table_view_item.mm",
+ "whats_new_table_view_subtitle_item.h",
+ "whats_new_table_view_subtitle_item.mm",
]
deps = [
diff --git a/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.h b/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.h
deleted file mode 100644
index fad1be001..0000000
--- a/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef IOS_CHROME_BROWSER_UI_WHATS_NEW_CELLS_WHATS_NEW_TABLE_VIEW_FAKE_HEADER_ITEM_H_
-#define IOS_CHROME_BROWSER_UI_WHATS_NEW_CELLS_WHATS_NEW_TABLE_VIEW_FAKE_HEADER_ITEM_H_
-
-#import <UIKit/UIKit.h>
-
-#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_cell.h"
-#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_item.h"
-
-// WhatsNewTableViewFakeHeaderItem renders a custom header for What's New table
-// view items.
-@interface WhatsNewTableViewFakeHeaderItem : TableViewItem
-
-// Main text to be displayed.
-@property(nonatomic, strong) NSString* text;
-
-@end
-
-// WhatsNewTableViewFakeHeaderCell that displays a text label. The text
-// label is displayed on one line.
-@interface WhatsNewTableViewFakeHeaderCell : TableViewCell
-
-// The text to display.
-@property(nonatomic, strong) UILabel* headerLabel;
-
-@end
-
-#endif // IOS_CHROME_BROWSER_UI_WHATS_NEW_CELLS_WHATS_NEW_TABLE_VIEW_FAKE_HEADER_ITEM_H_
diff --git a/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.mm b/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.mm
deleted file mode 100644
index 1978445..0000000
--- a/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.mm
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2022 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.h"
-
-#import "ios/chrome/browser/shared/ui/table_view/legacy_chrome_table_view_styler.h"
-#import "ios/chrome/browser/shared/ui/util/uikit_ui_util.h"
-#import "ios/chrome/common/ui/colors/semantic_color_names.h"
-#import "ios/chrome/common/ui/table_view/table_view_cells_constants.h"
-
-namespace {
-
-// The size of the leading margin between content view and the text labels.
-const CGFloat kItemLeadingMargin = 16.0;
-// The size of the top margin.
-const CGFloat kTopMargin = 24.0;
-
-} // namespace
-
-#pragma mark - WhatsNewTableViewFakeHeaderItem
-
-@implementation WhatsNewTableViewFakeHeaderItem
-
-- (instancetype)initWithType:(NSInteger)type {
- self = [super initWithType:type];
- if (self) {
- self.cellClass = [WhatsNewTableViewFakeHeaderCell class];
- }
- return self;
-}
-
-#pragma mark - TableViewItem
-
-- (void)configureCell:(WhatsNewTableViewFakeHeaderCell*)cell
- withStyler:(ChromeTableViewStyler*)styler {
- [super configureCell:cell withStyler:styler];
- cell.headerLabel.text = self.text;
- cell.accessibilityLabel = self.text;
-}
-
-@end
-
-#pragma mark - WhatsNewTableViewFakeHeaderCell
-
-@implementation WhatsNewTableViewFakeHeaderCell
-
-- (instancetype)initWithStyle:(UITableViewCellStyle)style
- reuseIdentifier:(NSString*)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.isAccessibilityElement = YES;
-
- self.headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- self.headerLabel.textColor = [UIColor colorNamed:kTextSecondaryColor];
- self.headerLabel.font =
- CreateDynamicFont(UIFontTextStyleSubheadline, UIFontWeightSemibold);
- self.headerLabel.adjustsFontForContentSizeCategory = YES;
- self.headerLabel.translatesAutoresizingMaskIntoConstraints = NO;
- self.headerLabel.numberOfLines = 1;
- [self.contentView addSubview:self.headerLabel];
-
- [NSLayoutConstraint activateConstraints:@[
- [self.headerLabel.leadingAnchor
- constraintEqualToAnchor:self.contentView.leadingAnchor
- constant:kItemLeadingMargin],
- [self.headerLabel.trailingAnchor
- constraintEqualToAnchor:self.contentView.trailingAnchor
- constant:-kItemLeadingMargin],
- [self.headerLabel.centerYAnchor
- constraintEqualToAnchor:self.contentView.centerYAnchor],
- [self.headerLabel.topAnchor
- constraintEqualToAnchor:self.contentView.topAnchor
- constant:kTopMargin],
- [self.headerLabel.bottomAnchor
- constraintEqualToAnchor:self.contentView.bottomAnchor],
- ]];
- }
- return self;
-}
-
-#pragma mark - UIReusableView
-
-- (void)prepareForReuse {
- [super prepareForReuse];
- self.headerLabel.text = nil;
-}
-
-@end
diff --git a/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.h b/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.h
new file mode 100644
index 0000000..b020e00
--- /dev/null
+++ b/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.h
@@ -0,0 +1,30 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_UI_WHATS_NEW_CELLS_WHATS_NEW_TABLE_VIEW_SUBTITLE_ITEM_H_
+#define IOS_CHROME_BROWSER_UI_WHATS_NEW_CELLS_WHATS_NEW_TABLE_VIEW_SUBTITLE_ITEM_H_
+
+#import <UIKit/UIKit.h>
+
+#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_header_footer_item.h"
+
+// WhatsNewTableViewSubtitleItem is a model class that uses
+// WhatsNewTableViewSubtitleCell.
+@interface WhatsNewTableViewSubtitleItem : TableViewHeaderFooterItem
+
+// The title text string.
+@property(nonatomic, strong) NSString* title;
+
+@end
+
+// WhatsNewTableViewSubtitleCell implements a TableViewHeaderFooterView subclass
+// containing informative text for What's New.
+@interface WhatsNewTableViewSubtitleCell : UITableViewHeaderFooterView
+
+// UILabels corresponding to `title` from the item.
+@property(nonatomic, strong) UILabel* textLabel;
+
+@end
+
+#endif // IOS_CHROME_BROWSER_UI_WHATS_NEW_CELLS_WHATS_NEW_TABLE_VIEW_SUBTITLE_ITEM_H_
diff --git a/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.mm b/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.mm
new file mode 100644
index 0000000..6cb3d37
--- /dev/null
+++ b/ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.mm
@@ -0,0 +1,67 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.h"
+
+#import "ios/chrome/browser/shared/ui/util/uikit_ui_util.h"
+#import "ios/chrome/common/ui/colors/semantic_color_names.h"
+#import "ios/chrome/common/ui/util/constraints_ui_util.h"
+
+@implementation WhatsNewTableViewSubtitleItem
+
+- (instancetype)initWithType:(NSInteger)type {
+ self = [super initWithType:type];
+ if (self) {
+ self.cellClass = [WhatsNewTableViewSubtitleCell class];
+ }
+ return self;
+}
+
+- (void)configureHeaderFooterView:(WhatsNewTableViewSubtitleCell*)footer
+ withStyler:(ChromeTableViewStyler*)styler {
+ [super configureHeaderFooterView:footer withStyler:styler];
+
+ footer.textLabel.text = self.title;
+}
+
+@end
+
+#pragma mark - WhatsNewTableViewSubtitleCell
+
+@implementation WhatsNewTableViewSubtitleCell
+
+@synthesize textLabel = _textLabel;
+
+- (instancetype)initWithReuseIdentifier:(NSString*)reuseIdentifier {
+ self = [super initWithReuseIdentifier:reuseIdentifier];
+ if (self) {
+ _textLabel = [[UILabel alloc] init];
+ _textLabel.translatesAutoresizingMaskIntoConstraints = NO;
+ _textLabel.font =
+ CreateDynamicFont(UIFontTextStyleSubheadline, UIFontWeightRegular);
+ _textLabel.adjustsFontForContentSizeCategory = YES;
+ _textLabel.textColor = [UIColor colorNamed:kTextSecondaryColor];
+ _textLabel.numberOfLines = 0;
+
+ [self.contentView addSubview:_textLabel];
+ AddSameConstraints(_textLabel, self.contentView);
+ }
+ return self;
+}
+
+#pragma mark - UITableViewCell
+
+- (void)prepareForReuse {
+ [super prepareForReuse];
+
+ _textLabel.text = nil;
+}
+
+#pragma mark - Private
+
+- (NSString*)accessibilityLabel {
+ return _textLabel.text;
+}
+
+@end
diff --git a/ios/chrome/browser/ui/whats_new/strings/ios_whats_new_strings.grd b/ios/chrome/browser/ui/whats_new/strings/ios_whats_new_strings.grd
index 67633be..0e9c2fa 100644
--- a/ios/chrome/browser/ui/whats_new/strings/ios_whats_new_strings.grd
+++ b/ios/chrome/browser/ui/whats_new/strings/ios_whats_new_strings.grd
@@ -190,6 +190,9 @@
<!-- Tips specific strings -->
<part file="tips_strings.grdp" />
+
+ <!-- Subtitle specific strings -->
+ <part file="subtitle_strings.grdp" />
</messages>
</release>
</grit>
diff --git a/ios/chrome/browser/ui/whats_new/strings/subtitle_strings.grdp b/ios/chrome/browser/ui/whats_new/strings/subtitle_strings.grdp
new file mode 100644
index 0000000..4008631
--- /dev/null
+++ b/ios/chrome/browser/ui/whats_new/strings/subtitle_strings.grdp
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grit-part>
+ <!-- Subtitle specific strings -->
+ <message name="IDS_IOS_WHATS_NEW_PRICE_INSIGHTS_SUBTITLE" desc="Subtitle in What's New for Price Insights release.">
+ Get shopping insights that help you track prices, see price history, and buy at the best time.
+ </message>
+</grit-part>
diff --git a/ios/chrome/browser/ui/whats_new/strings/subtitle_strings_grdp/IDS_IOS_WHATS_NEW_PRICE_INSIGHTS_SUBTITLE.png.sha1 b/ios/chrome/browser/ui/whats_new/strings/subtitle_strings_grdp/IDS_IOS_WHATS_NEW_PRICE_INSIGHTS_SUBTITLE.png.sha1
new file mode 100644
index 0000000..82e95ee8
--- /dev/null
+++ b/ios/chrome/browser/ui/whats_new/strings/subtitle_strings_grdp/IDS_IOS_WHATS_NEW_PRICE_INSIGHTS_SUBTITLE.png.sha1
@@ -0,0 +1 @@
+df22966f7285bcf6d8a526c0563ecf6d577c7929
\ No newline at end of file
diff --git a/ios/chrome/browser/ui/whats_new/whats_new_table_view_controller.mm b/ios/chrome/browser/ui/whats_new/whats_new_table_view_controller.mm
index f71a54c14..9da9061 100644
--- a/ios/chrome/browser/ui/whats_new/whats_new_table_view_controller.mm
+++ b/ios/chrome/browser/ui/whats_new/whats_new_table_view_controller.mm
@@ -8,8 +8,8 @@
#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_header_footer_item.h"
#import "ios/chrome/browser/shared/ui/table_view/cells/table_view_text_header_footer_item.h"
#import "ios/chrome/browser/shared/ui/table_view/table_view_utils.h"
-#import "ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_fake_header_item.h"
#import "ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_item.h"
+#import "ios/chrome/browser/ui/whats_new/cells/whats_new_table_view_subtitle_item.h"
#import "ios/chrome/browser/ui/whats_new/data_source/whats_new_item.h"
#import "ios/chrome/browser/ui/whats_new/whats_new_table_view_action_handler.h"
#import "ios/chrome/browser/ui/whats_new/whats_new_table_view_delegate.h"
@@ -17,6 +17,7 @@
#import "ios/chrome/common/ui/table_view/table_view_cells_constants.h"
#import "ios/chrome/grit/ios_branded_strings.h"
#import "ios/chrome/grit/ios_strings.h"
+#import "ios/chrome/grit/ios_whats_new_strings.h"
#import "ui/base/l10n/l10n_util.h"
namespace {
@@ -37,6 +38,7 @@
typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionFeaturesIdentifier = kSectionIdentifierEnumZero,
SectionChromeTipIdenfitier,
+ SectionSubtitleIdentifier,
};
} // namespace
@@ -193,16 +195,22 @@
return cell;
}
-- (TableViewItem*)defaultSectionCell {
- WhatsNewTableViewFakeHeaderItem* cell =
- [[WhatsNewTableViewFakeHeaderItem alloc] initWithType:ItemTypeHeader];
- cell.text = l10n_util::GetNSString(IDS_IOS_WHATS_NEW_SECTION_NEW_TITLE);
+- (TableViewItem*)subtitleSectionCell {
+ WhatsNewTableViewSubtitleItem* cell =
+ [[WhatsNewTableViewSubtitleItem alloc] initWithType:ItemTypeHeader];
+ cell.title =
+ l10n_util::GetNSString(IDS_IOS_WHATS_NEW_PRICE_INSIGHTS_SUBTITLE);
return cell;
}
- (void)loadItems {
TableViewModel* model = self.tableViewModel;
+ // Add subtitle
+ [model addSectionWithIdentifier:SectionSubtitleIdentifier];
+ [model setHeader:[self subtitleSectionCell]
+ forSectionWithIdentifier:SectionSubtitleIdentifier];
+
[self loadFeatures:model];
[self loadChromeTip:model];
}
@@ -239,6 +247,8 @@
header.text =
l10n_util::GetNSString(IDS_IOS_WHATS_NEW_SECTION_CHROME_TIP_TITLE);
break;
+ case SectionSubtitleIdentifier:
+ break;
}
return header;
}