Skip to content

callback on file picker selection #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gregriggins36
Copy link

No description provided.

@vinceglb
Copy link
Owner

Thanks a lot for your PR @gregriggins36! I will probably merge the PR #300 instead that goes beyond:

val multipleFilesPickerWithState = rememberFilePickerLauncher(
    type = FileKitType.Image,
    mode = FileKitMode.MultipleWithState(),
) { result ->
    when (result) {
        FileKitPickerState.Cancelled -> println("File picker cancelled")
        is FileKitPickerState.Started -> println("Started picking ${result.total} files")
        is FileKitPickerState.Progress -> println("New files processed: ${result.processed.size} / ${result.total}")
        is FileKitPickerState.Completed -> println("File picker completed with ${result.result.size} files")
    }
}

Button(onClick = { multipleFilesPickerWithState.launch() }) {
    Text("Picke images with state")
}

and

val files = FileKit.openFilePicker(
    type = FileKitType.Image,
    mode = FileKitMode.MultipleWithState(),
)

files.collect { result ->
    when (result) {
        FileKitPickerState.Cancelled -> println("File picker cancelled")
        is FileKitPickerState.Started -> println("Started picking ${result.total} files")
        is FileKitPickerState.Progress -> println("New files processed: ${result.processed.size} / ${result.total}")
        is FileKitPickerState.Completed -> println("File picker completed with ${result.result.size} files")
    }
}

I'm really interested in having your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants