I don't know what I have this error : cannot convert return expression of any view to return type some view
I try some things but nothing nothing worked... And I found nothing on the web
Thanks for your help...
struct LoginView: View {
@Binding var showCreateAccount: Bool
@State private var email = ""
@State private var password = ""
@State private var formOffset: CGFloat = 0
@State private var presentPasswordRecoverySheet = false
var body: some View {
VStack {
VStack(spacing: 40) {
Image("Logo")
Text("Login").font(.title).bold()
VStack {
RoundTextfield(value: self.$email, placeholder: "Email", icon: Image(systemName: "at"),
onEditingChanged: { flag in withAnimation { self.formOffset = flag ? -150 : 0 } })
RoundTextfield(value: self.$password, placeholder: "Password", icon: Image(systemName: "lock"), isSecure: true,
onEditingChanged: { flag in withAnimation { self.formOffset = flag ? -150 : 0 } })
BasicButton(text: "Login") {}
}
Button(action: { withAnimation(.spring() ) { self.showCreateAccount.toggle() } } )
{
HStack { Text("Don't have an account? Sign up.").accentColor(Color.accentColor) }
}
Button(action: { self.presentPasswordRecoverySheet.toggle() } )
{
HStack { Text("Forgot your password?").accentColor(Color.purple) }
}
.sheet(isPresented: self.$presentPasswordRecoverySheet)
{ RecoverPasswordView(presentPasswordRecoverySheet: self.$presentPasswordRecoverySheet) }
}
.padding()
.offset(y: self.formOffset)
}
}
This is my BasicButton code, but I think this is not the problem
struct BasicButton: View {
var text = "Next"
var action: (()->()) = {}
var body: some View {
Button(action: {
self.action()
}) {
HStack {
Text(text)
.bold()
.frame(minWidth: 0, maxWidth: .infinity)
.padding(.vertical)
.accentColor(Color.white)
.background(Color("accentColor"))
.cornerRadius(30)
}
}
}
}
struct BasicButton_Previews: PreviewProvider {
static var previews: some View {
BasicButton()
}
When I remove the two button function for create account and forgot password, the code can build