[ad_1]
I received a ButtonsBarView that’s rendered in every view. It navigates by way of the views with exhibiting fullscreencovers. As a result of I create a brand new ButtonsBarView(settings: $settings, residence: $residence) in each view. If I am in HomeView and click on the button for the SettingsView the settings button coloration in HomeView would change however the button coloration in SettingsView would keep the identical.
I need the button that results in residence be blue if the present view is residence and similar for settings.
struct ButtonBarView: View {
@Binding var settings: Bool
@Binding var residence: Bool
var physique: some View {
Button() {
residence.toggle()
} label: {
Picture("residence").resizable()
.renderingMode(.template)
.foregroundColor(residence ? .blue : Shade(.init(crimson: 0.59, inexperienced: 0.62, blue: 0.67, alpha: 1)))
.body(width: 34, peak: 34)
}.fullScreenCover(isPresented: $residence) {
HomeView()
}
Spacer()
Button() {
settings.toggle()
} label: {
Picture("settings").resizable()
.renderingMode(.template)
.foregroundColor(settings ? .blue : Shade(.init(crimson: 0.59, inexperienced: 0.62, blue: 0.67, alpha: 1)))
.body(width: 34, peak: 34)
}.fullScreenCover(isPresented: $settings) {
SettingsView()
}
}
}
Simplified HomeView (SettingsView would look the identical):
struct HomeView: View {
@State var residence: Bool = true
@State var settings: Bool = false
var physique: some View {
ButtonBarView(settings: $settings, residence: $residence)
}
}
Possibly I ought to change the way in which I navigate by way of my views completely, however I do not fairly perceive find out how to use a NavigationView with a number of Views.
[ad_2]
