Created
August 22, 2022 05:10
-
-
Save markchristopherng/daba82f0cd7114808f1af94b34b02b40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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