Skip to content

Instantly share code, notes, and snippets.

@AndroidPoet
Created April 17, 2026 17:28
Show Gist options
  • Select an option

  • Save AndroidPoet/43ad92e77d4d0839a9d1cd022ef9c9fc to your computer and use it in GitHub Desktop.

Select an option

Save AndroidPoet/43ad92e77d4d0839a9d1cd022ef9c9fc to your computer and use it in GitHub Desktop.
@Serializable
data class PickedImage(val url: String, val width: Int, val height: Int)
@Composable
fun ImagePickerScreen(navController: NavController) {
LazyVerticalGrid(columns = GridCells.Fixed(3)) {
items(images) { image ->
AsyncImage(
model = image.url,
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
.clickable {
navController.previousBackStackEntry
?.savedStateHandle
?.set("picked_image", PickedImage(
url = image.url,
width = image.width,
height = image.height
))
navController.popBackStack()
}
)
}
}
}
@Composable
fun ImageListScreen(navController: NavController) {
val pickedImage = navController.currentBackStackEntry
?.savedStateHandle
?.getStateFlow<PickedImage?>("picked_image", null)
?.collectAsState()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment