Skip to content

Instantly share code, notes, and snippets.

@samdeane
Created February 3, 2022 14:20
Show Gist options
  • Save samdeane/682d987fb6f95e6702b6d1604747961b to your computer and use it in GitHub Desktop.
Save samdeane/682d987fb6f95e6702b6d1604747961b to your computer and use it in GitHub Desktop.
ContentView illustrating nasty transition for a searchable ScrollView
import SwiftUI
struct ContentView: View {
@State var text = ""
var body: some View {
TabView {
NavigationView {
ScrollView {
LazyVStack(alignment: .leading) {
ForEach(0..<1000) { n in
Divider()
.padding(.leading)
Text("\(n)")
.padding(.leading)
.padding(.top, 3)
}
}
}
.navigationTitle("Test")
.searchable(text: $text, placement: .navigationBarDrawer(displayMode: .always))
}
.tabItem {
Label("ForEach", systemImage: "tag")
}
NavigationView {
List(0..<1000) { n in
Text("\(n)")
}
.listStyle(.plain)
.navigationTitle("Test")
.searchable(text: $text, placement: .navigationBarDrawer(displayMode: .always))
}
.tabItem {
Label("List", systemImage: "tag")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment