All Projects → okhanokbay → Expytableview

okhanokbay / Expytableview

Licence: mit
Make your table view expandable just by implementing one method.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Expytableview

Grouprecyclerviewadapter
可增删改查、可动画展开收起、可吸附悬浮动态可配置的分组列表
Stars: ✭ 41 (-88.22%)
Mutual labels:  expandable, collapse
Ynexpandablecell
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 4
Stars: ✭ 445 (+27.87%)
Mutual labels:  tableview, expandable
Expandablelayout
🦚 An expandable layout that shows a two-level layout with an indicator.
Stars: ✭ 448 (+28.74%)
Mutual labels:  expandable, collapse
Ios Swift Collapsible Table Section
📱 A simple iOS Swift project demonstrates how to implement collapsible table section.
Stars: ✭ 1,134 (+225.86%)
Mutual labels:  tableview, collapse
Emaccordiontableviewcontroller
Accordion effect for UITableView
Stars: ✭ 158 (-54.6%)
Mutual labels:  tableview, expandable
Accordion-Collapse-react-native
React native Accordion/Collapse component, very good to use in toggles & show/hide content
Stars: ✭ 147 (-57.76%)
Mutual labels:  collapse, expandable
Fole
Fole is a simple library to collapse and expand a TextView.
Stars: ✭ 67 (-80.75%)
Mutual labels:  expandable, collapse
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-64.08%)
Mutual labels:  tableview, expandable
Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (-60.34%)
Mutual labels:  tableview, expandable
TreeView
"TreeView - sub-cells simplified" (c). Enable subcells in UITableView with a single drop-in extension. CocoaPod:
Stars: ✭ 54 (-84.48%)
Mutual labels:  collapse, expandable
Doublelift
🦋 Expands and collapses a layout horizontally and vertically sequentially.
Stars: ✭ 343 (-1.44%)
Mutual labels:  expandable, collapse
Differencekit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Stars: ✭ 2,986 (+758.05%)
Mutual labels:  tableview
mvcvm-swift-file-templates
Swift file templates for boosting mobile app development.
Stars: ✭ 16 (-95.4%)
Mutual labels:  tableview
birthday-keeper
一个生日管理APP, UI风格模仿的系统闹钟, 可以添加, 编辑, 删除生日以及本地推送提醒, 项目截图见README.
Stars: ✭ 27 (-92.24%)
Mutual labels:  tableview
Pageable
An easy way to Pagination or Infinite scrolling for TableView/CollectionView
Stars: ✭ 44 (-87.36%)
Mutual labels:  tableview
Dropdowntextview
Simple drop-down(expandable) TextView for Android
Stars: ✭ 307 (-11.78%)
Mutual labels:  expandable
Shsegmentedcontroltableview
Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,上拉加载更多。现已加入swift豪华套餐,使用样例助你快速使用
Stars: ✭ 259 (-25.57%)
Mutual labels:  tableview
material-ui-settings-panel
A settings component in material ui style inspired by google admin console and google inbox.
Stars: ✭ 15 (-95.69%)
Mutual labels:  expandable
react-super-treeview
👏 Finally, a React Treeview component which is customizable on every level
Stars: ✭ 98 (-71.84%)
Mutual labels:  collapse
android-tableview-kotlin
Android's missing TableView component.
Stars: ✭ 40 (-88.51%)
Mutual labels:  tableview

ExpyTableView

Version Swift 5.0 iOS 10.0+ License: MIT Platform contributions welcome

Alt Text

About

ExpyTableView is a re-write based on SLExpandableTableView. Takes some ideas, concepts and codes and regenerates them in Swift. Lets you create expandable table views as easily as its ancestor.

With ExpyTableView, you make an expandable table view by using multiple cells and inserting/deleting them(which can mean expanding and collapsing). With this approach, you will have a great chance in future design requests. All you will have to do is adding a new UITableViewCell and writing the code for it. You will easily have the new design.

When using ExpyTableView, sections are being expanded and collapsed. You implement your table view as you always do, and add an extra method. Then your section becomes expandable.

Requirements

VERSION 1.2.2:

  • SPM Support
  • iOS 10.0+
  • Swift 5.0+
  • Objective-C compatibility

