// // AccountLoginView.swift // AcaMate // // Created by Sean Kim on 12/14/24. // import SwiftUI struct AccountLoginView: View { @ObservedObject var viewModel: LoginViewModel @Binding var userId: String @Binding var password: String @Binding var isSecure: Bool @Binding var isSave: Bool var body: some View { VStack(spacing: 0) { ZStack(alignment: .leading) { if userId.isEmpty { Text("아이디를 입력하세요.") .font(.nps(font: .regular, size: 16)) .foregroundStyle(Color(.Text.border)) .padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 24)) } CustomTextField(placeholder: "", text: $userId) .frame(maxWidth: .infinity,maxHeight: 24) .padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 24)) } .background { RoundedRectangle(cornerRadius: 24) .foregroundStyle(.white) } .padding(EdgeInsets(top: 0, leading: 12, bottom: 8, trailing: 12)) ZStack(alignment: .leading) { if password.isEmpty { Text("비밀번호를 입력하세요.") .font(.nps(font: .regular, size: 16)) .foregroundStyle(Color(.Text.border)) .padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 24)) } CustomTextField(placeholder: "", text: $password, isSecure: $isSecure) .frame(maxWidth: .infinity,maxHeight: 24) .padding(EdgeInsets(top: 12, leading: 24, bottom: 12, trailing: 24)) HStack { Spacer() Button { isSecure.toggle() } label: { if password.isEmpty { Rectangle() .frame(width: 16, height: 2) .foregroundStyle(Color(.Text.border)) .padding(.trailing,24) } else { if isSecure { Image(systemName: "eye") .frame(width: 16, height: 16) .foregroundStyle(Color(.Text.detail)) .padding(.trailing,24) } else { Image(systemName: "eye.slash") .frame(width: 16, height: 16) .foregroundStyle(Color(.Text.detail)) .padding(.trailing,24) } } } } } .background { RoundedRectangle(cornerRadius: 24) .foregroundStyle(.white) } .padding(EdgeInsets(top: 0, leading: 12, bottom: 8, trailing: 12)) Button { isSave.toggle() } label: { HStack(alignment: .center, spacing: 4) { Spacer(minLength: 1) if isSave { Image(systemName: "checkmark.square") .foregroundStyle(Color(.Second.normal)) .frame(width: 24, height: 24) } else { Image(systemName: "square") .foregroundStyle(Color(.Second.normal)) .frame(width: 24, height: 24) } Text("로그인 정보 저장") .font(.nps(font: .regular, size: 16)) .foregroundStyle(Color(.Text.detail)) } } .padding(EdgeInsets(top: 0, leading: 0, bottom: 24, trailing: 12)) Button { viewModel.loginAction.send(true) } label: { Text("로그인") .font(.nps(font: .bold, size: 24)) .foregroundStyle(Color(.Text.white)) .padding(EdgeInsets(top: 8, leading: 48, bottom: 8, trailing: 48)) .background{ RoundedRectangle(cornerRadius: 12) .foregroundStyle(Color(.Second.normal)) } } } } }