FUIListFloorplan

open class FUIListFloorplan<Entity, Section> : UITableViewController, UISearchResultsUpdating where Entity : Hashable, Entity : Identifiable, Section : CaseIterable, Section : Hashable

A generic UITableViewController subclass for displaying business objects in a list context.

Floorplan Structure

Usage

View Model Binding

An FUIListViewModel manages the data pipeline between the list floorplan and data query loader. It also controls how paginated list results are displayed and the global search function. When initializing an FUIListFloorplan, it is required to set up a view model. The floorplan informs the view model whenever there is a request of new entities query, meanwhile it also observes state changes exposed by the view model.

var queries: [ProductListReportSections: FUIDataLoader<Product>] = [:]
queries[.default] = ProductDataLoader()

let model = FUIListViewModel<Product, ProductListReportSections>(queries: queries, isListPagingEnabled: true, isSearchEnabled: true)

let floorplan = FUIListFloorplan<Product, ProductListReportSections>(viewModel: model)

Cell Binding

A cellBinding closure may be used to custom the display of table view cells bound with different entities.

floorplan.cellBinding = { tableView, indexPath, entity in
    let cell = tableView.dequeueReusableCell(withIdentifier: FUIObjectTableViewCell.reuseIdentifier, for: indexPath) as! FUIObjectTableViewCell
    entity.bind(to: cell)
    return cell
}

Pull & Drag Interaction

By default FUIListFloorplan supports pagination in an infinite scroll pattern.

  • Pull to refresh is implemented using standard UIRefreshControl.
  • Infinite scrolling with paginated display is triggered by the scrollViewDidEndDragging delegate. An initial list will be displayed when the floorplan is displayed. When user scrolls to the end of the list, entities for the next page will be fetched and display. During the data fetching period, a loading indicator will be animating in the footer area of the list view.

Search Control

  • Change searchDebounceTiming to add a delay before actual initiating of search requests to a data query loader.
  • Implement emptyResultsView to display a custom empty state view when the search result is empty.

Tap Action Handling

  • Implement addButtonDidTapHandler to handle the tap action on add button.
  • Implement deleteButtonDidTapHandler to handle the tap action on delete button.
  • Fiori style UISearchBar (set in viewDidLoad in case ListViewModel.isSearchEnabled is true).

    Declaration

    Swift

    public var searchBar: FUISearchBar? { get }
  • Debounce timing for firing the search request to a data query loader.

    Declaration

    Swift

    open var searchDebounceTiming: Double
  • A view to be displayed when the search result is empty.

    Declaration

    Swift

    open lazy var emptyResultsView: UIView { get set }
  • The FUICoordinator object that handles navigation when user performs certain actions.

    Declaration

    Swift

    open var coordinator: FUICoordinator?
  • An optional closure for handling tap action on add button.

    Declaration

    Swift

    open var addButtonDidTapHandler: (() -> Void)?
  • The FUIGridRowHeaderItem list for used when display in grid table mode.

    Declaration

    Swift

    open var gridRowHeaderItems: [FUIGridRowHeaderItem]
  • An optional closure for handling tap action on delete button.

    Declaration

    Swift

    open var deleteButtonDidTapHandler: ((Section, Entity) -> Void)?
  • An optional closure for configuring the UITableViewCell bound with different entities.

    Declaration

    Swift

    open var cellBinding: ((UITableView, IndexPath, Entity) -> UITableViewCell?)? { get set }