VERSION 1.2.1:

  • CocoaPods version
  • iOS 10.0+
  • Swift 5.0+
  • Objective-C compatibility

VERSION 1.0:

  • iOS 8.0+
  • Swift 4.0+

VERSION 0.3.1:

  • iOS 8.0+
  • Swift 3.0+

Installation

ExpyTableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ExpyTableView'

Or you can manually drag and drop the ExpyTableView.swift AND ExpyAbstractions.swift into your project, then use it.

How to use

First of all, if you are using Interface Builder, set your table view's class and module as ExpyTableView.'

Then start implementing required methods:

import ExpyTableView

class ViewController: ExpyTableViewDataSource {

  @IBOutlet weak var expandableTableView: ExpyTableView!

  // First, set data source for your table view.
  override func viewDidLoad() {
    super.viewDidLoad() 
    expandableTableView.dataSource = self
    //Set delegate if you will implement any UITableViewDelegate or ExpyTableViewDelegate methods.
    //expandableTableView.delegate = self 
  }

  // Then return your expandable cell instance from this data source method.
  func tableView(_ tableView: ExpyTableView, expandableCellForSection section: Int) -> UITableViewCell {
    // This cell will be displayed at IndexPath with (section: section and row: 0)
  }
} 

You are ready to go with the setup above.

Customization (optional)

extension ViewController {
  //OPTIONAL DATA SOURCE METHOD, default is true for all sections.
  func tableView(_ tableView: ExpyTableView, canExpandSection section: Int) -> Bool {
    return true //Return false if you want your section not to be expandable
  }
}

You can use optional delegate method:

extension ViewController: ExpyTableViewDelegate {

  //OPTIONAL DELEGATE METHOD, receives callbacks when a section will expand, will collapse, did expand, did collapse. A unified method.
  func tableView(_ tableView: ExpyTableView, expyState state: ExpyState, changeForSection section: Int) {

    switch state {
    case .willExpand:
     print("WILL EXPAND")

    case .willCollapse:
     print("WILL COLLAPSE")

    case .didExpand:
     print("DID EXPAND")

    case .didCollapse:
     print("DID COLLAPSE")
    }
  } 

If your header cell (which is section: section and row: 0) conforms to ExpyTableViewHeaderCell protocol which is optional, it gets notifications in changeState method: (See example project for more detailed usage)

class YourTableViewCell: UITableViewCell, ExpyTableViewHeaderCell{

  //changeState method has a cellReuse parameter to allow you to prepare your cell for reusing. 
  //All state info is allocated by ExpyTableView.
  func changeState(_ state: ExpyState, cellReuseStatus cellReuse: Bool) {

    switch state {
    case .willExpand:
     print("WILL EXPAND")

    case .willCollapse:
     print("WILL COLLAPSE")

    case .didExpand: 
     print("DID EXPAND")

    case .didCollapse:
     print("DID COLLAPSE")
    }
  }
}

You can manually expand or collapse any section like below:

  //These two methods are exposed publicly.
  public func expand(_ section: Int) {}
  public func collapse(_ section: Int) {}

  //You can use these methods as below.
  expandableTableView.collapse(0) //Collapse section at (index: 0) manually
  expandableTableView.expand(1) //Expand section at (index: 1) manually

You will get callbacks for all of the UITableViewDataSource or UITableViewDelegate methods. Just conform to ExpyTableViewDataSource and ExpyTableViewDelegate and they will forward you all the methods you need.

extension ViewController{

  //All of the UITableViewDataSource and UITableViewDelegate methods will be forwarded to you right as they are.
  //Here you can see two examples below.
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("DID SELECT row: \(indexPath.row), section: \(indexPath.section)")
  }

  func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return UITableViewAutomaticDimension
  }
}

See example code for more details and implementation examples.

Example

To run the example project, just download the project and open the xcworkspace file in Example folder.

Roadmap

  • Add a variable that allows collapsing the recently expanded section, when any other section is expanded
  • Add a variable that allows scrolling to recent expanded section rect to show it completely
  • Add a variable that allows clicking on any cell in section to expand or collapse the whole section
  • Add expandAll and collapseAll methods and functionality

All contributions about these issues or other improvements are really appreciated.

Screenshots

License

ExpyTableView is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].