adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.27k stars 109 forks source link

Configuration changes not handled - Tab Options #369

Open pitampoudel opened 2 months ago

pitampoudel commented 2 months ago

I have defined a Tab as:

data object CampaignsTab : Tab {
    override val options: TabOptions
        @Composable
        get() {
            val title = SharedRes.strings.label_campaigns.desc().localized()
            val icon = rememberVectorPainter(Icons.Default.Campaign)
            return remember {
                TabOptions(
                    index = 0u,
                    title = title,
                    icon = icon
                )
            }
        }
  }

And I am consuming that as:

    NavigationBar {
        remember { listOf(CampaignsTab, LeaderboardTab) }.forEach { tab ->
            val tabNavigator = LocalTabNavigator.current
            NavigationBarItem(
                selected = tabNavigator.current == tab,
                onClick = { tabNavigator.current = tab },
                icon = {
                    tab.options.icon?.let { icon ->
                        Icon(
                            painter = icon,
                            contentDescription = tab.options.title
                        )
                    }

                },
                label = { Text(tab.options.title) }
            )
        }
    }

I expect my bottom navigation bar texts to change automatically whenever the app language changes like all other components.