Good afternoon!
Tell me how to correctly implement a connection between different views for general object changes?
For example, there is 1 view where I use the button to change the background color, go to view 2 and there is already a changed background color and vice versa with view 2 change the color for all other views?
I tried to use "ObservableObject" but I get to change the color on one view, when I switch, the standard is restored in the next view
View connection
Button
Background color
Tell me how to correctly implement a connection between different views for general object changes?
For example, there is 1 view where I use the button to change the background color, go to view 2 and there is already a changed background color and vice versa with view 2 change the color for all other views?
I tried to use "ObservableObject" but I get to change the color on one view, when I switch, the standard is restored in the next view
Code Block class Store: ObservableObject { @Published var colorBackground = "Black" }
View connection
Code Block @ObservedObject var store: Store
Button
Code Block Button(action: { self.store.colorBackground = "Black" }, label: { })
Background color
Code Block ZStack { Color(store.colorBackground) .edgesIgnoringSafeArea(.all) }