Specifies the contents of a section.
A `SectionConfiguration` includes the content of the section, as well as
its header and footer.
A `SectionConfiguration` can represent either an explicit section,
or groups of sibling views that are not explicitly wrapped in a section.
Notably, the `header`, `footer` and `content` properties of a
`SectionConfiguration` are all `SubviewsCollection`s as they can be made up
of multiple subviews. That means in most cases, the subviews collection
should be treated as a collection (either indexed into, or used with a
`ForEach`), or the subviews collection should be wrapped in a container
view, like a layout, or other custom container:
PinboardSectionsLayout {
ForEach(sections: content) { section in
VStack {
HStack { section.header }
section.content
HStack { section.footer }
}
}
}
Here, we want to create one view for `PinboardSectionsLayout` to place per
section in content. To do that, we surround the `ForEach` body in another
container, a `VStack` layout, ensuring the different subviews of
section.content are treated as a single view by the surrounding layout.
Additionally, surrounding the header and footer in an `HStack` layout
avoids vertically stacking subviews of the header and footer
which we want visually grouped together.
Members (5)
get · iOS 18.0+
containerValues
TypeScript
get containerValues(): ContainerValues
Swift declaration
var containerValues: ContainerValues { get }
The container values associated with the given section.
Only explicitly created sections are able to have container values,
meaning this container values will be empty if the section is implicit.
get · iOS 18.0+
id
TypeScript
get id(): SectionConfiguration_ID
Swift declaration
var id: SectionConfiguration.ID { get }
A unique identifier representing the section.
get · iOS 18.0+
footer
TypeScript
get footer(): SubviewsCollection
Swift declaration
var footer: SubviewsCollection { get }
The contents of the section footer.
Notably, the section's footer is a `SubviewsCollection`, not a
`Subview`, as it can be made up of multiple subviews. That means in most
cases, the subviews collection should be treated as a collection (either
indexed into, or used with a `ForEach`), or the subviews collection
should be wrapped in a container view, like a layout, or other custom
container:
ForEach(sections: content) {
VStack {
HStack { section.header }
HStack { section.footer }
}
}
Here, we surround the header and footer in an `HStack` layout to avoid
vertically stacking the subviews of the header and footer which we want
visually grouped together. Additionally, we surround the `ForEach` body
in a VStack, so it is treated as a single view by containers it gets
passed to.
get · iOS 18.0+
header
TypeScript
get header(): SubviewsCollection
Swift declaration
var header: SubviewsCollection { get }
The contents of the section header.
Notably, the section's header is a `SubviewsCollection`, not a
`Subview`, as it can be made up of multiple subviews. That means in most
cases, the subviews collection should be treated as a collection (either
indexed into, or used with a `ForEach`), or the subviews collection
should be wrapped in a container view, like a layout, or other custom
container:
ForEach(sections: content) {
VStack {
HStack { section.header }
HStack { section.footer }
}
}
Here, we surround the header and footer in an `HStack` layout to avoid
vertically stacking the subviews of the header and footer which we want
visually grouped together. Additionally, we surround the `ForEach` body
in a VStack, so it is treated as a single view by containers it gets
passed to.
get · iOS 18.0+
content
TypeScript
get content(): SubviewsCollection
Swift declaration
var content: SubviewsCollection { get }
The contents of the section body.
Notably, the section's content is a `SubviewsCollection`, not a
`Subview`, as it can be made up of multiple subviews. That means in most
cases, the subviews collection should be treated as a collection (either
indexed into, or used with a `ForEach`), or the subviews collection
should be wrapped in a container view, like a layout, or other custom
container:
PinboardSectionsLayout {
ForEach(sections: content) { section in
VStack {
section.content
}
}
}
Here, we want to create one view for `PinboardSectionsLayout` to place
per section in content. To do that, we surround the `ForEach` body in
another container, a `VStack` layout, ensuring the different subviews of
section.content are treated as a single view by the surrounding layout.