List
public class List<D> : ScrollView
Wrapper of UITableView A view that presents data using rows arranged in a single column.
Example:
struct ListView: View {
@DataSource var dataSource: [Model] = [Model]()
@DataSource var headerDataSource: [Model] = [Model]()
@DataSource var footerDataSource: [Model] = [Model]()
var body: View {
List(data:$dataSource){ data in
Row(data)
}
.sectionHeader($headerDataSource) { data in
Header(data)
}
.sectionFooter($footerDataSource) { data in
Footer(data)
}
.didSelectRow { (data, index) in
// Did Select row action
}
}
func appendData(data: Model) {
$dataSource.append(data)
$dataSource.apply()
}
}
-
Initializer
List { Row1() Row2() Row3() }
Declaration
Swift
public convenience init(style: UITableView.Style? = .plain, @ArgoKitListBuilder content: @escaping () -> View) where D : ArgoKitNode
Parameters
style
Constants for the list styles.
content
The content of the list.
-
Initializer
List(data: $dataSource) { item in Row(item) }
Declaration
Swift
public convenience init(_ style: UITableView.Style? = .plain, data: DataSource<DataList<D>>, @ArgoKitListBuilder rowContent: @escaping (D) -> View)
Parameters
style
Constants for the list styles.
data
The data for populating the list.
rowContent
A view builder that creates the view for a single row of the list.
-
Initializer
List(data: $sectionDataSource) { item in Row(item) }
Declaration
Swift
public convenience init(_ style: UITableView.Style? = .plain, data: DataSource<SectionDataList<D>>, @ArgoKitListBuilder rowContent: @escaping (D) -> View)
Parameters
style
Constants for the list styles.
data
The section data for populating the list.
rowContent
A view builder that creates the view for a single row of the list.
-
The view that is displayed above the list’s content.
Declaration
Swift
@discardableResult public func tableHeaderView(headerContent: @escaping () -> View?) -> Self
Parameters
headerContent
A view builder that creates the view for header.
Return Value
Self
-
The view that is displayed below the list’s content.
Declaration
Swift
@discardableResult public func tableFooterView(headerContent: @escaping () -> View?) -> Self
Parameters
footerContent
A view builder that creates the view for footer.
Return Value
Self
-
The view that is displayed in the header of the specified section of the list.
Declaration
Swift
@discardableResult public func sectionHeader(_ data: DataSource<DataList<D>>, @ArgoKitListBuilder headerContent: @escaping (D) -> View) -> Self
Parameters
data
The data for populating the section header.
headerContent
A view builder that creates the view for section header.
Return Value
Self
-
The view that is displayed in the footer of the specified section of the list.
Declaration
Swift
@discardableResult public func sectionFooter(_ data: DataSource<DataList<D>>, @ArgoKitListBuilder footerContent: @escaping (D) -> View) -> Self
Parameters
data
The data for populating the section footer.
footerContent
A view builder that creates the view for section footer.
Return Value
Self
-
Set the estimated height of rows in the table view.
Declaration
Swift
@discardableResult public func estimatedRowHeight(_ value: @autoclosure @escaping () -> CGFloat) -> Self
Parameters
footerContent
A view builder that creates the view for footer.
Return Value
Self
-
Undocumented
Declaration
Swift
public func closeAnimation(value: @autoclosure @escaping () -> Bool) -> Self
-
Undocumented
Declaration
Swift
public func relayoutList(value: @autoclosure @escaping () -> Bool) -> Self
-
Undocumented
Declaration
Swift
public func removeNode(value: Bool) -> Self
-
Setshe cell’s background color.
Declaration
Swift
@discardableResult public func cellBackgroudColor(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> UIColor) -> Self
Parameters
action
Return Value
Self
-
Sets the style of selected cells.
Declaration
Swift
@discardableResult public func selectionStyle(_ value: UITableViewCell.SelectionStyle) -> Self
Parameters
value
The style of selected cells.
Return Value
Self
-
Sets the default inset of cell separators.
Declaration
Swift
@discardableResult public func separatorInset(_ value: UIEdgeInsets) -> Self
Parameters
value
The default inset of cell separators.
Return Value
Self
-
Gets the default inset of cell separators.
Declaration
Swift
public func separatorInset() -> UIEdgeInsets
Return Value
inset of cell separators
-
Sets an indicator of how the separator inset value should be interpreted.
Declaration
Swift
@available(iOS 11.0, *) @discardableResult public func separatorInsetReference(_ value: UITableView.SeparatorInsetReference) -> Self
Parameters
value
An indicator of how the separator inset value should be interpreted.
Return Value
Self
-
Gets an indicator of how the separator inset value should be interpreted.
Declaration
Swift
@available(iOS 11.0, *) @discardableResult public func separatorInsetReference() -> UITableView.SeparatorInsetReference
Return Value
Self
-
Scrolls through the list until a row identified by index path is at a particular location on the screen.
Declaration
Swift
@discardableResult public func cellScrollTo(at indexPath: IndexPath, at scrollPosition: UITableView.ScrollPosition, animated: Bool) -> Self
Parameters
indexPath
An index path that identifies a row in the list by its row index and its section index. NSNotFound is a valid row index for scrolling to a section with zero rows.
scrollPosition
A constant that identifies a relative position in the list (top, middle, bottom) for row when scrolling concludes. See UITableView.ScrollPosition for descriptions of valid constants.
animated
true if you want to animate the change in position; false if it should be immediate.
Return Value
Self
-
Scrolls the list so that the selected row nearest to a specified position in the list is at that position.
Declaration
Swift
@discardableResult public func cellScrollToNearestSelected(at scrollPosition: UITableView.ScrollPosition, animated: Bool) -> Self
Parameters
scrollPosition
A constant that identifies a relative position in the list (top, middle, bottom) for the row when scrolling concludes. See UITableView.ScrollPosition for a descriptions of valid constants.
animated
true if you want to animate the change in position; false if it should be immediate.
Return Value
Self
-
Sets a Boolean value that determines whether users can select a row.
Declaration
Swift
@discardableResult public func allowsSelection(_ value: Bool) -> Self
Parameters
value
A Boolean value that determines whether users can select a row.
Return Value
Self
-
Sets a Boolean value that determines whether users can select more than one row outside of editing mode.
Declaration
Swift
@discardableResult public func allowsMultipleSelection(_ value: Bool) -> Self
Parameters
value
A Boolean value that determines whether users can select more than one row outside of editing mode.
Return Value
Self
-
Selects a row in the list identified by index path, optionally scrolling the row to a location in the list.
Declaration
Swift
@discardableResult public func cellSelectIndexPath(at indexPath: IndexPath?, animated: Bool, scrollPosition: UITableView.ScrollPosition) -> Self
Parameters
indexPath
An index path identifying a row in the list.
animated
true if you want to animate the selection and any change in position; false if the change should be immediate.
scrollPosition
A constant that identifies a relative position in the list (top, middle, bottom) for the row when scrolling concludes. See UITableView.ScrollPosition for descriptions of valid constants.
Return Value
Self
-
Deselects a given row identified by index path, with an option to animate the deselection.
Declaration
Swift
@discardableResult public func cellDeselectIndexPath(at indexPath: IndexPath, animated: Bool) -> Self
Parameters
indexPath
An index path identifying a row in the list.
animated
true if you want to animate the deselection, and false if the change should be immediate.
Return Value
Self
-
Sets a Boolean value that indicates whether the list should automatically return the focus to the cell at the last focused index path.
Declaration
Swift
@available(iOS 9.0, *) @discardableResult public func remembersLastFocusedIndexPath(_ value: Bool) -> Self
Parameters
value
A Boolean value that indicates whether the list should automatically return the focus to the cell at the last focused index path.
Return Value
Self
-
Sets a Boolean value that triggers an automatic selection when focus moves to a cell.
Declaration
Swift
@available(iOS 14.0, *) @discardableResult public func selectionFollowsFocus(_ value: Bool) -> Self
Parameters
value
A Boolean value that triggers an automatic selection when focus moves to a cell.
Return Value
Self
-
Asks the data source to verify that the given row is editable.
Declaration
Swift
@discardableResult public func cellCanEdit(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Asks the data source whether a given row can be moved to another location in the list.
Declaration
Swift
@discardableResult public func cellCanMove(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Sets the titles for the sections of a list.
Declaration
Swift
@discardableResult public func sectionIndexTitles(_ value: [String]?) -> Self
Parameters
value
The titles for the sections of a list.
Return Value
Self
-
Asks the data source to commit the insertion or deletion of a specified row in the receiver.
Declaration
Swift
@discardableResult public func cellCommitEditing(_ action: @escaping (_ editingStyle: UITableViewCell.EditingStyle, _ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Tells the data source to move a row at a specific location in the list to another location.
Declaration
Swift
@discardableResult public func cellMove(_ action: @escaping (_ sourceData: D, _ destinationData: D, _ sourceIndexPath: IndexPath, _ destinationIndexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle tells the data source to move a row at a specific location in the list to another location.
Return Value
Self
-
Instructs your prefetch data source object to begin preparing data for the cells at the supplied index paths.
Declaration
Swift
@discardableResult public func cellsPrefetch(_ action: @escaping (_ indexPaths: [IndexPath]) -> Void) -> Self
Parameters
action
The action to prefetch data source.
Return Value
Self
-
Cancels a previously triggered data prefetch request.
Declaration
Swift
@discardableResult public func cellsCancelPrefetching(_ action: @escaping (_ indexPaths: [IndexPath]) -> Void) -> Self
Parameters
action
The action to cancel a previously triggered data prefetch request.
Return Value
Self
-
Sets the action that handle the list is about to draw a cell for a particular row.
Declaration
Swift
@discardableResult public func cellWillAppear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle the list is about to draw a cell for a particular row.
Return Value
Self
-
Sets the action that handle the table is about to display the header view for the specified section.
Declaration
Swift
@discardableResult public func headerWillAppear(_ action: @escaping (_ data: D, _ section: Int) -> Void) -> Self
Parameters
action
The action that handle the table is about to display the header view for the specified section.
Return Value
Self
-
Sets the action that handle the table is about to display the footer view for the specified section.
Declaration
Swift
@discardableResult public func headerDidDisappear(_ action: @escaping (_ data: D, _ section: Int) -> Void) -> Self
Parameters
action
The action that handle the table is about to display the footer view for the specified section.
Return Value
Self
-
Sets the action that handle the specified cell was removed from the table.
Declaration
Swift
@discardableResult public func cellDidDisappear(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle the specified cell was removed from the table.
Return Value
Self
-
Sets the action that handle the specified header view was removed from the table.
Declaration
Swift
@discardableResult public func footerWillAppear(_ action: @escaping (_ data: D, _ section: Int) -> Void) -> Self
Parameters
action
The action that handle the specified header view was removed from the table.
Return Value
Self
-
Sets the action that handle the specified footer view was removed from the table.
Declaration
Swift
@discardableResult public func footerDidDisappear(_ action: @escaping (_ data: D, _ section: Int) -> Void) -> Self
Parameters
action
The action that handle the specified footer view was removed from the table.
Return Value
Self
-
Sets the action that handle the specified row was highlighted.
Declaration
Swift
@discardableResult public func cellDidHighlight(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle the specified row was highlighted.
Return Value
Self
-
Sets the action that handle the highlight was removed from the row at the specified index path.
Declaration
Swift
@discardableResult public func cellDidUnhighlight(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle the highlight was removed from the row at the specified index path.
Return Value
Self
-
Sets the action that handle a row is about to be selected.
Declaration
Swift
@discardableResult public func cellWillSelect(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> IndexPath?) -> Self
Parameters
action
The action that handle a row is about to be selected.
Return Value
Self
-
Sets the action that handle a specified row is about to be deselected.
Declaration
Swift
@discardableResult public func cellWillDeselect(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> IndexPath?) -> Self
Parameters
action
The action that handle a specified row is about to be deselected.
Return Value
Self
-
Sets the action that handle a row is selected.
Declaration
Swift
@discardableResult public func cellSelected(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle a row is selected.
Return Value
Self
-
Sets the action that handle a row is Deselected.
Declaration
Swift
@discardableResult public func cellDeselected(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle a row is Deselected.
Return Value
Self
-
Sets the cell height.
Declaration
Swift
@discardableResult public func cellHeight(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> CGFloat) -> Self
Parameters
action
The height of cell.
Return Value
Self
-
Asks the delegate for the editing style of a row at a particular location in a list.
Declaration
Swift
@discardableResult public func editingStyle(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> UITableViewCell.EditingStyle) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Changes the default title of the delete-confirmation button.
Declaration
Swift
@discardableResult public func titleForDeleteConfirmationButton(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> String?) -> Self
Parameters
action
The default title of the delete-confirmation button.
Return Value
Self
-
Asks the delegate for the actions to display in response to a swipe in the specified row.
Declaration
Swift
@available(iOS, introduced: 8.0, deprecated: 13.0) @discardableResult public func editActions(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> [ListRowAction]?) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Sets the aciton that returns the swipe actions to display on the leading edge of the row.
Declaration
Swift
@available(iOS 11.0, *) @discardableResult public func leadingSwipeActions(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> ListSwipeActionsConfiguration?) -> Self
Parameters
action
The aciton that returns the swipe actions to display on the leading edge of the row.
Return Value
Self
-
Sets the aciton that returns the swipe actions to display on the trailing edge of the row.
Declaration
Swift
@available(iOS 11.0, *) @discardableResult public func trailingSwipeActions(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> ListSwipeActionsConfiguration?) -> Self
Parameters
action
The aciton that returns the swipe actions to display on the trailing edge of the row.
Return Value
Self
-
Asks the delegate whether the background of the specified row should be indented while the list is in editing mode.
Declaration
Swift
@discardableResult public func cellShouldIndentWhileEditing(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Sets the action that handle the list is about to go into editing mode.
Declaration
Swift
@discardableResult public func cellWillBeginEditing(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle the list is about to go into editing mode.
Return Value
Self
-
Sets the action that handle the list has left editing mode.
Declaration
Swift
@discardableResult public func cellDidEndEditing(_ action: @escaping (_ data: D?, _ indexPath: IndexPath?) -> Void) -> Self
Parameters
action
The action that handle the list has left editing mode.
Return Value
Self
-
Asks the delegate to return a new index path to retarget a proposed move of a row.
Declaration
Swift
@discardableResult public func targetIndexPathForMove(_ action: @escaping (_ sourceData: D, _ proposedDestinationData: D, _ sourceIndexPath: IndexPath, _ proposedDestinationIndexPath: IndexPath) -> IndexPath) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Asks the delegate to return the level of indentation for a row in a given section.
Declaration
Swift
@discardableResult public func indentationLevel(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Int) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Asks the delegate if the editing menu should be shown for a certain row.
Declaration
Swift
@available(iOS, introduced: 5.0, deprecated: 13.0) @discardableResult public func shouldShowMenu(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Asks the delegate if the editing menu should omit the Copy or Paste command for a given row.
Declaration
Swift
@discardableResult public func canPerformAction(_ action: @escaping (_ action: Selector, _ data: D, _ indexPath: IndexPath, _ sender: Any?) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Sets the action that handle perform a copy or paste operation on the content of a given row.
Declaration
Swift
@discardableResult public func performAction(_ action: @escaping (_ action: Selector, _ data: D, _ indexPath: IndexPath, _ sender: Any?) -> Void) -> Self
Parameters
action
The action that handle perform a copy or paste operation on the content of a given row.
Return Value
Self
-
Asks the delegate whether the cell at the specified index path is itself focusable.
Declaration
Swift
@discardableResult public func cellCanFocus(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Asks the delegate whether the focus update specified by the context is allowed to occur.
Declaration
Swift
@discardableResult public func shouldUpdateFocus(_ action: @escaping (_ context: UITableViewFocusUpdateContext) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Sets the action that handle a focus update specified by the context has just occurred.
Declaration
Swift
@discardableResult public func didUpdateFocus(_ action: @escaping (_ context: UITableViewFocusUpdateContext, _ coordinator: UIFocusAnimationCoordinator) -> Void) -> Self
Parameters
action
The action that handle a focus update specified by the context has just occurred.
Return Value
Self
-
Asks the delegate for the list’s index path for the preferred focused view.
Declaration
Swift
@discardableResult public func indexPathForPreferredFocusedView(_ action: @escaping () -> IndexPath?) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Called to let you fine tune the spring-loading behavior of the rows in a table.
Declaration
Swift
@available(iOS 11.0, *) @discardableResult public func shouldSpringLoadRow(_ action: @escaping (_ data: D, _ indexPath: IndexPath, _ context: UISpringLoadedInteractionContext) -> Bool) -> Self
Parameters
action
The aciton that handle fine tune the spring-loading behavior of the rows in a table.
Return Value
Self
-
Asks the delegate whether the user can use a two-finger pan gesture to select multiple items in a list.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func shouldBeginMultipleSelectionInteraction(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Bool) -> Self
Parameters
action
Result of the ask.
Return Value
Self
-
Sets the action that handle the user starts using a two-finger pan gesture to select multiple rows in a list.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func didBeginMultipleSelectionInteraction(_ action: @escaping (_ data: D, _ indexPath: IndexPath) -> Void) -> Self
Parameters
action
The action that handle the user starts using a two-finger pan gesture to select multiple rows in a list.
Return Value
Self
-
Sets the action that handle the user stops using a two-finger pan gesture to select multiple rows in a list.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func didEndMultipleSelectionInteraction(_ action: @escaping () -> Void) -> Self
Parameters
action
The action that handle the user stops using a two-finger pan gesture to select multiple rows in a list.
Return Value
Self
-
Sets the aciton that returns a context menu configuration for the row at a point.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func contextMenuConfiguration(_ action: @escaping (_ data: D, _ indexPath: IndexPath, _ point: CGPoint) -> UIContextMenuConfiguration?) -> Self
Parameters
action
The aciton that returns a context menu configuration for the row at a point.
Return Value
Self
-
Sets the aciton that returns a view to override the default preview the list created.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func previewForHighlightingContextMenu(_ action: @escaping (_ configuration: UIContextMenuConfiguration) -> UITargetedPreview?) -> Self
Parameters
action
The aciton that returns a view to override the default preview the list created.
Return Value
Self
-
Sets the aciton that returns the destination view when dismissing a context menu.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func previewForDismissingContextMenu(_ action: @escaping (_ configuration: UIContextMenuConfiguration) -> UITargetedPreview?) -> Self
Parameters
action
The aciton that returns the destination view when dismissing a context menu.
Return Value
Self
-
Sets the action that handle a user triggers a commit by tapping the preview.
Declaration
Swift
@available(iOS 13.0, *) @discardableResult public func willPerformPreviewAction(_ action: @escaping (_ configuration: UIContextMenuConfiguration, _ animator: UIContextMenuInteractionCommitAnimating) -> Void) -> Self
Parameters
action
The action that handle a user triggers a commit by tapping the preview.
Return Value
Self
-
Sets the action that handle a context menu will appear.
Declaration
Swift
@available(iOS 14.0, *) @discardableResult public func willDisplayContextMenu(_ action: @escaping (_ configuration: UIContextMenuConfiguration, _ animator: UIContextMenuInteractionAnimating?) -> Void) -> Self
Parameters
action
The action that handle a context menu will appear.
Return Value
Self
-
Sets the action that handle a context menu will disappear.
Declaration
Swift
@available(iOS 14.0, *) @discardableResult public func willEndContextMenuInteraction(_ action: @escaping (_ configuration: UIContextMenuConfiguration, _ animator: UIContextMenuInteractionAnimating?) -> Void) -> Self
Parameters
action
The action that handle a context menu will disappear.
Return Value
Self
-
Set the callback called when a scrolling animation in the scroll view concludes.
Declaration
Swift
public func didEndScroll(_ action: @escaping ([(D, UITableViewCell)], UITableView) -> Void) -> Self
Parameters
action
callback
Return Value
self