frzi / swiftui-router

Path-based routing in SwiftUI
MIT License
900 stars 43 forks source link

White rectangle behind view wrapped by Link #10

Closed amadeu01 closed 4 years ago

amadeu01 commented 4 years ago

I'm not really sure if it is something in the lib or I just messed things.

When I try something like:

ForEach(pipes, id: \.id) { pipe in
                Link(to: "/pipe/:" + pipe.id) {
                    PipeCell(pipe: pipe).frame(
                        width: pipeCellSize.width,
                        height: pipeCellSize.height,
                        alignment: .center
                    )
                }
            }

I get this:

image

Link seems to display this weird white rectangle behind the view. I'm not sure how I should use it.

amadeu01 commented 4 years ago

I've also tried stuff like:

Link(to: "/pipe/:" + pipe.id) {
                    VStack(alignment: .leading) {
                        Text("Text")
                        Text("Text")
                        Text("Text")
                        Text("Text")
                    }
                }.padding().background(Color.green)

Which resulted in image

frzi commented 4 years ago

SwiftUI Router's Link is basically just a wrapper around a Button. Could you try the following?

Link(to: "/pipe/:" + pipe.id) {
    // Etc ...
}
.buttonStyle(PlainButtonStyle())

This should erase any predefined styling of a Button.