V8tr / PopupSwiftUI

Custom popup in SwiftUI
https://www.vadimbulavin.com/
The Unlicense
60 stars 7 forks source link

Passing binding variables to the popup #1

Open ClaesClaes opened 3 years ago

ClaesClaes commented 3 years ago

HI, thanks for a nice write up on your blog and code on how to create popups. I got inspired and tried to use the snackbar example to crate a hue color slider popup. The hue color slider has two binding variable (Color and slider knob position).

So, how can I pass those bindings to/from the snackbar popup? I've tried the following but it fails and I'm not sure how to pass those two bindings to the snackbar:

.popup(isPresented: showHuePicker, alignment: .center, direction: .bottom, content: huePicker.init(color: $color1, knobLocation: $knobLocation))

trungnt1995 commented 3 years ago

.popup(isPresented: showHuePicker, alignment: .center, direction: .bottom, content: {huePicker.init(color: $color1, knobLocation: $knobLocation})) try wrap it in {} , It work for me. @ClaesClaes