Skip to content

TabBarViewBuilder, shadow seems to not work #26

@Alex-Vaiman

Description

@Alex-Vaiman

I think u cannot apply shadow directly on color...
but applying, on shape works.

   public var body: some View {
    HStack(spacing: 0) {
        ForEach(tabs, id: \.self) { tab in
            tabView(tab)
                .background(Color.black.opacity(0.001))
                .onTapGesture {
                    switchToTab(tab: tab)
                }
        }
    }
    .padding(.horizontal, insetPadding)
    .background(
        ZStack {
          if let backgroundColor = backgroundColor {
                backgroundColor
                    .cornerRadius(cornerRadius)
                    .shadow(
                        color: shadow.color, radius: shadow.radius, x: shadow.x, y: shadow.y
                    )
            } else {
                Color.clear
            }
        }
    )
    .padding(outerPadding)
}

and i think this extension is redundant? (i am not sure about old version of swift-UI, but in my setup, it just ignores negative values.

    extension View {

@ViewBuilder func cornerRadiusIfNeeded(cornerRadius: CGFloat) -> some View {
    if cornerRadius > 0 {
        self
            .cornerRadius(cornerRadius)
    } else {
        self
    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions