Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabbar items customisation #119

Open
PomazanovaAnna opened this issue Apr 24, 2023 · 2 comments
Open

Tabbar items customisation #119

PomazanovaAnna opened this issue Apr 24, 2023 · 2 comments

Comments

@PomazanovaAnna
Copy link

Hello!
I want to add localization on the fly for my project. However, I have @published property for the current language in custom TabCoordinator, which conforms TabCoordinatable. How can I update tab bar items each time when @published property is changed?
For now, tab bar items will change when the user press on some of them.

  final class AuthentificatedCoordinator: TabCoordinatable {
    
    @Route(tabItem: makeHomeTab) private var home = makeHomeCoordinator
    @Published var appLanguage: Language!

   }
@ViewBuilder
    func makeHomeTab(isActive: Bool) -> some View {
        Image(systemName: "house" + (isActive ? ".fill" : ""))
        Text("Home".localized(appLanguage)
    }

Thanks!

@LePips
Copy link
Collaborator

LePips commented Apr 24, 2023

You may be able to use .id() to cause an update:

@ViewBuilder
func makeHomeTab(isActive: Bool) -> some View {
	Image(systemName: "house" + (isActive ? ".fill" : ""))

	Text("Home".localized(appLanguage)
		.id(appLanguage)
}

@PomazanovaAnna
Copy link
Author

Unfortunately, it does not update with .id()
When the appLanguage property changes, the method makeHomeTab() does not call. Only when the user press on some of the tab bar items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants