FUIListFloorplan
@MainActor
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
- On the top of view is
FUIGridTableViewHeader(optional). - Under the header, to display a list of entities, a standard table view is implemented using
FUIEditableTableViewDiffableDataSource. By default the list view supports features including pull to refresh, global search, and pagination control.
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
scrollViewDidEndDraggingdelegate. 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
searchDebounceTimingto add a delay before actual initiating of search requests to a data query loader. - Implement
emptyResultsViewto display a custom empty state view when the search result is empty.
Tap Action Handling
- Implement
addButtonDidTapHandlerto handle the tap action on add button. - Implement
deleteButtonDidTapHandlerto handle the tap action on delete button.
-
Fiori style UISearchBar (set in viewDidLoad in case ListViewModel.isSearchEnabled is true).
Declaration
Swift
@MainActor public var searchBar: FUISearchBar? { get } -
Debounce timing for firing the search request to a data query loader.
Declaration
Swift
@MainActor open var searchDebounceTiming: Double -
A view to be displayed when the search result is empty.
Declaration
Swift
@MainActor open lazy var emptyResultsView: UIView { get set } -
The
FUICoordinatorobject that handles navigation when user performs certain actions.Declaration
Swift
@MainActor open var coordinator: FUICoordinator? -
An optional closure for handling tap action on add button.
Declaration
Swift
@MainActor open var addButtonDidTapHandler: (() -> Void)? -
The
FUIGridRowHeaderItemlist for used when display in grid table mode.Declaration
Swift
@MainActor open var gridRowHeaderItems: [FUIGridRowHeaderItem] -
An optional closure for handling tap action on delete button.
Declaration
Swift
@MainActor open var deleteButtonDidTapHandler: ((Section, Entity) -> Void)? -
An optional closure for configuring the
UITableViewCellbound with different entities.Declaration
Swift
@MainActor open var cellBinding: ((UITableView, IndexPath, Entity) -> UITableViewCell?)? { get set }