could someone help me figure out what's wrong within this view? Can you see the status bar and bottom view refreshing like crazy? I've tried several things like playing with paddings and margins without success. What seems to be triggering the bug is adding the fifth element on the tab bar but i cannot realize what's wrong with it, can you?
Thanks for your help
import SwiftUI
struct TabManager: View {
@State var selectedTab = "house"
@State var edge = UIApplication.shared.windows.first?.safeAreaInsets
var body: some View{
ZStack(alignment: Alignment(horizontal: .center, vertical: .bottom)) {
switch selectedTab {
case "house" :
HomeView()
.ignoresSafeArea(.all, edges: .bottom)
case "bookmark.circle":
BookingView()
.ignoresSafeArea(.all, edges: .bottom)
case "square.and.pencil":
BookingsHistoryView()
.ignoresSafeArea(.all, edges: .bottom)
case "gear":
SettingsView()
.ignoresSafeArea(.all, edges: .bottom)
default:
HomeView()
.ignoresSafeArea(.all, edges: .bottom)
}
HStack(spacing: 0){
ForEach(tabs,id: \.self){image in
TabButton(selectedTab: $selectedTab, image: image)
// equal spacing...
if image != tabs.last{
Spacer(minLength: 0)
}
}
}
.padding(.horizontal,25)
.background(Color("panel"))
.clipShape(Capsule())
.shadow(color: Color.black.opacity(0.15), radius: 5, x: 5, y: 5)
.shadow(color: Color.black.opacity(0.15), radius: 5, x: -5, y: -5)
.padding(.horizontal)
.padding(.bottom,edge!.bottom == 0 ? 20 : 0)
}
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
.ignoresSafeArea(.keyboard, edges: .bottom)
.background(Color("background").ignoresSafeArea(.all, edges: .all))
}
}
var tabs = ["house","bookmark.circle","square.and.pencil","gear","gear"]
struct TabButton : View {
@Binding var selectedTab : String
var image : String
var body: some View{
Button(action: {selectedTab = image}) {
Image(systemName: image)
.renderingMode(.template)
.foregroundColor(selectedTab == image ? Color("component") : Color(.label).opacity(0.4))
.font(.system(size: 32))
.padding()
}
}
}