|
|
|
@ -42,20 +42,21 @@ import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
|
|
|
import androidx.compose.runtime.DisposableEffect
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
import androidx.compose.runtime.remember
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.platform.LocalView
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
|
import androidx.navigation.NavDestination
|
|
|
|
|
import androidx.navigation.NavDestination.Companion.hierarchy
|
|
|
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.ClearRippleTheme
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.addPerformanceMetricsState
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.component.NiaBackground
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.rememberMetricsStateHolder
|
|
|
|
|
import com.google.samples.apps.nowinandroid.core.ui.theme.NiaTheme
|
|
|
|
|
import com.google.samples.apps.nowinandroid.navigation.NiaNavHost
|
|
|
|
|
import com.google.samples.apps.nowinandroid.navigation.NiaTopLevelNavigation
|
|
|
|
@ -66,11 +67,20 @@ import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination
|
|
|
|
|
@Composable
|
|
|
|
|
fun NiaApp(windowSizeClass: WindowSizeClass) {
|
|
|
|
|
NiaTheme {
|
|
|
|
|
val localView = LocalView.current
|
|
|
|
|
val navController = rememberNavController()
|
|
|
|
|
navController.addOnDestinationChangedListener { _, destination, _ ->
|
|
|
|
|
localView.addPerformanceMetricsState("Navigation", "${destination.route}")
|
|
|
|
|
val metricsHolder = rememberMetricsStateHolder()
|
|
|
|
|
DisposableEffect(navController, metricsHolder) {
|
|
|
|
|
val listener = NavController.OnDestinationChangedListener { _, destination, _ ->
|
|
|
|
|
metricsHolder.state?.addState("Navigation", destination.route.toString())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navController.addOnDestinationChangedListener(listener)
|
|
|
|
|
|
|
|
|
|
onDispose {
|
|
|
|
|
navController.removeOnDestinationChangedListener(listener)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val niaTopLevelNavigation = remember(navController) {
|
|
|
|
|
NiaTopLevelNavigation(navController)
|
|
|
|
|
}
|
|
|
|
|