ContentView.swift
// // ContentView.swift // SwiftUIProject // // Created by Cairocoders // import SwiftUI struct ContentView: View { var body: some View { NavigationView{ SignIn() .navigationBarTitle("") .navigationBarHidden(true) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct SignIn : View { @State var user = "" @State var pass = "" @State var show = false var body : some View{ ZStack{ NavigationLink(destination: Register(show: self.$show), isActive: self.$show) { Text("") } VStack{ HStack{ Image("bgtop") .resizable() Spacer() } VStack{ Image("logo") .resizable() .frame(width: 150, height: 130, alignment: .center) }.offset(y: -40) .padding(.bottom,-60) VStack(spacing: 20){ Text("Sign In").font(.title).fontWeight(.bold) Text("Sign Into Your Account").fontWeight(.bold) CustomField(value: self.$user, isemail: true) CustomField(value: self.$pass, isemail: false) HStack{ Spacer() Button(action: { }) { Text("Forget Password ?").foregroundColor(Color.black.opacity(0.1)) } } Button(action: { loginUser() }) { Text("Login") .frame(width: UIScreen.main.bounds.width - 100) .padding(.vertical) .foregroundColor(.white) }.background(Color("Color1")) .clipShape(Capsule()) Text("Or Login Using Social Media").fontWeight(.bold) SocialMedia() }.padding() .background(Color.white) .cornerRadius(5) .padding() HStack{ Text("Don't Have an Account ?") Button(action: { self.show.toggle() }) { Text("Register Now").foregroundColor(Color("Color1")) } }.padding(.top) Spacer(minLength: 0) }.edgesIgnoringSafeArea(.top) .background(Color("Color").edgesIgnoringSafeArea(.all)) } } private func loginUser() { print("email : \(user) pass : \(pass)") } } struct CustomField : View { @Binding var value : String var isemail = false var reenter = false @State private var showText: Bool = false var body : some View{ VStack(spacing: 8){ HStack{ Text(self.isemail ? "Email ID" : self.reenter ? "Re-Enter" : "Password").foregroundColor(Color.black.opacity(0.1)) Spacer() } HStack{ if self.isemail{ TextField("", text: self.$value) Image(systemName: "envelope.fill").foregroundColor(Color("Color1")) } else{ if showText { TextField("", text: self.$value) }else{ SecureField("", text: self.$value) .disableAutocorrection(true) .autocapitalization(.none) } Button(action: { showText.toggle() }, label: { Image(systemName: showText ? "eye.slash.fill" : "eye.fill") .foregroundColor(Color("Color1")) }) } } Divider() } } }Register.swift
// // Register.swift // SwiftUIProject // // Created by Cairocoders // import SwiftUI struct Register : View { @State var user = "" @State var pass = "" @State var repass = "" @State var agree = false @Binding var show : Bool var body : some View{ ZStack(alignment: .topLeading) { VStack{ VStack{ Image("logo") .resizable() .frame(width: 150, height: 130, alignment: .center) }.offset(y: 50) .padding(.bottom,90) VStack(spacing: 20){ Text("Sign Up").font(.title).fontWeight(.bold) Text("Sign Into Your Account").fontWeight(.bold) CustomField(value: self.$user, isemail: true) CustomField(value: self.$pass, isemail: false) CustomField(value: self.$repass, isemail: false,reenter: true) HStack{ Button(action: { self.agree.toggle() }) { ZStack{ Circle().fill(Color.black.opacity(0.05)).frame(width: 20, height: 20) if self.agree{ Image("check").resizable().frame(width: 10, height: 10) .foregroundColor(Color("Color1")) } } } Text("I Read And Agree The Terms And Conditions").font(.caption) .foregroundColor(Color.black.opacity(0.1)) Spacer() } Button(action: { }) { Text("Register Now") .frame(width: UIScreen.main.bounds.width - 100) .padding(.vertical) .foregroundColor(.white) }.background(Color("Color1")) .clipShape(Capsule()) Text("Or Register Using Social Media").fontWeight(.bold) SocialMedia() }.padding() .background(Color.white) .cornerRadius(5) .padding() Spacer(minLength: 0) }.edgesIgnoringSafeArea(.top) .background(Color("Color").edgesIgnoringSafeArea(.all)) Button(action: { self.show.toggle() }) { Image(systemName: "arrow.left").resizable().frame(width: 18, height: 15).foregroundColor(.black) }.padding() }.navigationBarTitle("") .navigationBarHidden(true) } } struct Register_Previews: PreviewProvider { @State static var show = false static var previews: some View { Register(show: $show) } }SocialMedia.swift
// // SocialMedia.swift // SwiftUIProject // // Created by Cairocoders // import SwiftUI struct SocialMedia : View { var body : some View{ HStack(spacing: 40){ Button(action: { }) { Image("fb").renderingMode(.original) } Button(action: { }) { Image("twitter").renderingMode(.original) } } } } struct SocialMedia_Previews: PreviewProvider { static var previews: some View { SocialMedia() } }