sodalive-ios/SodaLive/Sources/User/Login/LoginView.swift

116 lines
4.3 KiB
Swift

//
// LoginView.swift
// SodaLive
//
// Created by klaus on 2023/08/09.
//
import SwiftUI
import PopupView
struct LoginView: View {
@ObservedObject var viewModel = LoginViewModel()
@State private var isPasswordVisible: Bool = false
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
VStack(spacing: 0) {
HomeNavigationBar(title: "로그인") {}
Spacer()
TextField("이메일", text: $viewModel.email)
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 15))
.foregroundColor(.grayee)
.keyboardType(.emailAddress)
.padding(.vertical, 18)
.padding(.horizontal, 13.3)
.frame(height: 56)
.background(RoundedRectangle(cornerRadius: 6.7).fill(Color.gray33.opacity(0.7)))
.padding(.horizontal, 13.3)
HStack {
Group {
if isPasswordVisible {
TextField("비밀번호", text: $viewModel.password)
} else {
SecureField("비밀번호", text: $viewModel.password)
}
}
.autocapitalization(.none)
.disableAutocorrection(true)
.font(.custom(Font.medium.rawValue, size: 15))
.foregroundColor(.grayee)
Spacer()
Image(systemName: isPasswordVisible ? "eye.slash.fill" : "eye.fill")
.foregroundColor(.grayee)
.onTapGesture {
isPasswordVisible.toggle()
}
}
.padding(.vertical, 18)
.padding(.horizontal, 13.3)
.frame(height: 56)
.background(RoundedRectangle(cornerRadius: 6.7).fill(Color.gray33.opacity(0.7)))
.padding(.horizontal, 13.3)
.padding(.top, 16)
Button(action: { viewModel.login() }) {
Text("로그인")
.font(.custom(Font.bold.rawValue, size: 15))
.frame(width: screenSize().width - 26.6, height: 46.7)
.foregroundColor(.white)
.background(Color.button)
.cornerRadius(6.7)
}
.padding(.top, 40)
Text("비밀번호를 잊으셨나요?")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color.graybb)
.padding(.vertical, 10)
.onTapGesture { AppState.shared.setAppStep(step: .findPassword) }
.padding(.top, 30)
Text("보이스온 회원이 아닌가요? 지금 가입하세요.")
.font(.custom(Font.medium.rawValue, size: 13.3))
.foregroundColor(Color.graybb)
.padding(.vertical, 10)
.onTapGesture { AppState.shared.setAppStep(step: .signUp) }
.padding(.top, 20)
Spacer()
}
}
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
GeometryReader { geo in
HStack {
Spacer()
Text(viewModel.errorMessage)
.padding(.vertical, 13.3)
.frame(width: geo.size.width - 66.7, alignment: .center)
.font(.custom(Font.medium.rawValue, size: 12))
.background(Color.button)
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.cornerRadius(20)
.padding(.top, 66.7)
Spacer()
}
}
}
}
}
struct LoginView_Previews: PreviewProvider {
static var previews: some View {
LoginView()
}
}