Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / networklocation / src / main / java / com / vayunmathur / networklocation / Navigation.kt

Navigation.kt25 lines · 1013 BRaw
1package com.vayunmathur.networklocation
2
3import androidx.compose.runtime.Composable
4import androidx.compose.runtime.remember
5import androidx.compose.ui.platform.LocalContext
6import com.vayunmathur.library.util.MainNavigation
7import com.vayunmathur.library.util.rememberNavBackStack
8import com.vayunmathur.networklocation.ui.SetupScreen
9import com.vayunmathur.networklocation.ui.StatusScreen
10
11@Composable
12fun 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}