How to use CropImageView in Compose?
I want to use CropImageView in Compose project, how to do that?
Like this:
val cropImage = rememberLauncherForActivityResult(CropImageContract()) { result -> if (result.isSuccessful) { // Use the returned uri. val uriContent = result.uriContent val uriFilePath = result.getUriFilePath(context) // optional usage } else { // An error occurred. val exception = result.error } }
and start with e.g. this:
cropImage.launch( CropImageContractOptions( uri = null, cropImageOptions = CropImageOptions( imageSourceIncludeGallery = true, imageSourceIncludeCamera = false, fixAspectRatio = true // aspectRatioX = 1, // aspectRatioY = 1, ) ) )
https://gist.github.com/hoangchungk53qx1/b17356cc82515666058b3d53781bf5d5
Seems like there is a solution. We don't have official Compose support, but I'm willing to take PRs that either improve the overall component / provide a proper Compose support.