Fix performance issues with lists
This commit is contained in:
@ -72,13 +72,18 @@ struct PostListView: View {
|
||||
TextField("", text: $searchString, prompt: Text("Search"))
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.padding(.horizontal, 8)
|
||||
List(filteredAndSortedPosts) { post in
|
||||
SelectableListItem(selected: selection.post == post) {
|
||||
PostListItem(post: post)
|
||||
}
|
||||
.onTapGesture {
|
||||
selection.post = post
|
||||
}
|
||||
ScrollView {
|
||||
LazyVStack(spacing: 0) {
|
||||
ForEach(filteredAndSortedPosts) { post in
|
||||
SelectableListItem(selected: selection.post == post) {
|
||||
PostListItem(post: post)
|
||||
}
|
||||
.id(post)
|
||||
.onTapGesture {
|
||||
selection.post = post
|
||||
}
|
||||
}
|
||||
}.padding(.horizontal, 8)
|
||||
}
|
||||
}.onAppear {
|
||||
if selection.post == nil, let first = content.posts.first {
|
||||
|
Reference in New Issue
Block a user