Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / networklocation / src / main / java / com / vayunmathur / networklocation / Navigation.kt
Navigation.kt25 lines · 1013 BRaw
| 1 | package com.vayunmathur.networklocation |
| 2 | |
| 3 | import androidx.compose.runtime.Composable |
| 4 | import androidx.compose.runtime.remember |
| 5 | import androidx.compose.ui.platform.LocalContext |
| 6 | import com.vayunmathur.library.util.MainNavigation |
| 7 | import com.vayunmathur.library.util.rememberNavBackStack |
| 8 | import com.vayunmathur.networklocation.ui.SetupScreen |
| 9 | import com.vayunmathur.networklocation.ui.StatusScreen |
| 10 | |
| 11 | @Composable |
| 12 | fun Navigation() { |
| 13 | val context = LocalContext.current |
| 14 | val start = remember { if (OfflineDatabases.allPresent(context)) Route.Status else Route.Setup } |
| 15 | val backStack = rememberNavBackStack<Route>(start) |
| 16 | |
| 17 | MainNavigation(backStack) { |
| 18 | entry<Route.Setup> { |
| 19 | // reset() rather than add(): once the databases are installed there is nothing to go |
| 20 | // back to, and leaving Setup on the stack would let Back return to a finished download. |
| 21 | SetupScreen(onReady = { backStack.reset(Route.Status) }) |
| 22 | } |
| 23 | entry<Route.Status> { StatusScreen() } |
| 24 | } |
| 25 | } |