I connected my SwiftUI app to Firebase Auth and Firestore, and the data is stored in a collection.
My question is, how can I read specific data from the signed In user and display his data without a List?
An example, the navigation title will be like this:
Text("Hello \(The signed In user's name)")
and so on.
Any helpful sites or videos?
Post
Replies
Boosts
Views
Activity
I have two collections in Firestore (Instructor, Student), and each collection has a bunch of documents. How can I access each document with the Auth method?
And I have two buttons: (Log in as Student, Log in as Instructor). I want each button to access the collection and the wanted document.
Button1: Log in as Student -> "Student" collection.
Button2: Log in as Instructor -> "Instructor" collection.
Is there any way to show alerts in Swiftui without using the "toggle" and writing (.alert(isPresented:content:))?
I'm using a list with a navigation link in my swiftui app, and I'm not using a ForEach loop and trying to put the ".onDelete "method but I don't know how can I do that. Can you help me?
NavigationView {
List(courses) {course in
NavigationLink(destination: CourseDetails(course: course)) {
StudentExtractedCourses(course: course)
}
}
}
I have two collections (Student, Instructor) in Firestore, and each collection has documents with Auto-ID. I want to specify two buttons (Log in as Student, log in as Instructor) with the database, which means if you are a student and your information is in a collection, you only can log in as Student but you can't log in as Instructor, and the same for the Instructor.
Recently I created a Swiftui project and connected it with my firestore firebase, and I have two documents (Student, Instructor).
And in my project, I have two buttons (Login as Student, log in as Instructor), how can I connect the two buttons to fit with these documents respectively?
In summary, the "Login as Student" button should ONLY access the "Student" document, and the "Log in as Instructor" button should ONLY access the "Instructor" document.
I built a registration page in Swiftui with 8 text fields and connected it successfully with Firestore Firebase.
The problem is, I have declared many conditionals for:
The user must check the password strength before pressing the "Register Button".
If one of the fields is empty, this will occur an error.
The password and re-password must be matched.
If nothing is wrong, the user should see that he/she successfully registered.
After registering, the fields should be empty.
The button declaration:
Button(action: {
alertPresented.toggle()
// //Text Fields
// firstName = ""
// lastName = ""
// email = ""
// password = ""
// phoneNum = ""
// studentID = ""
// coursesNum = ""
// repassword = ""
// //After checking the strength
// passwordStatus = ""
}) {
Text("Register")
}
.padding(12)
.frame(width: UIScreen.main.bounds.width - 150)
.background(Color("Color"))
.foregroundColor(.white)
.cornerRadius(8)
.alert(isPresented: $alertPresented, content: {
getAlerts()
})
}
The getAlerts function:
func getAlerts() -> Alert {
if self.password != self.repassword {
return Alert(title: Text("Error!"), message: Text("The passwords NOT matching"), dismissButton: .default(Text("OK!")))
}
if (self.firstName == "") && (self.lastName == "") && (self.email == "") && (self.password == "") && (self.repassword == "") && (self.studentID == "") && (self.phoneNum == "") && (self.coursesNum == "") {
return Alert(title: Text("Error!"), message: Text("Something MISSING!"), dismissButton: .default(Text("Got it!")))
}
if self.passwordStatus == "Weak" {
return Alert(title: Text("Error!"), message: Text("You can't register if the password is WEAK!"), dismissButton: .default(Text("Got it!")))
}
if trigger == 0 {
return Alert(title: Text("Error!"), message: Text("Please check the strength first"), dismissButton: .default(Text("Got it!")))
} else {
data.addData(firstName: firstName, lastName: lastName, email: email, password: password, phoneNum: phoneNum, studentID: studentID, coursesNum: coursesNum)
return Alert(title: Text("Congrats!!"), message: Text("You successfully REGISTERED, you can go back to Login"), dismissButton: .default(Text("Awesome!!")))
}
}
The problem is when everything is correct and I press the Register button, I got more than 5 documents in Firestore, and the "Something Missing" alert shows, and the fields went empty.
I am trying to build a new ios app (Clicker), which is an educational app for universities.
I want to build it using SwiftUI NOT Storyboard, and its features are:
Login and register with Firebase.
Students can put their attendance when they are asked by the instructor.
The instructor can make a pop quiz, and he/she can choose the quiz type: Multiple Choice/Polls/Yes or No.
The quiz results will be shown on the instructor's account.
And other features.
So, what should I learn to make a progress with it?
If something is not clear, please reply to this question.