I have this List of items, with a toolbar, when I use the geometryReader to show on the side the sideBarCockpitView() the toolbar disappears?
var body: some View {
ZStack{
List(itemData.items) { item in
Button(action: {
if let index = itemData.items.firstIndex(of: item) {
itemData.items[index].isSelected.toggle()
saveData(itemData: itemData)
}
}) {
HStack {
Text(item.name)
.foregroundColor(textColor(for: item))
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
.padding(.leading, 10)
.padding(.vertical, 10) // Adjust the vertical padding here
if item.name == "ATIS & TOPA (NOTAM?)" {
TextField("TOPA RWY:", text: $TOPAText)
.foregroundColor(.red)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding(.horizontal, 15)
.keyboardType(.numbersAndPunctuation)
.autocapitalization(.allCharacters)
}
if item.name == "RCL - TECH & CAB LOG\n - DAILY Check" {
Button {
showMELview.toggle()
} label: {
Text("MEL")
.foregroundColor(.green)
.padding(10)
.background(Color.gray.opacity(0.5))
.cornerRadius(8)
}
.sheet(isPresented: $showMELview) {
MELItems()
}.padding(10)
}
if item.name == "FMS & QR" {
Button {
showOFPPersonalNotesview.toggle()
} label: {
Text("OFP notes")
.foregroundColor(.green)
.padding(10)
.background(Color.gray.opacity(0.5))
.cornerRadius(8)
}
.sheet(isPresented: $showOFPPersonalNotesview) {
sideOFPpersonalNotes()
}.padding(5)
}
if item.name == "PA" {
Button {
welcomePASheetPresented.toggle()
} label: {
Text("PA")
.foregroundColor(.green)
.padding(10)
.background(Color.gray.opacity(0.5))
.cornerRadius(8)
}.padding(5)
}
if item.name == "BRIEF — CLX-DCL | CL" {
Button {
showDepBriefView.toggle()
} label: {
Text("DepBrief")
.foregroundColor(.green)
.padding(10)
.background(Color.gray.opacity(0.5))
.cornerRadius(8)
}
.sheet(isPresented: $showDepBriefView) {
DEPbriefView()
}.padding(5)
}
if item.name == "FMS/NSS, FLT OPS/ OANS" {
TextField("AIRAC", text: $Airac)
.foregroundColor(.white)
.textFieldStyle(RoundedBorderTextFieldStyle())
.frame(width: 60)
.padding(.horizontal, 2)
.keyboardType(.numbersAndPunctuation)
.autocapitalization(.allCharacters)
.multilineTextAlignment(.center)
}
if item.name == "FMS/NSS, FLT OPS/ OANS" {
TextField("ERM", text: $ERM)
.foregroundColor(.white)
.frame(width: 60)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding(.horizontal, 2)
.keyboardType(.numbersAndPunctuation)
.autocapitalization(.allCharacters)
.multilineTextAlignment(.center)
}
if item.name == "L/S—XcheckAV — Accept L/S" {
TextField("OFP", text: $OFPnbr)
.foregroundColor(.green)
.frame(width: 50)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding(.horizontal, 2)
.keyboardType(.numbersAndPunctuation)
.autocapitalization(.allCharacters)
.multilineTextAlignment(.center)
}
}
.background(
RoundedRectangle(cornerRadius: 8)
.stroke(item.isSelected ? Color.clear : Color.white, lineWidth: 2)
.background(item.isSelected ? Color.black : Color.clear).cornerRadius(10)
).padding(.vertical, 0)
}.listRowSeparator(.hidden)
}
.listRowInsets(EdgeInsets())
.listStyle(PlainListStyle())
.toolbar {
HStack{
Text("T - \(TminusSTD)")
.frame(width: 100)
.padding(5)
// .cornerRadius(5)
.foregroundColor(.black)
.background(timeBackground())
.cornerRadius(5)
///
Spacer()
if let topaTowDouble = Double(TOPAtow) {
let formattedValue = String(format: "FLX TOW %.1f T", topaTowDouble)
if topaTowDouble != 0 {
Text(formattedValue)
.foregroundColor(.black)
.padding(5)
.background(Color.green)
.cornerRadius(5)
} else {
Text(formattedValue)
.hidden()
}
} else {
// Handle the case where TOPAtow is not a valid Double
Text("")
}
Spacer()
Button(action: {
resetItemsToInitialState()
}) {
Text("Reset")
.foregroundColor(.white)
.padding(8)
.background(Color.red)
.cornerRadius(8)
}
}
}
GeometryReader { _ in // when I use this the toolbar dissapears
HStack{
Spacer()
sideBarCockpitView()
}
}
}
.onReceive(timer) { _ in
updateSkedTime()
if !timerStopped {
updateUTCLabel()
updateIntervalText()
saveToUserDefaults()
}
}
.onChange(of: depTime) {
timerStopped = false
TminusSTD = "00:00:00"
saveToUserDefaults()
}
///
.onAppear {
restoreData(itemData: itemData)
UIApplication.shared.isIdleTimerDisabled = true
///
flightTime = UserDefaults.standard.object(forKey: "flightTime") as? Date ?? Date()
arrTime = UserDefaults.standard.object(forKey: "arrTime") as? Date ?? Date()
depTime = UserDefaults.standard.object(forKey: "depTime") as? Date ?? Date()
UserDefaults.standard.set(TminusSTD, forKey: "intervalText")
///
}
.onDisappear {
saveToUserDefaults() // para el timer
UIApplication.shared.isIdleTimerDisabled = false
}
.sheet(isPresented: $welcomePASheetPresented) {
WelcomePAviewPDF(pdfName: "PA1")
}
}
What I expect is to show the list of items, the toolbar in the upper side, and a sideBar. The sidebar has a button that offsets the View and it should shows over the list without affecting the visibility of the toolbar. The app starts with a List menu that shows different options, when press in one you go to a detail view with a navigationLink, which is the one presented here.