Cannot find 'Email' in scope;Cannot find 'PAssword' in scope;Cannot find 'RsWpassword' in scope

import SwiftUI import Firebase

struct ContentView: View { @State var email: String = "" @State var password: String = "" @State var showLogin: Bool = true var body: some View { NavigationView{ VStack { Image(systemName: "globe").resizable().frame(width: 150, height: 150).padding(20) Text("Login").font(.system(size: 22)).foregroundColor(Color.black).padding(10) Email(Email: self.$email).padding(10) Password(Password: self.$password).padding(10) NavigationLink(destination: RswPassword (email: self.$email, password: self.$password, showLogin: self.$showLogin)) { Text("Reset Password ") }.padding(20)

            Button(action:{
                //Procedura Login   firebase
                Auth.auth().signIn(withEmail: self.email, password: self.password) { (result, errore) in
                    if errore != nil {
                        print("errore login")
                    } else {
                        print("login effettuato")
                    }
                    
                }
                
            }) {
                Text("Accedi")
                    .font(.system(size: 14))
                    .foregroundColor(Color.black)
                    .padding()
                    .frame(minWidth: 0, maxHeight: .infinity)
                    .frame(height: 40)
            }.padding(10)
            
            Button(action :{
                //procedura Registrazione Firebase
            }) {
                Text("Registrati ")
                    .font(.system(size: 13))
            }
        }
    }
    struct RswPAssword: View {
        @Binding var email:  String
        @Binding var password: String
        @Binding var showLogin: Bool
        var body: some View {
            VStack {
                Image("globe").resizable().frame(width: 150, height: 150).padding(20)
                Text("Resetta la password").padding(20).font(.system(size: 22)).foregroundColor(Color.black)
                Email(Email: self.$email).padding(10)
                Button (action: {
                    //procedura reset password
                    Auth.auth().sendPasswordReset(withEmail: self.email) { (error) in
                        if error != nil {
                            print("errore nel reset ")
                            
                        } else {
                            print("email inviata con sucesso")
                            self.showLogin.toggle()
                        }
                        
                    }
                }) {
                    Text("resetta password")
                        .font(.system(size: 14))
                        .foregroundColor(Color.black)
                        .padding()
                        .frame(minWidth: 0, maxWidth: .infinity)
                        .frame(height: 40)
                        .background(Color.black)
                }.padding(10)
            }
        }
        struct Email: View  {
            @Binding var email: String
            var body: some View {
                TextField("Email", text: $email)
                    .font(.system(size: 14))
                    .padding(12)
                    .background(RoundedRectangle(cornerRadius: 5).stroke(Color.black))
                    .foregroundColor(Color.black)
                
            }
        }
        
        struct Password: View {
            @Binding var password: String
            var body: some View {
                TextField("Password", text: $password)
                    .font(.system(size: 14))
                    .padding(12)
                    .background(RoundedRectangle(cornerRadius: 5).stroke(Color.black))
                    .foregroundColor(Color.black)
                
            }
        }
        
        
        
        
        struct ContentView_Previews: PreviewProvider {
            static var previews: some View {
                ContentView()
            }
        }
    }
}

}

Answered by JesusMG in 750735022

Which are the conflict lines? Could you edit the example again to view it more clear?


I think you are declaring structs inside the ContentView body.

if you do it outside of it, should work.

Cannot find 'Email' in scope Cannot find 'Password' in scope Cannot find 'Rswpassword' in scope

there are errors, Can anyone help me? I'm trying to create a loginpage with email thanks you :)

Accepted Answer

Which are the conflict lines? Could you edit the example again to view it more clear?


I think you are declaring structs inside the ContentView body.

if you do it outside of it, should work.

Cannot find 'Email' in scope;Cannot find 'PAssword' in scope;Cannot find 'RsWpassword' in scope
 
 
Q