I noticed that Xcode shows warning when a view has list with SearchBar and swipe down action leads to it.
The warning message: [Assert] What changed the navigation bar bounds size to something unexpected during the animation if it wasn't a showsScopeBar change?
I created a simple project to reproduce the same behavior (added code below). How we can fix it? Thanks.
enum Route: Hashable {
case list
}
class ExampleCoordinator: ObservableObject {
@Published var path = NavigationPath()
func push(_ route: Route) {
path.append(route)
}
}
struct ContentView: View {
@StateObject private var coordinator = ExampleCoordinator()
var body: some View {
ZStack {
NavigationStack(path: $coordinator.path) {
VStack(spacing: 40) {
Button("Test") {
coordinator.push(.list)
}
}
.navigationTitle("Hello")
.navigationDestination(for: Route.self) { route in
switch route {
case .list:
ListView()
}
}
}
}
}
}
struct ListView: View {
@State private var searchableText = ""
let array: [Int] = {
var array = [Int]()
for value in 0...99 {
array.append(value)
}
return array
}()
var body: some View {
list
.navigationBarTitleDisplayMode(.inline)
.searchable(text: $searchableText, placement: .toolbar)
.autocorrectionDisabled(true)
.scrollDismissesKeyboard(.immediately)
}
private var list: some View {
List {
ForEach(array, id: \.description) { number in
Text(number.description)
.id(number)
}
}
.listStyle(.plain)
}
}
Demo: