Strange @State & .sheet(isPresented:) behavior

I want create view, inside it place two button and on click this buttons i want to show sheet view for two this button (for example: Selector view)

When i create view as struct with var inside, all work like a need, but i can't change in struct variable, i know that is value type 🙂

But, when i set @State wrapper for changeable variable inside popUp (i mean my Custom view), i see next behavior:


Watched:

- Press button One, Open Sheet with value for button one: 123

- Press button Two, Open Sheet with value for button one: 123

- Also, if you change value to any, close Sheet and open by pressed to alter button (i mean Button One), value stay here 🙂


Needed:

- Press button One, Open Sheet with value for button one: 123

- Press button Two, Open Sheet with value for button two: 321


Example code:

https://gist.github.com/iDevPro/af5f7369832c9f4ef9dc2c4676331ede


May be i was misstake, but i can't find it here 😟

Replies

Have you tried making test a String whose value you set to "123" in Button1 and "321" in Button2 ?