Skip to content

Instantly share code, notes, and snippets.

@markchristopherng
Created August 22, 2022 05:10
Show Gist options
  • Save markchristopherng/daba82f0cd7114808f1af94b34b02b40 to your computer and use it in GitHub Desktop.
Save markchristopherng/daba82f0cd7114808f1af94b34b02b40 to your computer and use it in GitHub Desktop.
sealed class DebugScreen(val route: String, val title: Int, val topLevelDestination: Boolean = false) {
object Environment : DebugScreen(DebugNavigationItem.Environment.route, R.string.environment_screen_title, true)
}
Scaffold(
scaffoldState = scaffoldState,
topBar = { DebugTopBar(navController, version) },
bottomBar = { DebugBottomNavigationBar(navController) }
) { paddingValues ->
DebugNavHost(navController = navController, paddingValues, showSnackBar)
}
@Composable
fun DebugTopBar(navController: NavController, version: String) {
val currentScreen = getCurrentScreen(navController)
TopAppBar(
title = {
val topBarTitle = stringResource(id = currentScreen.title)
APText(apStyle = APTextStyle.Title, text = topBarTitle, textColor = AP_White)
},
navigationIcon = {
if (!currentScreen.topLevelDestination) {
IconButton(onClick = { navController.navigateUp() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = "Back"
)
}
}
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment