FileKit icon indicating copy to clipboard operation
FileKit copied to clipboard

More params for capturing image via image picker

Open suhaibkazi opened this issue 8 months ago • 2 comments

val launcher = rememberCameraPickerLauncher( type = FileKitCameraType.Photo ) { file -> // Handle the captured photo }

The rememberCameraPickerLauncher has only one param asking for captureType, would be great to have more params like directory, name, format, etc

Internally it stores on cache for android and returns the platformFile, and we have to copy or move the file to correct assets dir/folder.

suhaibkazi avatar May 15 '25 13:05 suhaibkazi

Hi @suhaibkazi!

You can move the file and put it where you want easily like this:

val scope = rememberCoroutineScope()
val takePhotoLauncher = rememberCameraPickerLauncher { file ->
    scope.launch {
        file?.atomicMove(FileKit.filesDir / "my-photo.jpg")
    }
}

We can imagine improving the API by providing a new optional parameter called destinationFile:

val takePhotoLauncher = rememberCameraPickerLauncher(
    destinationFile = FileKit.filesDir / "my-photo.jpg"
) { file ->

}

This keeps things simple while still being flexible. What do you think?

vinceglb avatar May 15 '25 16:05 vinceglb

Agreed. I was inspired by the filepicker API since that has a lot of params to customise

PS thanks for the hack

suhaibkazi avatar May 15 '25 16:05 suhaibkazi

I added the parameter like you suggested in FileKit 0.10.0 🎉

I'm closing, feel free to reopen if needed 👌

vinceglb avatar Aug 03 '25 10:08 vinceglb