Fix performance issues with lists

This commit is contained in:
Christoph Hagen
2025-02-07 14:09:07 +01:00
parent dc7ab6fb15
commit 1bc40bfb47
5 changed files with 59 additions and 35 deletions

View File

@ -51,13 +51,19 @@ struct FileListView: View {
TextField("", text: $searchString, prompt: Text("Search"))
.textFieldStyle(.roundedBorder)
.padding(.horizontal, 8)
List(filteredFiles) { file in
SelectableListItem(selected: selectedFile == file) {
Text(file.id)
}
.onTapGesture {
selectedFile = file
ScrollView {
LazyVStack(spacing: 0) {
ForEach(filteredFiles) { file in
SelectableListItem(selected: selectedFile == file) {
Text(file.id)
}
.id(file.id)
.onTapGesture {
selectedFile = file
}
}
}
.padding(.horizontal, 8)
}
.onChange(of: selectedFileType) { oldValue, newValue in
guard oldValue != newValue else {