I am putting an app together that consists of several buttons. To help clean code I created a view for the buttons and did all the design on them there. I then created a background view to lay out the buttons that will be seen when contentView loads. I created a State variable in my background view and added my .sheet code (see below) but when I click on it I do not get a sheet sliding in. I am not seeing what I am missing so any guidance would be greatly appreciated. The view the sheet should display is called Wetlab104. So when I click the button I would like the sheet for that room to appear.
///swift
struct BackgroundView: View {
@State private var Wetlab104IsShowing = false
@State private var rm105IsShowing = false
var body: some View {
VStack {
HStack {
Button {
Wetlab104IsShowing = true
} label: {
ButtonView(text: “Rm 104”)
}
.sheet(isPresented: $Wetlab104IsShowing) {
Wetlab104()
}
Spacer()
Button {
rm105IsShowing = true
} label: {
ButtonView(text: “Rm 105”)
}
.sheet(isPresented: $rm105IsShowing) {
Wetlab105()
}
}
HStack {
Button {
// show room 107
} label: {
ButtonView(text: “Rm 107”)
}
Spacer()
Button {
// show room 108
} label: {
ButtonView(text: “Rm 108”)
}
}
HStack {
Button {
// show room 118
} label: {
ButtonView(text: “Rm 118”)
}
Spacer()
Button {
// show room 120
} label: {
ButtonView(text: “Rm 120”)
}
}
Button {
// show room 120
} label: {
ButtonView(text: “Q-Lab”)
}
}
}
}
struct BackgroundView_Previews: PreviewProvider {
@Binding var rm104IsShowing: Bool
static var previews: some View {
BackgroundView()
BackgroundView()
.preferredColorScheme(.dark)
.previewDevice(“iPhone 15”)
}
}
///