Structure
OUDSChipPicker
A picker allowing to expose several filter chips and proposing single or multiple selections.
- iOS 15.0+
- macOS 13.0+
- visionOS 1.0+
@MainActor struct OUDSChipPicker<Tag> where Tag : Hashable
Mentioned In
Overview
Each chip contains a “tag”, i.e. a supposed to be unique value. The picker will expose choosen values through this “tag”. It has also some configuration elements which will override the one applied to nested OUDSFilterChip.
Accessibility considerations
Voice Over will use several elements to describe the component. The picker itself does no have any defined accessiiblity value, label or identifier ; it remains in the users hands to define which one will be used. However if defined in the OUDSChipPickerData the items inside the picker will have such accessibility identifiers.
Code samples
// Define the elements to display in filter chip using OUDSChipPickerData.
enum Drink: String, CaseIterable {
case virginHolyLava, ipaBeer, mineralWater
}
var someDataToPopulate: [OUDSChipPickerData<Drink>] {
[
OUDSChipPickerData(tag: Drink.virginHolyLava,
layout: .textAndIcon("Virgin Holy Lava", icon: Image(systemName: "flame")),
OUDSChipPickerData(tag: Dring.ipaBeer,
layout: .textAndIcon("IPA Beer", icon: Image(systemName: "dog.fill")),
OUDSChipPickerData(tag: Drink.mineralWater,
layout: .textAndIcon("Mineral water", icon: Image(systemName: "waterbottle.fill")),
]
}
/// Single selection case
// Prepare the selection, with a value previously selected
// Use the data and the binding for the picker.
@State var selection: Drink = .mineralWater
// Here the picker with title, selection and data
OUDSChipPicker(title: "Select a drink", selection: $selection, chips: someDataToPopulate)
/// Multiple selection case
// Prepare the selection, with a value previously selected
// Use the data and the binding for the picker.
@State var selections: [Drink] = [.mineralWater]
// Here the picker with title, selection and data
OUDSChipPicker(title: "Select a drink", selections: $selections, chips: someDataToPopulate)
Design documentation
There is no online specification as this component is not an official OUDS one.
Theme rendering
Orange

Orange Compact

Sosh

Wireframe

Since
0.17.0
Topics
Initializers
init(title: String?, selection: Binding<Tag>, chips: [OUDSChipPickerData<Tag>], itemsSpacing: SpaceSemanticToken?)Defines the single selection picker view which displays using OUDSFilterChip view the OUDSChipPickerData The user will be able to choose only one option in this picker.
init(title: String?, selection: Binding<Tag?>, chips: [OUDSChipPickerData<Tag>], itemsSpacing: SpaceSemanticToken?)Defines the single selection picker view which displays using OUDSFilterChip view the OUDSChipPickerData. The user will be able to choose zero or one option in this picker.
init(title: String?, selections: Binding<[Tag]>, chips: [OUDSChipPickerData<Tag>], itemsSpacing: SpaceSemanticToken?)Defines the multiple selection picker view which displays using OUDSFilterChip view the OUDSChipPickerData. The user will be able to choose zero or one or seevral options in this picker.
init(title: LocalizedStringKey?, tableName: String?, bundle: Bundle, selection: Binding<Tag?>, chips: [OUDSChipPickerData<Tag>], itemsSpacing: SpaceSemanticToken?)Defines the single selection picker view with a localized title, looking up the key in the given bundle.
init(title: LocalizedStringKey?, tableName: String?, bundle: Bundle, selection: Binding<Tag>, chips: [OUDSChipPickerData<Tag>], itemsSpacing: SpaceSemanticToken?)Defines the single selection picker view with a localized title, looking up the key in the given bundle.
init(title: LocalizedStringKey?, tableName: String?, bundle: Bundle, selections: Binding<[Tag]>, chips: [OUDSChipPickerData<Tag>], itemsSpacing: SpaceSemanticToken?)Defines the multiple selection picker view with a localized title, looking up the key in the given bundle.
Instance Properties