From 37cc5b055f732643f7adfec5938a3c554a5ef94a Mon Sep 17 00:00:00 2001 From: Trey t Date: Wed, 16 Aug 2023 21:34:13 -0500 Subject: [PATCH] WIP --- Werkout_ios/Views/Login/LoginView.swift | 33 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Werkout_ios/Views/Login/LoginView.swift b/Werkout_ios/Views/Login/LoginView.swift index 171f85b..6f65bdd 100644 --- a/Werkout_ios/Views/Login/LoginView.swift +++ b/Werkout_ios/Views/Login/LoginView.swift @@ -12,6 +12,7 @@ struct LoginView: View { @State var password: String = "" @Environment(\.dismiss) var dismiss let completion: (() -> Void) + @State var doingNetworkShit: Bool = false var body: some View { VStack { @@ -35,19 +36,27 @@ struct LoginView: View { .overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 255/255, green: 255/255, blue: 255/255, alpha: 1))) .cornerRadius(8) - Button("Login", action: { - login() - }) - .frame(maxWidth: .infinity, alignment: .center) - .frame(height: 44) - .foregroundColor(.blue) - .background(.yellow) - .cornerRadius(8) - .padding() - .frame(maxWidth: .infinity) + if doingNetworkShit { + ProgressView("Logging In") + .padding() + .foregroundColor(.white) + .progressViewStyle(CircularProgressViewStyle(tint: .white)) + .scaleEffect(1.5, anchor: .center) + } else { + Button("Login", action: { + login() + }) + .frame(maxWidth: .infinity, alignment: .center) + .frame(height: 44) + .foregroundColor(.blue) + .background(.yellow) + .cornerRadius(8) + .padding() + .frame(maxWidth: .infinity) + .disabled(password.isEmpty || email.isEmpty) + } Spacer() - } .padding() .background( @@ -63,7 +72,9 @@ struct LoginView: View { "email": email, "password": password ] + doingNetworkShit = true UserStore.shared.login(postData: postData, completion: { success in + doingNetworkShit = false if success { completion() dismiss()