NicFontana / SwiftUI-CustomTabView

A SwiftUI component for creating TabView with a custom tab bar.
MIT License
43 stars 3 forks source link

Hi Niccolò! #1

Open Alex-Vaiman opened 6 months ago

Alex-Vaiman commented 6 months ago

Grate project! I found a small issue, all tabs screens are in safe area, and I cannot change this, for example the back ground color of the status bar in every screen. I am afraid the fix is going to be dangerous for current users?

private func bottomBarView(children: _VariadicView.Children) -> some View {
        VStack(spacing: 0) {
            contentView(children: children)
                .ignoresSafeArea(.container)

            tabBarView
        }
    }

if you add the .ignoresSafeArea(.container), the issue solved, but the we have 2 problems. 1 It supported since ios13, mac 11. 2 the other thing, depending on the setup, it may? brake thing for current users.

Alex-Vaiman commented 6 months ago
Simulator Screenshot - iPhone 15 Pro - 2024-03-09 at 23 41 35

I mean the orange screen, it is not possible without this fix.

NicFontana commented 6 months ago

Hello Alex!

I have achieved the result you wanted by ignoring the safe area in CustomTabView and in the content of the first tab:

    var body: some View {
        CustomTabView(tabBarView: tabBarView, tabs: Tab.allCases, selection: selectedTab) {
            NavigationView {
                ZStack {
                    Color.orange

                    Text("Profile")
                }
                .edgesIgnoringSafeArea(.all) // <--- Here
                .navigationBarTitle("Profile")
            }

            // Other tabs
        }
        .edgesIgnoringSafeArea(.vertical) // <--- Here
    }

Let me know if that works for you as well.