Im trying to show a TextField inside a SwiftUI Form. The animation for moving the view when the keyboard appears does not look smooth.
First, the top section moves under the navigation title before the view moves up completely (which is not possible with scrolling).
When the the keyboard disappears the animation is not smooth at all and leaves a white space at then bottom safe area, which disappears without any animation.
This is a sample code to reproduce the issue. I am using Xcode 14.2 and iOS 16.2
struct Test: View {
@State var text1: String = ""
@State var text2: String = ""
var body: some View {
Form {
Section {
Text("Test")
Text("Test")
Text("Test")
Text("Test")
}
Section {
Text("Test")
Text("Test")
Text("Test")
Text("Test")
}
Section {
Text("asdasdasd")
Text("fdfdsf")
Text("q34dasd")
Text("sdad33q34asd")
}
Section {
TextField("Textfield1", text: $text1)
.textFieldStyle(.roundedBorder)
TextField("Textfield2", text: $text2)
.textFieldStyle(.roundedBorder)
} header: {
Text("Header")
}
}
.listStyle(.insetGrouped)
.navigationTitle("List")
.scrollDismissesKeyboard(.immediately)
}
}
Im only using default components in this sample, so I don't see why this animation does not work as intended (smooth).
Has anyone a solution to this problem?