From a82061d821a556468ad0fc4efa61aa8bef36d034 Mon Sep 17 00:00:00 2001 From: Nicolas Frugoni Date: Fri, 30 Aug 2024 11:59:10 +0200 Subject: [PATCH] chore: Update BPKMultiSelectChipGroup to handle dropdown type in chip items --- .../Classes/BPKMultiSelectChipGroup.swift | 10 +++++++++- ...hipGroupMultipleSelectWrapExampleView.swift | 18 +++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Backpack-SwiftUI/ChipGroup/Classes/BPKMultiSelectChipGroup.swift b/Backpack-SwiftUI/ChipGroup/Classes/BPKMultiSelectChipGroup.swift index d99b8ed27..837af42bc 100644 --- a/Backpack-SwiftUI/ChipGroup/Classes/BPKMultiSelectChipGroup.swift +++ b/Backpack-SwiftUI/ChipGroup/Classes/BPKMultiSelectChipGroup.swift @@ -78,7 +78,7 @@ public struct BPKMultiSelectChipGroup: View { @ViewBuilder private func chip(for chip: ChipItem) -> some View { switch chip.type { - case .option, .dropdown: + case .option: BPKChip( chip.text, icon: chip.icon, @@ -86,6 +86,14 @@ public struct BPKMultiSelectChipGroup: View { style: style, onClick: chip.onClick ) + case .dropdown: + BPKDropdownChip( + chip.text, + icon: chip.icon, + selected: chip.selected, + style: style, + onClick: chip.onClick + ) case .dismiss: BPKDismissableChip( chip.text, diff --git a/Example/Backpack/SwiftUI/Components/ChipGroup/MultiSelect/ChipGroupMultipleSelectWrapExampleView.swift b/Example/Backpack/SwiftUI/Components/ChipGroup/MultiSelect/ChipGroupMultipleSelectWrapExampleView.swift index a5ffbbbf1..4bc64fb4a 100644 --- a/Example/Backpack/SwiftUI/Components/ChipGroup/MultiSelect/ChipGroupMultipleSelectWrapExampleView.swift +++ b/Example/Backpack/SwiftUI/Components/ChipGroup/MultiSelect/ChipGroupMultipleSelectWrapExampleView.swift @@ -23,22 +23,26 @@ import Backpack_SwiftUI struct ChipGroupMultipleSelectWrapExampleView: View { struct ChipData { let name: String + let type: BPKMultiSelectChipGroup.ChipItem.ChipType var selected: Bool } @State var chipsData = [ - ChipData(name: "Shenzhen", selected: true), - ChipData(name: "London", selected: false), - ChipData(name: "Edinburgh", selected: true), - ChipData(name: "Manchester", selected: false), - ChipData(name: "Belfast", selected: false), - ChipData(name: "Glasgow", selected: false) + ChipData(name: "Shenzhen", type: .option, selected: true), + ChipData(name: "London", type: .dropdown, selected: false), + ChipData(name: "Edinburgh", type: .option, selected: true), + ChipData(name: "Manchester", type: .dismiss, selected: false), + ChipData(name: "Belfast", type: .option, selected: false), + ChipData(name: "Glasgow", type: .option, selected: false) ] var chips: [BPKMultiSelectChipGroup.ChipItem] { chipsData.enumerated().map({ (index, chip) in BPKMultiSelectChipGroup.ChipItem( - text: chip.name, selected: chip.selected, onClick: { chipsData[index].selected.toggle() } + text: chip.name, + type: chip.type, + selected: chip.selected, + onClick: { chipsData[index].selected.toggle() } ) }) }