Whenever i click in my textfield, the keyboard is overlapping my button, and i would like that the view would go up to have space between the button and keyboard
this is my code
import SwiftUI
@MainActor
struct SignUpView: View {
var body: some View {
ScrollViewReader { scrollView in
ScrollView {
VStack {
header
signUpText
signUpFields
button
}
.padding(.horizontal, 30)
.onAppear {
focusField = .fullName
}
.background(Color.background.onTapGesture {
focusField = nil
})
}
.clipped() //Clips the view within the scrollView
.background(Color.background.ignoresSafeArea())
}
}
}
var signUpFields: some View {
VStack(spacing: 30) {
TextfieldsLayout(fieldType: .textFieldType, placeholder: "Full name", prefix: {Image(systemName: "person.fill")}, text: $loginVM.name, keyboardType: .default)
.textContentType(.name)
.focused($focusField, equals: .fullName)
.submitLabel(.next)
.onSubmit {
focusField = .email
}
.onChange(of: loginVM.name) {
loginVM.buttonEnableForSignUp()
}
TextfieldsLayout(fieldType: .textFieldType, placeholder: "Email", prefix: {Text("@")}, text: $loginVM.email, keyboardType: .emailAddress)
.textContentType(.emailAddress)
.focused($focusField, equals: .email)
.submitLabel(.next)
.onSubmit {
focusField = .password
}
.onChange(of: loginVM.email) {
loginVM.buttonEnableForSignUp()
}
TextfieldsLayout(fieldType: .secureFieldType, placeholder: "Password", iconPrefix: {Image(systemName: "lock.fill")}, text: $loginVM.password, keyboardType: .default, isPasswordVisible: $isPasswordVisible, forgotButtonEnable: false)
.textContentType(.password)
.focused($focusField, equals: .password)
.submitLabel(.done)
.onSubmit {
focusField = nil
}
.onChange(of: loginVM.password) {
loginVM.buttonEnableForSignUp()
}
}
.padding(.top, 10)
}
I was using scrollReaderView but without success.
anyone had the same issue?
please some asnwer.
thank you
Recognized by Mobile Development Collective
1