P
P
Poshy152020-12-10 08:37:48
iOS
Poshy15, 2020-12-10 08:37:48

How to perform click transition in Swift to view?

struct TextLinkPropertyView : View {
    let name : String;
    let value : String;
    let id : String;
    let object : String;
    
    var body: some View {
        VStack(alignment: .leading) {
            Text(name).font(.headline)
            Button(action: {

                  //Тут должен быть переход к View, но это не работает
                  //ItemDetailsView(id:item.id, name : item.name, entityType: self.entityType)

            }) {
                Text(id)
            }.padding(EdgeInsets(top: 2, leading: 0, bottom: 0, trailing: 0))
        }.padding([.horizontal])
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2020-12-17
@kozinakoff

Replace Button with NavigationLink:

NavigationLink(destination: ItemDetailsView(id:item.id, name : item.name, entityType: self.entityType)) {
    Text("\(id)")
}.padding(EdgeInsets(top: 2, leading: 0, bottom: 0, trailing: 0))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question