How to show list with section in SwiftUI

Issue #511

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
struct CountriesView: View {
let groups: [Group]

init(countries: [Country]) {
self.groups = CountryManager.shared.groups(countries: countries)
}

var body: some View {
List {
ForEach(groups) { group in
Section(
header:
Text(group.initial)
.foregroundColor(Color.yellow)
.styleTitle(),
content: {
ForEach(group.countries) { country in
CountryRow(country: country)
}
}
)
}
}
}
}

Comments