Skip to content

Commit

Permalink
feat: Add initializer for sectioned content with single selection
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiBardon committed Jul 26, 2022
1 parent 7151f6a commit 870403e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Prose/ProseLib/Sources/ProseUI/CustomList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,41 @@ public struct CustomList<SelectionValue: Hashable, Content: View>: View {
)
}

public init<Section, Header, Element, Row>(
_ sections: IdentifiedArrayOf<Section>,
elements: KeyPath<Section, IdentifiedArrayOf<Element>>,
selection: Binding<SelectionValue?>,
@ViewBuilder row: @escaping (Element) -> Row,
@ViewBuilder header: @escaping (Section) -> Header
) where SelectionValue == Element.ID,
Content == ForEach<
IdentifiedArrayOf<Section>,
Section.ID,
CustomListSection<
CustomListSectionHeader<Header>,
SelectionValue,
BaseContent<Element, Row>
>
>
{
self.init(
content: ForEach(sections, id: sections.id) { section in
CustomListSection(
header: CustomListSectionHeader {
header(section)
},
content: CustomList<SelectionValue, BaseContent<Element, Row>>(
section[keyPath: elements],
selection: selection,
padding: 0,
row: row
)
)
},
spacing: 16
)
}

public init<Section, Header, Element, Row>(
_ sections: IdentifiedArrayOf<Section>,
elements: KeyPath<Section, IdentifiedArrayOf<Element>>,
Expand Down

0 comments on commit 870403e

Please sign in to comment.