Code Monkey home page Code Monkey logo

m80tableviewcomponent's Introduction

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

m80tableviewcomponent's People

Contributors

xiangwangfeng avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.