Skip to content

Simple drop down container for create drop down lists

Notifications You must be signed in to change notification settings

Stampoo/DropDownController

Repository files navigation

DropDownController

Simple view with custom content and animation like drop-down list

Example:

How usage:

  1. Create instanse of controller on drop-down content and adapter
final class ExampleDropListViewController: UIViewController {
    
    private let filterView = FilterView()
    private let dropDownTableAdapter = DropDownTableAdapter()
    private lazy var dropDownController = DropDownController(adapter: dropDownTableAdapter)
  1. Create content adapter(for UITableView in example)
   // Content can be anything, create your content adapter and sign with DropDownAdapterProtocol
   private func getAdapter(for table: UITableView) -> AnyObject {
        table.backgroundColor = .black
        table.layer.cornerRadius = 12
        table.separatorStyle = .none
        
        // Table adapter can be AnyObject, simple class or self
        let adapter = BaseTableAdapter(tableView: table)
        let model = BasicCell.Model(title: "Test example with text", backgroundColor: .gray)
        let cellController = CellController<BasicCell>(model: model)
        adapter.append(cellController: cellController)
        adapter.append(cellController: cellController)
        adapter.append(cellController: cellController)
        return adapter
    }
  1. Inject adapter with custom content
filterView.onDidTouchTriggered { isOpen in
    if isOpen {
        self.dropDownTableAdapter.injectContentAdapter(self.getAdapter(for:))
        self.dropDownController.showDropDownList(below: self.filterView, offset: 8)
    } else {
        self.dropDownController.hideDropDonwList()
    }
}

About

Simple drop down container for create drop down lists

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages