{"id":24350760,"url":"https://github.com/imodeveloperlab/imotableview","last_synced_at":"2025-04-09T22:23:30.171Z","repository":{"id":13996102,"uuid":"75604591","full_name":"imodeveloperlab/ImoTableView","owner":"imodeveloperlab","description":"ImoTableView","archived":false,"fork":false,"pushed_at":"2022-10-06T19:27:56.000Z","size":31610,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"development","last_synced_at":"2025-04-09T07:48:42.775Z","etag":null,"topics":["cell","cells","custom","reusable","source","tableview","uitableview"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imodeveloperlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-05T08:31:29.000Z","updated_at":"2023-07-11T21:52:10.000Z","dependencies_parsed_at":"2022-11-29T13:19:46.182Z","dependency_job_id":null,"html_url":"https://github.com/imodeveloperlab/ImoTableView","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imodeveloperlab%2FImoTableView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imodeveloperlab%2FImoTableView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imodeveloperlab%2FImoTableView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imodeveloperlab%2FImoTableView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imodeveloperlab","download_url":"https://codeload.github.com/imodeveloperlab/ImoTableView/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248120918,"owners_count":21051048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cell","cells","custom","reusable","source","tableview","uitableview"],"created_at":"2025-01-18T14:04:48.989Z","updated_at":"2025-04-09T22:23:30.149Z","avatar_url":"https://github.com/imodeveloperlab.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![alt text](Content/Logo.png \"ImoTableView Logo\")\n\nA wrapper around **UITableView** which aims to facilitate working with tables.\n\n- [Onboarding](#onboarding)\n- [Implementation Example](#implementation-example)\n- [Templates](#templates)\n- [Snippets](#snippets)\n- [Requirements](#requirements)\n- [Installation](#installation)\n\n## Onboarding\nTo start to use **ImoTableView** you need to understand the base concept, **ImoTableView** is composed of four classes.\n\n1. **ImoTableView** is a subclass from **UITableView** and owns the role to manage with **ImoTableViewSection**'s, add new sections, delete and update them.\n2. **ImoTableViewSection** is a class that works with **ImoTableViewSource**'s, add a new source, delete, update.\n3. **ImoTableViewSource** is the base object for your new **CellSource**'s this source contains base info about cell class, cell height, and other additional proprieties which you want to show in your cell, user name for example.\n\n4. **ImoTableViewCell** is a view representation of properties you have stored in your source.\n\n![alt text](Content/ImoTableView.png \"ImoTableView\")\n\n## Implementation Example\n\nExample of how quick and simple you can add and populate a tableView\nThis is how ```swift ViewController.swift ``` looks like\n```swift\n//Create a table and ad on some UIView\nlet tableView = ImoTableView(on: someUIView, insets: UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0))\n//Create a new section\nlet section = ImoTableViewSection()\n//Create new cellSource\nlet actionCellSource = ActionCellSource(title: \"Action\")\n//Add cellSource to section\nsection.add(actionCellSource)\n//Add section to table View\ntableView.add(section)\n//Reload table\ntableView.reloadData()\n```\n\n`ActionCell.swift` Contain an method ```swift open override func setUpWithSource(source:AnyObject)``` and this method is called every time  **ActionCell** will be shown on screen and ```swift source:AnyObject``` is cell source with all properties you need to set up you cell.\n\n```swift\nopen class ActionCell: ImoTableViewCell {\n    //UILabel from ActionCell.xib\n    @IBOutlet weak var actionTitle: UILabel!\n    //This method is called every time your cell will be displayed on screen\n    open override func setUpWithSource(source: AnyObject) {\n        //Cast source to ActionCellSource\n        if let source = source as? ActionCellSource {\n            //Set the label title\n            self.actionTitle.text = source.title\n        }\n    }\n}\n```\n`ActionCellSource.swift` Contain an method ```swift open override func setUpWithSource(source:AnyObject)``` and this method is called every time  **ActionCell** will be shown on screen and ```swift source:AnyObject``` is cell source with all properties you need to set up you cell.\n\n```swift\nopen class ActionCellSource: ImoTableViewSource {\n\n    public var title: String\n\n    init(title: String) {\n        self.title = title\n        //Init source an specify cell class you will represent by this source\n        super.init(cellClass: \"ActionCell\")\n        //Set nib bundle if your cell is not in current project bundle\n        setNibBundle(with:Bundle.init(for: self.classForCoder))\n    }\n}\n```\n\n## Templates\nThe quick onboarding for use **ImoTableView** is to add **ImoTableViewCell.xctemplate** in your xcode templates, this template will create all you need to fast create an new **Cell** and **CellSource** for you\n\n![alt text](Content/CreateCellFromTemplate.gif \"ImoTableView Logo\")\n\nTo add **ImoTableViewCell.xctemplate.xctemplate** in xcode you need to open File Templates folder, you can simply call this terminal command ```open /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\\ Templates/```\n\nAfter create an folder **ImoTableView** and copy in this folder **ImoTableViewCell.xctemplate** from Templates/ folder of this repo.\n\n## Snippets\n### ImoTableViewSection\n\n```swift\n//Create new section\nlet section = ImoTableViewSection()\n\n//Add CellSource\nsection.add(yourCellSource)\n\n//Delete CellSource\nsection.delete(atIndex: yourCellIndex)\n\n//Delete CellSource\nsection.delete(yourCellSource)\n\n//Delete All\nsection.deleteAll()\n\n//Set section header View\nsection.headerView = YourView\n\n//Set section footer View\nsection.footerView = YourView\n\n```\n\n### ImoTableView\n\n```swift\n//Create new table\nlet table = ImoTableView()\n\n//Add section\ntable.add(yourSection)\n\n//Add sections\ntable.add(yourSections)\n\n//Delete section at index\ntable.deleteSection(at: yourSectionIndex)\n\n//Delete all sections\ntable.deleteAllSections()\n\n//Did select source, after user touch up on cell\ntable.didSelectSource = { source in\n    //Do something with source\n}\n\n//Did select cell at index path, after user touch up on cell\ntable.didSelectCellAtIndexPath = { indexPath in\n    //Do something with source\n}\n\n```\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 8.1+\n- Swift 3.1+\n\n## Installation\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate ImoTableView into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"imodeveloperlab/ImoTableView\" ~\u003e 1.0\n```\n\nRun `carthage update` to build the framework and drag the built `ImoTableView.framework` into your Xcode project.\n\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.1.0+ is required to build ImoTableView 1.0.8+.\n\nTo integrate ImoTableView into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'ImoTableView', '~\u003e 1.0.25'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n## Examples\n\n### Basic Example\n\n```swift\n//TABLE\nlet table = ImoTableView(on: self.view)\n\n//SECTION\nlet section = ImoTableViewSection()\n\n//FAKER\nlet faker = Faker.init()\n\nlet firstName = TextCellSource(text: \"First Name: \\(faker.name.firstName())\")\nsection.add(firstName)\n\nlet lastName = TextCellSource(text: \"Last Name: \\(faker.name.lastName())\")\nsection.add(lastName)\n\nlet company = TextCellSource(text: \"Company: \\(faker.company.name())\")\nsection.add(company)\n\ntable.add(section: section)\n```\n![alt text](Content/BasicExample.gif \"ImoTableView Logo\")\n\n### Basic Actions Example\n\n```swift\noverride func viewDidLoad() {\n\n        super.viewDidLoad()\n\n        //TABLE\n        let table = ImoTableView(on: self.view)\n\n        //SECTION\n        let section = ImoTableViewSection()\n\n        //FAKER\n        let faker = Faker.init()\n\n        //1. First way\n        let appNameCell = ActionCellSource(title: \"App name: \\(faker.app.name())\")\n        section.add(appNameCell, target: self, #selector(didSelectAppName))\n\n        //2. Second way\n        let appAuthorCell = ActionCellSource(title: \"Author: \\(faker.app.author())\")\n        appAuthorCell.target = self\n        appAuthorCell.selector = #selector(didSelectAppAuthor)\n        section.add(appAuthorCell)\n\n        //3. Third way\n        let appVersion = faker.app.version()\n        let appVersionCell = ActionCellSource(title: \"App version: \\(appVersion)\")\n        appVersionCell.target = self\n        appVersionCell.object = appVersion as AnyObject\n        appVersionCell.selector = #selector(didSelectAppVersion)\n        section.add(appVersionCell)\n\n        table.add(section: section)\n}\n\nfunc didSelectAppVersion(sender: AnyObject) {\n\n    let version = sender as! String\n    show(message: \"Did select version \\(version)\")\n}\n\nfunc didSelectAppAuthor() {\n\n    self.show(message: \"Did select app author\")\n}\n\nfunc didSelectAppName() {\n\n    show(message: \"Did select app name\")\n}\n```\n![alt text](Content/BasicActionsExample.gif \"ImoTableView Logo\")\n\n### Multiple Sections Example\n\n```swift\n//TABLE\nlet table = ImoTableView(on: self.view)\n\n//USER INFO SECTION\nlet userInfoSection = ImoTableViewSection()\nuserInfoSection.headerTitle = \"User info\"\n\nlet firstName = TextCellSource(text: \"First Name: \\(faker.name.firstName())\")\nuserInfoSection.add(firstName)\n\nlet lastName = TextCellSource(text: \"Last Name: \\(faker.name.lastName())\")\nuserInfoSection.add(lastName)\ntable.add(section: userInfoSection)\n\n//BUSSINES INFO SECTION\nlet bussinesInfoSection = ImoTableViewSection()\nbussinesInfoSection.headerTitle = \"Bussines info\"\n\nlet company = TextCellSource(text: \"Company: \\(faker.company.name())\")\nbussinesInfoSection.add(company)\n\nlet cardNumber = TextCellSource(text: \"Credit Card: \\(faker.business.creditCardNumber())\")\nbussinesInfoSection.add(cardNumber)\n\nlet cardType = TextCellSource(text: \"Type: \\(faker.business.creditCardType())\")\nbussinesInfoSection.add(cardType)\ntable.add(section: bussinesInfoSection)\n\n//Lorem section\nlet loremSection = ImoTableViewSection()\nloremSection.headerTitle = \"Lorem Ipsum\"\n\nfor _ in 0...20 {\n    let text = faker.lorem.sentence()\n    loremSection.add(TextCellSource(text: text))\n}\n\ntable.add(section: loremSection)\n```\n![alt text](Content/MultipleSectionsExample.gif \"ImoTableView Logo\")\n\n### Animate Add Cells Example\n\n```swift\noverride func viewDidLoad() {\n\n  super.viewDidLoad()\n\n  //HIDE THE KAYBOARD WHEN TAPPED ARROUND\n  self.hideKeyboardWhenTappedAround()\n\n  //TABLE\n  self.table = ImoTableView(on: self.view)\n\n  //ADD ONE CELL ACTION\n  let addSource = ActionCellSource(title: \"Add new Cell\")\n  mainSection.add(addSource, target: self, #selector(addNewCell))\n\n  //ADD MULTIPLE CELL'S ACTION\n  let addMultipleSource = ActionCellSource(title: \"Add multiple Cells\")\n  mainSection.add(addMultipleSource, target: self, #selector(addMultipleCells))\n\n  //HEADER TITLE\n  secondSection.headerTitle = \"Cells\"\n\n  //ADD SECTIONS TO TABLE\n  table.add(section: mainSection)\n  table.add(section: secondSection)\n}\n\nfunc addNewCell() {\n\n  let text = faker.lorem.sentence()\n  let source = TextCellSource(text: text)\n  table.add(source: source, in: secondSection, animated: true, animation: .top)\n}\n\nfunc addMultipleCells() {\n\n  var sources:[TextCellSource] = []\n\n  for _ in 0...10 {\n      let text = faker.lorem.sentence()\n      sources.append(TextCellSource(text: text))\n  }\n\n  table.add(sources: sources, in: secondSection, animated: true, animation: .top)\n}\n```\n![alt text](Content/AnimateAddCellsExample.gif \"ImoTableView Logo\")\n\n### Animate Delete Cells Example\n\n```swift\noverride func viewDidLoad() {\n\n    super.viewDidLoad()\n    self.hideKeyboardWhenTappedAround()\n    self.table = ImoTableView(on: self.view)\n\n    let deleteFirstSource = ActionCellSource(title: \"Delete first cell\")\n    mainSection.add(deleteFirstSource, target: self, #selector(deleteFirst))\n\n    let deleteLastSource = ActionCellSource(title: \"Delete last cell\")\n    mainSection.add(deleteLastSource, target: self, #selector(deleteLast))\n\n    let deleteAllSource = ActionCellSource(title: \"Delete all cells\")\n    mainSection.add(deleteAllSource, target: self, #selector(deleteAll))\n\n    secondSection.headerTitle = \"Cells\"\n\n    addMultipleCells()\n\n    table.add(section: mainSection)\n    table.add(section: secondSection)\n}\n\nfunc addMultipleCells() {\n\n    var sources:[TextCellSource] = []\n\n    for _ in 0...5 {\n        let text = faker.lorem.sentence()\n        sources.append(TextCellSource(text: text))\n    }\n\n    secondSection.add(sources: sources)\n}\n\nfunc deleteFirst()  {\n\n    if let source = secondSection.firstSource() {\n        table.delete(source: source, in: secondSection, animated: true, animation: .left)\n    }\n}\n\nfunc deleteLast()  {\n\n    if let source = secondSection.lastSource() {\n        table.delete(source: source, in: secondSection, animated: true, animation: .right)\n    }\n}\n\nfunc deleteAll()  {\n\n    let allSources = secondSection.allSources()\n    table.delete(sources: allSources, in: secondSection, animated: true, animation: .top)\n}\n```\n![alt text](Content/AnimateDeleteCellsExample.gif \"ImoTableView Logo\")\n\n### Animate Delete Cells Example\n\n```swift\nself.hideKeyboardWhenTappedAround()\nlet table = ImoTableView(on: self.view, insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0))\n\ntable.tableView.contentInset = UIEdgeInsets(top: 100, left: 0, bottom: 60, right: 0)\ntable.tableView.scrollIndicatorInsets = UIEdgeInsets(top: 100, left: 0, bottom: 60, right: 0)\n\ntable.adjustContentInsetsForKeyboard(true)\nlet section = ImoTableViewSection()\n\nfor _ in 0...5 {\n    let textField = TextFieldCellSource(staticCellWithTableView: table)\n    section.add(textField)\n}\n\nfor _ in 0...20 {\n    let text = faker.lorem.sentence()\n    section.add(TextCellSource(text:text))\n}\n\ntable.add(section: section)\n```\n![alt text](Content/AdjustScrollForKeyboardExample.gif \"ImoTableView Logo\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimodeveloperlab%2Fimotableview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimodeveloperlab%2Fimotableview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimodeveloperlab%2Fimotableview/lists"}