Код: Выделить всё
struct LoginView: View {
@State private var email = ""
@State private var password = ""
@Environment(\.presentationMode) private var presentationMode
@EnvironmentObject var viewModel: AuthViewModel
var body: some View {
ZStack {
VStack {
...
...
...
CustomTextField(icon: "mail", placeholder: "Email", text: $email)
CustomTextField(icon: "lock", placeholder: "Password", text: $password, isSecure: true)
}
}
}
}
Код: Выделить всё
struct CustomTextField: View {
var icon: String
var placeholder: String
@Binding var text: String
var isSecure: Bool = false
var body: some View {
HStack {
Image(systemName: icon)
.foregroundColor(.gray)
if isSecure {
SecureField(placeholder, text: $text)
} else {
TextField(placeholder, text: $text)
}
}
.padding()
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray, lineWidth: 1)
)
.padding(.horizontal)
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... ile-typing
Мобильная версия