Commit 0a9fafbb authored by sczs's avatar sczs Committed by Commit Bot

[ios] Adds RecentTabsVC TableViewModel support.

Deletes old table view DataSource implementation and creates a TableViewModel instead.
Moves Item/Cell configuration logic from recent_tabs/views/ into the VC.
Some helper methods are being re-used.


Screenshots:
https://drive.google.com/open?id=1n-IYyIffatHC2ok9fnvyIRhqH6rLADuh
https://drive.google.com/open?id=14NuWwnYFncYfijRpjIuy8kQ-EDYuIze6

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: If997fb74862d135ff68e2b4aafd930d90f13f159
Reviewed-on: https://chromium-review.googlesource.com/954227
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542239}
parent 1ff872df
...@@ -33,6 +33,7 @@ source_set("recent_tabs") { ...@@ -33,6 +33,7 @@ source_set("recent_tabs") {
"//base", "//base",
"//components/browser_sync", "//components/browser_sync",
"//components/sessions", "//components/sessions",
"//components/strings",
"//components/sync", "//components/sync",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/app/theme", "//ios/chrome/app/theme",
......
...@@ -31,6 +31,10 @@ const CGFloat kMargin = 16; ...@@ -31,6 +31,10 @@ const CGFloat kMargin = 16;
TableViewTextHeaderFooterView* header = TableViewTextHeaderFooterView* header =
base::mac::ObjCCastStrict<TableViewTextHeaderFooterView>(headerFooter); base::mac::ObjCCastStrict<TableViewTextHeaderFooterView>(headerFooter);
header.textLabel.text = self.text; header.textLabel.text = self.text;
// Set the contentView backgroundColor, not the header's.
header.contentView.backgroundColor = [UIColor whiteColor];
header.textLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
} }
@end @end
...@@ -46,7 +50,6 @@ const CGFloat kMargin = 16; ...@@ -46,7 +50,6 @@ const CGFloat kMargin = 16;
// Text Label, set font sizes using dynamic type. // Text Label, set font sizes using dynamic type.
_textLabel = [[UILabel alloc] init]; _textLabel = [[UILabel alloc] init];
_textLabel.translatesAutoresizingMaskIntoConstraints = NO; _textLabel.translatesAutoresizingMaskIntoConstraints = NO;
_textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
// Container View. // Container View.
UIView* containerView = [[UIView alloc] init]; UIView* containerView = [[UIView alloc] init];
......
...@@ -21,6 +21,15 @@ ...@@ -21,6 +21,15 @@
_tableViewModel = [[TableViewModel alloc] init]; _tableViewModel = [[TableViewModel alloc] init];
} }
#pragma mark - ViewLifeCycle
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView setBackgroundColor:[UIColor whiteColor]];
[self.tableView setSeparatorColor:[UIColor grayColor]];
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 56, 0, 0)];
}
#pragma mark - UITableViewDataSource #pragma mark - UITableViewDataSource
- (UITableViewCell*)tableView:(UITableView*)tableView - (UITableViewCell*)tableView:(UITableView*)tableView
...@@ -54,7 +63,7 @@ ...@@ -54,7 +63,7 @@
TableViewHeaderFooterItem* item = TableViewHeaderFooterItem* item =
[self.tableViewModel headerForSection:section]; [self.tableViewModel headerForSection:section];
if (!item) if (!item)
return [super tableView:self.tableView viewForHeaderInSection:section]; return [[UIView alloc] initWithFrame:CGRectZero];
Class headerFooterClass = [item cellClass]; Class headerFooterClass = [item cellClass];
NSString* reuseIdentifier = NSStringFromClass(headerFooterClass); NSString* reuseIdentifier = NSStringFromClass(headerFooterClass);
[self.tableView registerClass:headerFooterClass [self.tableView registerClass:headerFooterClass
...@@ -70,7 +79,7 @@ ...@@ -70,7 +79,7 @@
TableViewHeaderFooterItem* item = TableViewHeaderFooterItem* item =
[self.tableViewModel footerForSection:section]; [self.tableViewModel footerForSection:section];
if (!item) if (!item)
return [super tableView:self.tableView viewForHeaderInSection:section]; return [[UIView alloc] initWithFrame:CGRectZero];
Class headerFooterClass = [item cellClass]; Class headerFooterClass = [item cellClass];
NSString* reuseIdentifier = NSStringFromClass(headerFooterClass); NSString* reuseIdentifier = NSStringFromClass(headerFooterClass);
[self.tableView registerClass:headerFooterClass [self.tableView registerClass:headerFooterClass
......
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