sodalive-ios/SodaLive/Sources/User/UserTextField.swift

85 lines
2.7 KiB
Swift

//
// UserTextField.swift
// SodaLive
//
// Created by klaus on 2023/08/09.
//
import SwiftUI
struct UserTextField: View {
let title: String
let hint: String
let isSecure: Bool
@Binding var variable: String
var isPasswordVisibleButton: Bool = false
var keyboardType: UIKeyboardType = .default
@State private var visiblePassword = false
var body: some View {
VStack(alignment: .leading, spacing: 0) {
Text(title)
.font(.custom(Font.medium.rawValue, size: 12))
.foregroundColor(Color(hex: "eeeeee"))
.padding(.leading, 6.7)
if isSecure && !visiblePassword{
SecureField(hint, text: $variable)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
.padding(.top, 12)
.padding(.leading, 6.7)
} else {
TextField(hint, text: $variable)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
.keyboardType(keyboardType)
.padding(.top, 12)
.padding(.leading, 6.7)
}
Divider()
.frame(height: 0.3)
.foregroundColor(Color(hex: "909090"))
.padding(.top, 8.3)
if isSecure && isPasswordVisibleButton {
Button(action: { visiblePassword.toggle() }) {
HStack(spacing: 13.3) {
if visiblePassword {
Image("btn_select_checked")
} else {
Image("btn_select_normal")
}
Text("비밀번호 표시")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color(hex: "eeeeee"))
}
}
.padding(.top, 20)
.padding(.leading, 6.7)
}
}
}
}
struct UserTextField_Previews: PreviewProvider {
static var previews: some View {
UserTextField(
title: "이메일",
hint: "user_id@email.com",
isSecure: true,
variable: .constant("test"),
isPasswordVisibleButton: true
)
}
}