Skip to content

Instantly share code, notes, and snippets.

@yschimke
Created June 13, 2022 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yschimke/a7039c8dbdc06be12f32a23c63bc6e5a to your computer and use it in GitHub Desktop.
Save yschimke/a7039c8dbdc06be12f32a23c63bc6e5a to your computer and use it in GitHub Desktop.
val navController = rememberSwipeDismissableNavController()
Scaffold(
modifier = Modifier.fillMaxSize(),
timeText = { TimeText() }
) {
SwipeDismissableNavHost(
navController = navController,
startDestination = "start",
) {
composable(route = "start") {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Button(onClick = { navController.navigate("second") }) {
Text("Page 2")
}
}
}
composable(route = "second") {
val state = rememberScalingLazyListState(initialCenterItemIndex = 0)
ScalingLazyColumn(
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(top = 0.dp),
autoCentering = AutoCenteringParams(itemIndex = 0),
state = state
) {
item {
Box(modifier = Modifier
.fillMaxWidth()
.fillParentMaxHeight(0.5f)
.background(Color.Red))
}
item {
Box(modifier = Modifier
.fillMaxWidth()
.fillParentMaxHeight(0.5f)
.background(Color.Blue))
}
item {
Box(modifier = Modifier
.fillMaxWidth()
.fillParentMaxHeight(0.5f)
.background(Color.Yellow))
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment