So let's say I have a view like this:
struct MyView {
@Binding var inEditMode: Bool
...
}
In some cases, I want this view to be able to swap in and out of edit mode, but in other cases, I only want it to be read-only.
Now I can avhieve this by creating a State var in the view containing this view that just never gets edited:
struct MyContainer {
@State alwaysFalse: Bool = false
var view: some View {
MyView(inEditMode: $alwaysFalse)
}
}
But it seems a little unnecessary to introduce a state var here. Is there any way to skip this and do something like this?
struct MyContainer {
var view: some View {
MyView(inEditMode: ConstBinding<Bool>(false))
}
}
I think it would make the intent a bit clearer.