rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
822 stars 87 forks source link

How to add a badge in TabBar #135

Closed pulimento closed 2 weeks ago

pulimento commented 2 weeks ago

I have a properly working tabbar, but I need to add badges to it. I've tried adding it to the image, to the text, as a group, and nothing is working Can't find documentation about it, and I'm asking before creating a whole new custom view for the tab bar.

Am I missing something? Thanks in advance

@ViewBuilder func makeHomeTab(isActive: Bool) -> some View {
        Image(isActive ? .tabIconHomeActive : .tabIconHome)            
            .renderingMode(.template)
            .badge(2)
            .foregroundColor(isActive ? .accentColor : Color(.gray1))
        Text.BodyS(.regular, L10n.tabHome)
    }
pulimento commented 2 weeks ago

i've ended using the customize function, and creating from scratch a view that emulates a tabview