I have a class where I get data from firebase. But I can't get it exactly as I want, for example document("abc" ) here I need to get the name "abc" from another place, different name may come according to each click. I can't assign this to the class I'm getting the data from, can you help me?
import Firebase
struct StadiumNameView: View {
var body: some View {
VStack{
List(stadiumnameeeee) { i in
NavigationLink(destination: SelectedStadiumView(selectedStadium:i.name)){
Text(i.name)
}
}
}
}
}
struct StadiumNameView_Previews: PreviewProvider {
static var previews: some View {
StadiumNameView()
}
}
I need to pass the "i.name" here to the following class.
import Firebase
class UserInfoModel : ObservableObject {
@Published var city=""
@Published var email=""
@Published var name=""
@Published var surname=""
@Published var phone=""
@Published var town=""
@Published var type=""
@Published var id=""
@Published var birthday=""
@Published var favStadium=[String]()
init(){
let db=Firestore.firestore()
db.collection("Users").document(Auth.auth().currentUser!.uid).addSnapshotListener { (snapshot, error) in
if error == nil {
if let city=snapshot?.get("City") as? String {
self.city=city
}
if let email=snapshot?.get("Email") as? String {
self.email=email
}
if let name=snapshot?.get("Name") as? String {
self.name=name
}
if let surname=snapshot?.get("Surname") as? String {
self.surname=surname
}
if let phonenumber=snapshot?.get("Phone") as? String {
self.phone=phonenumber
}
if let town=snapshot?.get("Town") as? String {
self.town=town
}
if let type=snapshot?.get("Type") as? String {
self.type=type
}
if let id=snapshot?.get("User") as? String {
self.id=id
}
if let birthday=snapshot?.get("DateofBirth") as? String {
self.birthday=birthday
}
if let favStadiums=snapshot?.get("FavoriteStadiums") as? [String]{
self.favStadium=favStadiums
}
}
}
}
}