Skip to content
A component-based library for UITableView
Objective-C Python Ruby
Branch: master
Clone or download
Latest commit 4339aa3 Jul 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Documents Update README.md Jul 21, 2019
Example ignore pods dir Jul 20, 2019
M80TableViewComponent M80TableViewComponent Jul 20, 2019
.gitignore ignore pods dir Jul 20, 2019
LICENSE Initial commit Jul 20, 2019
M80TableViewComponent.podspec
README.md Update README.md Jul 20, 2019
_Pods.xcodeproj M80TableViewComponent Jul 20, 2019
pod_push.py M80TableViewComponent Jul 20, 2019

README.md

M80TableViewComponent

A component-based library for UITableView 中文版本

Main Features
🙅 No more indexpath and array out of range
👋 Segregation of duties
😁 UITableViewCell will be automatically reusable
🏡 Data-driven
Safe model to view mapping
➡️ One way binding
📥 Easy to compose different components together
🚀 Simple support for height cache and precalculate
🔑 ListDiff supported

System Requirements

  • iOS 9.0 or higher
  • Xcode 11.0 or higher

Installation

Cocoapods

pod 'M80TableViewComponent'

QuickStart

Define custom component

@implementation M80ItemComponent

- (Class)cellClass
{
    return UITableViewCell.class;
}

- (CGFloat)height
{
    return 44.0;
}

- (void)configure:(UITableViewCell *)cell
{
    cell.textLabel.text = self.title;
}

@end

Compose them

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSArray *components = @[[M80ItemComponent component:@"Text" vcName:@"M80TextViewController"],
                            [M80ItemComponent component:@"ListDiff" vcName:@"M80ListDiffViewController"],
                            [M80ItemComponent component:@"Feed" vcName:@"M80FeedViewController"]];
    
    M80TableViewSectionComponent *section = [M80TableViewSectionComponent new];
    section.components = components;
    
    M80TableViewComponent *tableViewComponent = [[M80TableViewComponent alloc] initWithTableView:self.tableView];
    tableViewComponent.sections = @[section];
    tableViewComponent.context = context;
    
    self.tableViewComponent = tableViewComponent;
}

Key Classes

Class Usage
M80TableViewComponent TableView component which holds many section components
M80TableViewSectionComponent Section component which holds many cell components
M80TableViewCellComponent Cell component which is used for managing UITableViewCell
M80TableViewViewComponent View componnet
M80TableViewComponentContext Class which holds the context information for the tableview component
You can’t perform that action at this time.