I am at present working into an issue with a sheet not closing when the shut button is pushed or the save button has accomplished transferring the info from the shape to the checklist in homeview. Beneath is the code for a customized tab bar that when “New Survey” is pushed it’s going to open the formView. The formView has two buttons closed and save. I would love it that when both of these buttons are chosen that it closes the formView.
struct FormView: View {
@Binding var surveys: [Survey]
@State var customerName = ""
@State var metropolis = ""
@State var state = ""
@State var lineName = ""
@State var date = Date()
@Binding var isPresented: Bool
@State var showingFormView = false
var physique: some View {
VStack{
ZStack {
NavigationView {
VStack {
ZStack {
Type {
Part(header: Textual content("Survey Information").font(.customized("Roboto-Gentle", measurement: 24)).foregroundColor(Colour(crimson: 0.00, inexperienced: 0.188, blue: 0.42)).offset(x: -20)) { TextField("Buyer Title", textual content: $customerName)
.padding(.vertical, 10.0)
.font(.customized("Roboto-Gentle", measurement: 18))
TextField("Buyer Metropolis", textual content: $metropolis)
.padding(.vertical, 10.0)
.font(.customized("Roboto-Gentle", measurement: 18))
TextField("State", textual content: $state)
.padding(.vertical, 10.0)
.font(.customized("Roboto-Gentle", measurement: 18))
TextField("Line Title", textual content: $lineName)
.padding(.vertical, 10.0)
.font(.customized("Roboto-Gentle", measurement: 18))
DatePicker("Date", choice: $date, displayedComponents: .date)
.padding(.vertical, 10.0)
.font(.customized("Roboto-Gentle", measurement: 18))
}
}
VStack (alignment: .middle){
Spacer()
HStack {
**Button(motion: {
self.showingFormView = false
self.isPresented = false
}, label: {
Textual content("Shut")
.font(.customized("Roboto-Gentle", measurement: 23))
.foregroundColor(Colour.white)
.body(width: 150.0, top: 50.0, alignment: .middle)
.background(Colour(hue: 0.001, saturation: 0.768, brightness: 0.975))
.cornerRadius(3)
})
Button(motion: {
// Save survey information to UserDefaults or every other means
let survey = Survey(customerName: customerName, metropolis: metropolis, state: state, lineName: lineName, date: date)
self.surveys.append(survey)
// Clear textual content fields
self.customerName = ""
self.metropolis = ""
self.state = ""
self.lineName = ""
self.date = Date()
// Shut FormView
self.showingFormView = false
self.isPresented = false
}, label: {
Textual content("Save")
.font(.customized("Roboto-Gentle", measurement: 23))
.foregroundColor(Colour.white)
.body(width: 150.0, top: 50.0, alignment: .middle)
.background(Colour(crimson: 0.451, inexperienced: 0.729, blue: 0.251))
.cornerRadius(3)
})**
}
}
}
}
.navigationBarHidden(true)
}
}
}
}
}
Customized Tab Bar
struct CustomTabBar: View {
@Binding var surveys: [Survey]
@Binding var isPresented : Bool
@State var showingFormView = false
var physique: some View {
NavigationView{
VStack {
Spacer()
HStack (alignment: .backside) {
Button {
} label: {
GeometryReader { geo in
VStack (alignment: .middle, spacing: 4) {
Picture(systemName: "magnifyingglass")
.resizable()
.scaledToFit()
.body(width: 32, top: 32)
Textual content("Search")
.font(.customized("Roboto-Gentle", measurement: 14))
}
.body(width: geo.measurement.width,top: geo.measurement.top)
}
}
.tint(Colour(crimson: 0.0, inexperienced: 0.188, blue: 0.42))
**Button(motion: {
showingFormView = true
}) {
GeometryReader { geo in
VStack(alignment: .middle, spacing: 4) {
Picture("PSIcon")
.resizable()
.scaledToFit()
.body(width: 38, top: 38)
Textual content("New Survey")
.font(.customized("Roboto-Gentle", measurement: 14))
.tint(Colour(crimson: 0.0, inexperienced: 0.188, blue: 0.42))
}
.body(width: geo.measurement.width, top: geo.measurement.top)
}
}
.sheet(isPresented: $showingFormView) {
FormView(surveys: $surveys, isPresented: $isPresented) }
//code means that you can name up a particular view as long as a var is indicated
**
Button {
} label: {
GeometryReader { geo in
VStack (alignment: .middle, spacing: 4) {
Picture(systemName: "arrow.up.arrow.down")
.resizable()
.scaledToFit()
.body(width: 35, top: 35)
Textual content("Type")
.font(.customized("Roboto-Gentle", measurement: 14))
}
.body(width: geo.measurement.width,top: geo.measurement.top)
}
}
.tint(Colour(crimson: 0.0, inexperienced: 0.188, blue: 0.42))
}
.body(top: 50.0)
}
}
}
}
The save button saves and creates a brand new merchandise within the dynamic checklist nevertheless it doesn’t shut the formView. The one means for me to shut the view is by swiping down on the display.