Created
February 3, 2022 14:20
-
-
Save samdeane/682d987fb6f95e6702b6d1604747961b to your computer and use it in GitHub Desktop.
ContentView illustrating nasty transition for a searchable ScrollView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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