ListPickerItem
public struct ListPickerItem
extension ListPickerItem: View
extension ListPickerItem: _ViewEmptyChecking
ListPickerItem
is a view that provides a NavigationLink
with a title and selected value(s). And ListPickerDestination
is recommended to be used as its destination, for which selection, search filter and customized rows are supported.
Usage
let data = ["first", "second", "third"]
var body: some View {
ListPickerItem(title: {
Text("title")
}, value: {
Text("value")
}, axis: .vertical) {
ListPickerDestination(data,
id: \.self,
selection: $selection,
isTrackingLiveChanges: true,
searchFilter: { f, s in f.contains(s) }, rowContent: {
Text($0)
})
}
}
// If you want grouped different sections, the protocol `ListPickerSectionModel` is need be implemented for your element of data.
struct ListPickerSection: ListPickerSectionModel {}
let data = [ListPickerSection(title: "Section 1", items: ["first", "second", "third"]),
ListPickerSection(title: "Section 2", items: ["apple", "banana", "orange"])]
var body: some View {
ListPickerItem(title: {
Text("title")
}, value: {
Text("value")
}, axis: .vertical) {
ListPickerDestination(data,
id: \.self,
selection: $selection,
isTrackingLiveChanges: true,
searchFilter: { f, s in f.contains(s) }, rowContent: {
Text($0)
})
}
}
-
Undocumented
Declaration
Swift
public init(@ViewBuilder title: () -> any View, @ViewBuilder value: () -> any View = { EmptyView() }, @ViewBuilder mandatoryFieldIndicator: () -> any View = { Text("*") }, isRequired: Bool = false, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, axis: Axis = .horizontal, @ViewBuilder destination: () -> any View = { EmptyView() })
-
Undocumented
Declaration
Swift
init(title: AttributedString, value: AttributedString? = nil, mandatoryFieldIndicator: TextOrIcon? = .text("*"), isRequired: Bool = false, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, axis: Axis = .horizontal, @ViewBuilder destination: () -> any View = { EmptyView() })
-
Undocumented
Declaration
Swift
init(_ configuration: ListPickerItemConfiguration)
-
Declaration
Swift
public var body: some View { get }
-
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }