0

I have a customtab bar that I've implemented through a tutorial. Below is the HStack for this custom bar.

struct CustomTabBar: View {
    
    @Binding var selectedTab: String
    @State var isLinkActive = true
    
    // Storiing Each Tab Midpointts to animate it in future...
    @State var tabPoints: [CGFloat] = []
    
    var body: some View {
        HStack(spacing: 0){
            
            // Tab Bar Buttons....
            TabBarButton(image: "house", selectedTab: $selectedTab, tabPoints: $tabPoints)
                .background(
                    NavigationLink("",destination: QuickTing())
                )
            TabBarButton(image: "person", selectedTab: $selectedTab, tabPoints: $tabPoints)
            TabBarButton(image: "gearshape", selectedTab: $selectedTab, tabPoints: $tabPoints)
        }
        .padding()
        .background(LinearGradient(gradient: Gradient(colors: [Color.orange, Color.pink]), startPoint: .bottomLeading, endPoint: .topTrailing).clipShape(TabCurve(tabPoint: getCurvePoint() - 15))
                    
        )
            
        .overlay(
            
            Circle()
                .fill(Color.pink)
                .frame(width: 10, height: 10)
                .offset(x: getCurvePoint() - 20)
            
            ,alignment: .bottomLeading
        )
        .cornerRadius(35)
        .padding(.horizontal)
       
    }

Whenever I put in the navigationLink it doesn't push the view that i'd like. Even when using the emptyview() fix I receive this error.

enter image description here

Could anyone point as to why I get this error as well as how Implement a navigationLink without compromising on the design of the CustomTabBar.

Kamanda
  • 305
  • 3
  • 4
  • 11
  • If you aren't using NavigationView, then you shouldn't be using NavigationLink. Instead, you probably just want regular `Button`s that effect a state that's stored somewhere that determine which view is shown. – jnpdx Jul 12 '21 at 20:09
  • In terms of your syntax error, there's not initializer for `NavigationLink` that looks exactly like that. Remove the first parameter (the "") and it should work. – jnpdx Jul 12 '21 at 20:28
  • NavigationLink works *only* inside NavigationView. – Asperi Jul 13 '21 at 04:39

0 Answers0