Image and video picker with preview, camera capture, GIF support, directory grouping, playback controls, dark/light themes and internationalization; configurable max items and grid layout.
Put the Composable you created in navigation routes
composable("asset_picker") {
ImagePicker(
onPicked = { assets ->
// implement the onPicked logic, pass the assets list that you picked
viewModel.selectedList.clear()
viewModel.selectedList.addAll(assets)
navController.navigateUp()
},
onClose = { assets ->
// implement the onClose logic, pass the assets list that you picked
viewModel.selectedList.clear()
navController.navigateUp()
}
)
}
Navigate to the specified route to pick images
navController.navigate("asset_picker")
route name("asset_picker") should be the same as the name in the step two
You can customize the properties in AssetPickerConfig
dataclassAssetPickerConfig(
val maxAssets: Int = 9, // the maximum count you pickedval gridCount: Int = 3, // the column counts of LazyVerticalGrid that layout the imagesval requestType: RequestType = RequestType.COMMON,
)
So you can configure the maxAssets and gridCount to meet the requirements for different screens