Commit 25c846ec authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Add distillation badge to reading list table items.

Bug: 852429
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I32d6cae65a26ab3439caa41447a8ffd027b8e0ac
Reviewed-on: https://chromium-review.googlesource.com/1111382
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571356}
parent e97d4eda
...@@ -46,6 +46,7 @@ source_set("reading_list") { ...@@ -46,6 +46,7 @@ source_set("reading_list") {
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/favicon", "//ios/chrome/browser/ui/favicon",
"//ios/chrome/browser/ui/reading_list/context_menu", "//ios/chrome/browser/ui/reading_list/context_menu",
"//ios/chrome/browser/ui/reading_list/resources:distillation_fail_new",
"//ios/chrome/browser/ui/side_swipe", "//ios/chrome/browser/ui/side_swipe",
"//ios/chrome/browser/ui/static_content", "//ios/chrome/browser/ui/static_content",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
...@@ -112,6 +113,7 @@ source_set("reading_list_ui") { ...@@ -112,6 +113,7 @@ source_set("reading_list_ui") {
"//ios/chrome/browser/ui/keyboard", "//ios/chrome/browser/ui/keyboard",
"//ios/chrome/browser/ui/list_model", "//ios/chrome/browser/ui/list_model",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells/resources:table_view_cell_check_mark",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
......
...@@ -31,6 +31,13 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@"; ...@@ -31,6 +31,13 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@";
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface ReadingListTableViewItem ()
// The image to supply as to the TableViewURLCell's |faviconBadgeView|.
@property(nonatomic, strong) UIImage* distillationBadgeImage;
@end
@implementation ReadingListTableViewItem @implementation ReadingListTableViewItem
@synthesize title = _title; @synthesize title = _title;
@synthesize entryURL = _entryURL; @synthesize entryURL = _entryURL;
...@@ -40,6 +47,7 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@"; ...@@ -40,6 +47,7 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@";
@synthesize distillationDateText = _distillationDateText; @synthesize distillationDateText = _distillationDateText;
@synthesize customActionFactory = _customActionFactory; @synthesize customActionFactory = _customActionFactory;
@synthesize attributes = _attributes; @synthesize attributes = _attributes;
@synthesize distillationBadgeImage = _distillationBadgeImage;
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
if (self = [super initWithType:type]) { if (self = [super initWithType:type]) {
...@@ -48,6 +56,28 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@"; ...@@ -48,6 +56,28 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@";
return self; return self;
} }
#pragma mark - Accessors
- (void)setDistillationState:
(ReadingListUIDistillationStatus)distillationState {
if (_distillationState == distillationState)
return;
_distillationState = distillationState;
switch (_distillationState) {
case ReadingListUIDistillationStatusFailure:
self.distillationBadgeImage =
[UIImage imageNamed:@"distillation_fail_new"];
break;
case ReadingListUIDistillationStatusSuccess:
self.distillationBadgeImage =
[UIImage imageNamed:@"table_view_cell_check_mark"];
break;
case ReadingListUIDistillationStatusPending:
self.distillationBadgeImage = nil;
break;
}
}
#pragma mark - ListItem #pragma mark - ListItem
- (void)configureCell:(UITableViewCell*)cell - (void)configureCell:(UITableViewCell*)cell
...@@ -72,6 +102,7 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@"; ...@@ -72,6 +102,7 @@ NSString* const kURLAndDistillationDateFormat = @"%s • %@";
if (styler.cellTitleColor) if (styler.cellTitleColor)
URLCell.titleLabel.textColor = styler.cellTitleColor; URLCell.titleLabel.textColor = styler.cellTitleColor;
[URLCell.faviconView configureWithAttributes:self.attributes]; [URLCell.faviconView configureWithAttributes:self.attributes];
URLCell.faviconBadgeView.image = self.distillationBadgeImage;
cell.isAccessibilityElement = YES; cell.isAccessibilityElement = YES;
cell.accessibilityLabel = GetReadingListCellAccessibilityLabel( cell.accessibilityLabel = GetReadingListCellAccessibilityLabel(
self.title, base::SysUTF8ToNSString(self.entryURL.host()), self.title, base::SysUTF8ToNSString(self.entryURL.host()),
......
...@@ -31,6 +31,15 @@ imageset("distillation_fail") { ...@@ -31,6 +31,15 @@ imageset("distillation_fail") {
] ]
} }
imageset("distillation_fail_new") {
sources = [
"distillation_fail_new.imageset/Contents.json",
"distillation_fail_new.imageset/distillation_fail_new.png",
"distillation_fail_new.imageset/distillation_fail_new@2x.png",
"distillation_fail_new.imageset/distillation_fail_new@3x.png",
]
}
imageset("reading_list_side_swipe") { imageset("reading_list_side_swipe") {
sources = [ sources = [
"reading_list_side_swipe.imageset/Contents.json", "reading_list_side_swipe.imageset/Contents.json",
......
{
"images": [
{
"idiom": "universal",
"scale": "1x",
"filename": "distillation_fail_new.png"
},
{
"idiom": "universal",
"scale": "2x",
"filename": "distillation_fail_new@2x.png"
},
{
"idiom": "universal",
"scale": "3x",
"filename": "distillation_fail_new@3x.png"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
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