ExpandableList
@available(iOS 14, *)
@MainActor
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
@MainActor 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
dataThe data for constructing the list.
childrenThe key path to the optional property of a data element whose value indicates the children of that element.
selectionA binding to the selected data element.
rowContentThe view builder which returns the content of each row in an expandable list.
destinationThe view builder which returns the destination view when a row is selected.
-
Declaration
Swift
@MainActor 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
@MainActor init(data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Data.Element?>, rowModel: @escaping (Data.Element) -> _SideBarListItemModel, destination: @escaping (Data.Element) -> Destination)Parameters
dataThe data for constructing the list.
childrenThe key path to the optional property of a data element whose value indicates the children of that element.
selectionA binding to the selected data element.
rowModelA closure which returns the content model of each row in an expandable list.
destinationThe 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
@MainActor init(data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Data.Element?>, @ViewBuilder rowContent: @escaping (Data.Element) -> Row)Parameters
dataThe data for constructing the list.
childrenThe key path to the optional property of a data element whose value indicates the children of that element.
selectionA binding to the selected data element.
rowModelA closure which returns the content model of each row in an expandable list.