stinsen
stinsen copied to clipboard
Badge Support
The current TabCoordinatable implementation seams to miss badge() support. With iOS 15 this would look like this:
TabView {
Text("Your home screen here")
.tabItem {
Label("Home", systemImage: "house")
}
.badge(5)
}
I tried to use the badge modifier with Stinsen, but combining it with a NavigationCoordinatable doesn't work.
What I tried and what didn't work:
Adding the badge in the TabItem view:
@ViewBuilder func makeTodosTab(isActive: Bool) -> some View {
Image(systemName: "folder" + (isActive ? ".fill" : ""))
Text("Todos").badge(5)
}
Adding the badge on the "Screen" view, this works WITHOUT a NavigationCoordinatable.
struct TodosScreen: View {
@ViewBuilder var content: some View {
Color.white
.badge(5)
.navigationTitle(with: "Todos")
}
Basically the only real way to add badges would be to add it directly in the TabView:
TabView(selection: $child.activeTab) {
ForEach(Array(views.enumerated()), id: \.offset) { view in
view
.element
.tabItem {
coordinator.child.allItems[view.offset].tabItem(view.offset == child.activeTab)
}
.badge(2)
.tag(view.offset)
}
}
What would be the best solution for this? Making a TabItem Model with a badge and a view? Making a view.element customize option where we could add the badge() or other modifiers?