
SwiftUI Cookbook
By :

In this chapter, we'll learn how to display lists in SwiftUI. List
views are similar to UITableViews
in UIKit but are significantly simpler to use. No storyboards or prototype cells are required, and we do not need to know how many rows there are. SwiftUI's lists are designed to be modular so that you can build bigger things from smaller components.
We'll also look at lazy stacks and lazy grids, which are used to optimize the display of large amounts of data by loading only the subset of the content that is currently being displayed or is about to be displayed. Lastly, we'll take a look at how to present hierarchical data in an expanding list with sections that can be expanded or collapsed.
By the end of this chapter, you will understand how to display lists of static or dynamic items, add or remove rows from lists, edit lists, add sections to list views, and much more.
In this chapter, we will cover the following recipes:
LazyHStack
and LazyVStack
(iOS 14+)LazyHGrid
and LazyVGrid
(iOS 14+)ScrollViewReader
(iOS 14+)DisclosureGroup
to hide and show content (iOS 14+)