ExpandableList
@available(iOS 14, *)
public struct ExpandableList<Data, Row, Destination> : View where Data : RandomAccessCollection, Row : View, Destination : View, Data.Element : Hashable, Data.Element : Identifiable
Defines an expandable list which supports multi-level hierarchy with the ability to select a single item.
-
Creates an expandable list from a collection of data which supports multi-level hierarchy with the ability to select a single item.
Declaration
Swift
public init(data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Data.Element?>, @ViewBuilder rowContent: @escaping (Data.Element) -> Row, @ViewBuilder destination: @escaping (Data.Element) -> Destination? = { _ in nil })
Parameters
data
The data for constructing the list.
children
The key path to the optional property of a data element whose value indicates the children of that element.
selection
A binding to the selected data element.
rowContent
The view builder which returns the content of each row in an expandable list.
destination
The view builder which returns the destination view when a row is selected.
-
Declaration
Swift
public var body: some View { get }
-
Creates an expandable list from a collection of data which supports multi-level hierarchy with the ability to select a single item.
Declaration
Swift
init(data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Data.Element?>, rowModel: @escaping (Data.Element) -> _SideBarListItemModel, destination: @escaping (Data.Element) -> Destination)
Parameters
data
The data for constructing the list.
children
The key path to the optional property of a data element whose value indicates the children of that element.
selection
A binding to the selected data element.
rowModel
A closure which returns the content model of each row in an expandable list.
destination
The view builder which returns the destination view when a row is selected.
-
Creates an expandable list from a collection of data which supports multi-level hierarchy with the ability to select a single item. No destination view will be defined when using this initializer.
Declaration
Swift
init(data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Data.Element?>, @ViewBuilder rowContent: @escaping (Data.Element) -> Row)
Parameters
data
The data for constructing the list.
children
The key path to the optional property of a data element whose value indicates the children of that element.
selection
A binding to the selected data element.
rowModel
A closure which returns the content model of each row in an expandable list.