rebeloper / NavigationKit

🧭 SwiftUI navigation done right
176 stars 15 forks source link

Button is not clickable. Only Text is clickable. #2

Closed saumilshah200191 closed 3 years ago

saumilshah200191 commented 3 years ago

Hello @rebeloper,

This package is very helpful and thanks for that. I would like to get update on how it will work with Button and other components.

Problem: When I was trying to use this with button then only Text is clickable and not the Button. Please see the attached video for the problem.

https://user-images.githubusercontent.com/76034194/102853509-7538fa80-4446-11eb-8fbe-72f64ce62571.mov

Code snippet of the button:

Button {
} label: {
   Text("Push to Child 2")
          .foregroundColor(.white)
          .frame(width: 200, height: 50)
          .pushes(Child2())
}
.background(Color.blue)
.clipShape(Capsule())

Please help me with the solution of this. Thanks!

rebeloper commented 3 years ago

You can use asButton for any View to behave as a Button. This approach replaces the use of Button. Create your View as usual and append .asButton() after the Action needed

ex. Text(“Next”).pushes(NextView()).asButton()

https://github.com/rebeloper/NavigationKit#as-button