ListPickerItemConfiguration

public struct ListPickerItemConfiguration

The configuration for constructing the list picker.

  • Creates a searchable configuration object from a collection of data which supports single-level picker with the ability to select.

    Declaration

    Swift

    @available(iOS 15.0, macOS 12.0, *)
    public init<Data, ID>(
        _ data: Data,
        id: KeyPath<Data.Element, ID>,
        children: KeyPath<Data.Element, Data?>?,
        selection: Binding<Set<ID>>?,
        allowsMultipleSelection: Bool = true,
        searchFilter: ((Data.Element, String) -> Bool)?,
        @ViewBuilder rowContent: @escaping (Data.Element) -> some View,
        rowBackground: ((Data.Element) -> some View)? = nil
    )
        where Data: RandomAccessCollection, ID: Hashable

    Parameters

    data

    The data for constructing the list picker.

    id

    The key path to the data model’s unique identifier.

    children

    The key path to the optional property of a data element whose value indicates the children of that element.

    selection

    A binding to a set which stores the selected items.

    allowsMultipleSelection

    A boolean value to indicate to allow multiple selections or not.

    searchFilter

    The closure to filter the data in searching process. Request a boolean by the element and the filter key.

    rowContent

    The view builder which returns the content of each row in the list picker.

    rowBackground

    listRowBackground for each row.

  • Undocumented

    Declaration

    Swift

    public init<Data, ID>(_ data: Data,
                          id: KeyPath<Data.Element, ID>,
                          children: KeyPath<Data.Element, Data?>?,
                          selection: Binding<Set<ID>>?,
                          allowsMultipleSelection: Bool = true,
                          searchFilter: ((Data.Element, String) -> Bool)?,
                          @ViewBuilder rowContent: @escaping (Data.Element) -> some View)
        where Data: RandomAccessCollection, ID: Hashable
  • Creates a configuration object from a collection of data which supports both single-level and multi-level picker with the ability to select multiple items.

    Declaration

    Swift

    public init<Data, ID, RowContent>(_ data: Data,
                                      id: KeyPath<Data.Element, ID>,
                                      children: KeyPath<Data.Element, Data?>?,
                                      selection: Binding<Set<ID>>?,
                                      isActive: Binding<Bool>? = nil,
                                      @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent)
        where Data: RandomAccessCollection, RowContent: View, ID: Hashable

    Parameters

    data

    The data for constructing the list picker.

    id

    The key path to the data model’s unique identifier.

    children

    The key path to the optional property of a data element whose value indicates the children of that element.

    selection

    A binding to a set which stores the selected items.

    isActive

    A binding to a bool that decide if show children directly, Default value is nil.

    rowContent

    The view builder which returns the content of each row in the list picker.

  • Creates a configuration object from a collection of data (conforms to Identifiable) which supports both single-level and multi-level picker with the ability to select multiple items.

    Declaration

    Swift

    public init<Data, ID>(_ data: Data,
                          children: KeyPath<Data.Element, Data?>?,
                          selection: Binding<Set<ID>>?,
                          isActive: Binding<Bool>? = nil,
                          @ViewBuilder rowContent: @escaping (Data.Element) -> some View)
        where Data: RandomAccessCollection, Data.Element: Identifiable, ID == Data.Element.ID

    Parameters

    data

    The data for constructing the list picker.

    children

    The key path to the optional property of a data element whose value indicates the children of that element.

    selection

    A binding to a set which stores the selected items.

    isActive

    A binding to a bool that decide if show children directly, Default value is nil.

    rowContent

    The view builder which returns the content of each row in the list picker.

  • Creates a configuration object from a collection of String which supports both single-level and multi-level picker with the ability to select multiple items.

    Declaration

    Swift

    init(_ data: [String], selection: Binding<Set<String>>?, isActive: Binding<Bool>? = nil)

    Parameters

    data

    An array of strings for constructing the list.

    selection

    A binding to a set which stores the selected items.

    isActive

    A binding to a bool that decide if show children directly, Default value is nil.