Created
April 17, 2026 17:28
-
-
Save AndroidPoet/43ad92e77d4d0839a9d1cd022ef9c9fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @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