Hi! I have that bug in the title, so can you please help me? I don’t know how to fix it, but I’m trying to follow a video to create a Log-in page. Here is my code, thanks.
import SwiftUI
struct ContentView: View {
var body: some View {
Home()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct Home : View {
var body: some View {
VStack {
SignUp()
}
}
}
struct Login : View {
@State var color = Color.black.opacity(1.0)
@State var email = ""
@State var pass = ""
@State var visible = false
var body: some View {
ZStack(alignment: .topTrailing){
GeometryReader{_ in
VStack {
Image("logo")
Text("Log into your account")
.font(.title)
.fontWeight(.bold)
.foregroundColor(self.color)
.padding(.top, 35)
TextField("Email", text: self.$email)
.padding()
.background(RoundedRectangle(cornerRadius: 4).stroke(self.email != "" ? Color (.black) : self.color, lineWidth: 2))
.padding(.top, 35)
HStack(spacing: 15){
VStack{
if self.visible{
TextField("Password", text: self.$pass)
}
else{
SecureField("Password", text: self.$pass)
}
}
Button(action: {
self.visible.toggle()
}) {
Image(systemName: self.visible ? "eye.slash.fill" : "eye.fill")
.foregroundColor(self.color)
}
}
.padding()
.background(RoundedRectangle(cornerRadius: 4).stroke(self.pass != "" ? Color (.black) : self.color, lineWidth: 2))
.padding(.top, 25)
HStack{
Spacer()
Button(action: {
}) {
Text("Forgot password?")
.fontWeight(.bold)
.foregroundColor(Color(.black))
.padding()
}
}
.padding(.top, 25)
Button(action: {
}) {
Text("Log in")
.foregroundColor(.black)
.padding(.vertical)
.frame(width: UIScreen.main.bounds.width - 50)
.background(Color.white)
.padding(10)
.border(Color.purple, width: 5)
}
.background(Color("Color"))
.cornerRadius(10)
.padding(.top, 25)
}
.padding(.horizontal, 25)
}
Button(action: {
}) {
Text("Register")
.fontWeight(.semibold)
.foregroundColor(Color(.black))
}
.padding()
}
}
}
struct SignUp : View {
@State var color = Color.black.opacity(1.0)
@State var email = “”
@State var pass = “”
@State var repass = “”
@State var visible = false
@State var revisible = false
var body: some View {
ZStack(alignment: .topLeading){
GeometryReader{_ in
VStack {
Image("logo")
Text("Log into your account")
.font(.title)
.fontWeight(.bold)
.foregroundColor(self.color)
.padding(.top, 35)
TextField("Email", text: self.$email)
.padding()
.background(RoundedRectangle(cornerRadius: 4).stroke(self.email != "" ? Color (.black) : self.color, lineWidth: 2))
.padding(.top, 25)
HStack(spacing: 15){
VStack{
if self.visible{
TextField("Password", text: self.$pass)
}
else{
SecureField("Password", text: self.$pass)
}
}
Button(action: {
self.visible.toggle()
}) {
Image(systemName: self.visible ? "eye.slash.fill" : "eye.fill")
.foregroundColor(self.color)
}
}
.padding()
.background(RoundedRectangle(cornerRadius: 4).stroke(self.pass != "" ? Color (.black) : self.color, lineWidth: 2))
.padding(.top, 25)
HStack(spacing: 15){
VStack{
if self.revisible{
TextField("Password", text: self.$repass)
}
else{
SecureField("Password", text: self.$repass)
}
}
Button(action: {
self.revisible.toggle()
}) {
Image(systemName: self.revisible ? "eye.slash.fill" : "eye.fill")
.foregroundColor(self.color)
}
}
.padding()
.background(RoundedRectangle(cornerRadius: 4).stroke(self.pass != "" ? Color (.black) : self.color, lineWidth: 2))
.padding(.top, 25)
Button(action: {
}) {
Text("Register")
.fontWeight(.bold)
.foregroundColor(Color(.black))
.padding()
}
}
.padding(.top, 25)
Button(action: {
}) {
Text("Log in")
.foregroundColor(.black)
.padding(.vertical)
.frame(width: UIScreen.main.bounds.width - 50)
.background(Color.white)
.padding(10)
.border(Color.purple, width: 5)
}
.background(Color("Color"))
.cornerRadius(10)
.padding(.top, 25)
}
.padding(.horizontal, 25)
}
Button(action: {
}) {
Image(systemName: "chevron.left")
.font(.title)
.foregroundColor(Color(.black))
}
.padding()
}
}