rundfunk47 / stinsen

Coordinators in SwiftUI. Simple, powerful and elegant.
MIT License
924 stars 98 forks source link

How to add a badge in TabBar #135

Closed pulimento closed 5 months ago

pulimento commented 5 months 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 5 months ago

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