.fullScreenCover(isPresented: $viewModel.showEditRoom) {
EditRoomView(someData: someData, selectedRoom: $viewModel.selectedRoom)
}
I have a fullScreenCover
modifier that presents a view when a certain condition is met. The view that is presented, EditRoomView
, takes a few parameters including selectedRoom
, a binding property.
The issue I’m encountering is that when the EditRoomView
is presented using fullScreenCover
, it doesn’t reflect the latest value of the viewModel.selectedRoom
property. I update this property when a row is selected, and then I present the EditRoomView
.
I attempted to use the fullScreenCover(item:
but with this approach, I encountered issues in binding a variable since selectedRoom
is a Binding
property in the next view. Additionally, the view becomes unresponsive after its initial appearance.
2
Answers
It’s hard to infer the issues you encountered from your description. However I tried to create my View in the way you wrote and have successfully updated the selectedRoom as below. You can refer to my example to identify the differences.
(In this example, I used
List(1...5, id: .self) { room in }
for simplicity and clarity. Feel free to replace it with more complex objects as needed.)Here is one implementation: