로그인, 비밀번호 찾기, 회원가입

- TextField 터치영역 개선
This commit is contained in:
Yu Sung
2025-03-31 21:12:24 +09:00
parent 1f72e72627
commit 711ffbcb83
3 changed files with 86 additions and 8 deletions

View File

@@ -9,10 +9,16 @@ import SwiftUI
struct SignUpView: View {
enum FocusField: Hashable {
case email, password
}
@ObservedObject var viewModel = SignUpViewModel()
@StateObject var keyboardHandler = KeyboardHandler()
@State private var isPasswordVisible: Bool = false
@FocusState private var focusedField: FocusField?
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
GeometryReader { proxy in
@@ -22,6 +28,8 @@ struct SignUpView: View {
ScrollView(.vertical, showsIndicators: false) {
VStack(spacing: 0) {
TextField("이메일", text: $viewModel.email)
.submitLabel(.next)
.focused($focusedField, equals: .email)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 15))
@@ -33,6 +41,12 @@ struct SignUpView: View {
.background(RoundedRectangle(cornerRadius: 6.7).fill(Color.gray33.opacity(0.7)))
.padding(.horizontal, 13.3)
.padding(.top, 13.3)
.onSubmit {
self.focusedField = .password
}
.onTapGesture {
self.focusedField = .email
}
HStack {
Group {
@@ -42,6 +56,8 @@ struct SignUpView: View {
SecureField("비밀번호", text: $viewModel.password)
}
}
.submitLabel(.done)
.focused($focusedField, equals: .password)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 15))
@@ -52,6 +68,7 @@ struct SignUpView: View {
Image(systemName: isPasswordVisible ? "eye.slash.fill" : "eye.fill")
.foregroundColor(.grayee)
.onTapGesture {
hideKeyboard()
isPasswordVisible.toggle()
}
}
@@ -61,6 +78,9 @@ struct SignUpView: View {
.background(RoundedRectangle(cornerRadius: 6.7).fill(Color.gray33.opacity(0.7)))
.padding(.horizontal, 13.3)
.padding(.top, 16)
.onTapGesture {
self.focusedField = .password
}
VStack(spacing: 5) {
HStack(spacing: 10) {
@@ -70,7 +90,10 @@ struct SignUpView: View {
"btn_select_normal"
)
.padding(10)
.onTapGesture { viewModel.isAgreeTerms.toggle() }
.onTapGesture {
hideKeyboard()
viewModel.isAgreeTerms.toggle()
}
HStack(spacing: 5) {
Text("이용약관")
@@ -88,7 +111,10 @@ struct SignUpView: View {
Spacer()
}
.contentShape(Rectangle())
.onTapGesture { viewModel.isAgreeTerms.toggle() }
.onTapGesture {
hideKeyboard()
viewModel.isAgreeTerms.toggle()
}
HStack(spacing: 10) {
Image(
@@ -97,7 +123,10 @@ struct SignUpView: View {
"btn_select_normal"
)
.padding(10)
.onTapGesture { viewModel.isAgreePrivacyPolicy.toggle() }
.onTapGesture {
hideKeyboard()
viewModel.isAgreePrivacyPolicy.toggle()
}
HStack(spacing: 5) {
Text("개인정보수집 및 이용동의")
@@ -115,7 +144,10 @@ struct SignUpView: View {
Spacer()
}
.contentShape(Rectangle())
.onTapGesture { viewModel.isAgreePrivacyPolicy.toggle() }
.onTapGesture {
hideKeyboard()
viewModel.isAgreePrivacyPolicy.toggle()
}
}
.padding(.top, 20)
.padding(.horizontal, 13.3)
@@ -129,7 +161,10 @@ struct SignUpView: View {
.cornerRadius(10)
.padding(.horizontal, 13.3)
.contentShape(Rectangle())
.onTapGesture { viewModel.signUp() }
.onTapGesture {
hideKeyboard()
viewModel.signUp()
}
.padding(.top, 26.7)
Rectangle()
@@ -145,6 +180,9 @@ struct SignUpView: View {
}
}
.edgesIgnoringSafeArea(.bottom)
.onAppear {
focusedField = .email
}
.onTapGesture {
hideKeyboard()
}