// // LoginView.swift // Werkout_ios // // Created by Trey Tartt on 6/25/23. // import SwiftUI struct LoginView: View { @State var email: String = "" @State var password: String = "" @Environment(\.dismiss) var dismiss let completion: (() -> Void) var body: some View { VStack { Text("Login") .font(.title) TextField("Email", text: $email) .autocapitalization(.none) .frame(height: 55) .textFieldStyle(PlainTextFieldStyle()) .padding([.horizontal], 4) .overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2))) .cornerRadius(8) TextField("Password", text: $password) .autocapitalization(.none) .frame(height: 55) .textFieldStyle(PlainTextFieldStyle()) .padding([.horizontal], 4) .overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 200/255, green: 200/255, blue: 200/255, alpha: 0.2))) .cornerRadius(8) Button("Login", action: { login() }) .frame(maxWidth: .infinity, alignment: .center) .frame(height: 44) .foregroundColor(.blue) .background(.yellow) .cornerRadius(8) .padding() .frame(maxWidth: .infinity) Spacer() } .padding() } func login() { let postData = [ "email": email, "password": password ] UserStore.shared.login(postData: postData, completion: { success in if success { completion() dismiss() } }) } } struct LoginView_Previews: PreviewProvider { static var previews: some View { LoginView(completion: { }) } }