diff --git a/shared/src/commonMain/kotlin/bzh/ajaury/chombev/App.kt b/shared/src/commonMain/kotlin/bzh/ajaury/chombev/App.kt index dfe7204..ad94b20 100644 --- a/shared/src/commonMain/kotlin/bzh/ajaury/chombev/App.kt +++ b/shared/src/commonMain/kotlin/bzh/ajaury/chombev/App.kt @@ -47,15 +47,6 @@ fun App() { mutableStateListOf(Route.Records) } - // Selecting a main tab keeps Records as the root, so system Back always returns home. - fun selectMainTab(page: WebPage?) { - backStack.clear() - backStack.add(Route.Records) - if (page != null) { - backStack.add(Route.Web(page = page)) - } - } - val darkTheme = isSystemInDarkTheme() // The current top destination drives the shared chrome: the top and bottom bars are shown @@ -77,9 +68,9 @@ fun App() { if (isMainScreen) { MainBottomBar( selectedPage = selectedPage, - onRecordsClick = { selectMainTab(null) }, - onDeepenClick = { selectMainTab(WebPages.DEEPEN) }, - onAboutClick = { selectMainTab(WebPages.ABOUT) }, + onRecordsClick = { backStack.selectMainTab(null) }, + onDeepenClick = { backStack.selectMainTab(WebPages.DEEPEN) }, + onAboutClick = { backStack.selectMainTab(WebPages.ABOUT) }, ) } }, @@ -119,3 +110,12 @@ fun App() { } } } + +// Selecting a main tab keeps Records as the root, so system Back always returns home. +private fun MutableList.selectMainTab(page: WebPage?) { + this.clear() + this.add(Route.Records) + if (page != null) { + this.add(Route.Web(page = page)) + } +}