Skip to content

Commit

Permalink
Update file picker docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedRejeb committed Jun 23, 2024
1 parent 2b28f7c commit 9ee522e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,22 @@ Button(
* `FilePickerFileType.Document` - Allows you to pick documents only
* `FilePickerFileType.Text` - Allows you to pick text files only
* `FilePickerFileType.Pdf` - Allows you to pick PDF files only
* `FilePickerFileType.Presentation` - Allows you to pick presentation files only
* `FilePickerFileType.Spreadsheet` - Allows you to pick spreadsheet files only
* `FilePickerFileType.Word` - Allows you to pick compressed word only
* `FilePickerFileType.All` - Allows you to pick all types of files
* `FilePickerFileType.Folder` - Allows you to pick folders

You can also specify the file types you want to pick by using the `FilePickerFileType.Custom` type:
You can filter files by custom mime types using `FilePickerFileType.Custom`.

```kotlin
val type = FilePickerFileType.Custom(
"text/plain"
listOf("text/plain")
)
```

You can also filter files by custom extensions using `FilePickerFileType.Extension`.

```kotlin
val type = FilePickerFileType.Extension(
listOf("txt")
)
```

Expand Down
18 changes: 12 additions & 6 deletions docs/filepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,22 @@ Button(
* `FilePickerFileType.Document` - Allows you to pick documents only
* `FilePickerFileType.Text` - Allows you to pick text files only
* `FilePickerFileType.Pdf` - Allows you to pick PDF files only
* `FilePickerFileType.Presentation` - Allows you to pick presentation files only
* `FilePickerFileType.Spreadsheet` - Allows you to pick spreadsheet files only
* `FilePickerFileType.Word` - Allows you to pick compressed word only
* `FilePickerFileType.All` - Allows you to pick all types of files
* `FilePickerFileType.Folder` - Allows you to pick folders

You can also specify the file types you want to pick by using the `FilePickerFileType.Custom` type:
You can filter files by custom mime types using `FilePickerFileType.Custom`.

```kotlin
val type = FilePickerFileType.Custom(
"text/plain"
listOf("text/plain")
)
```

You can also filter files by custom extensions using `FilePickerFileType.Extension`.

```kotlin
val type = FilePickerFileType.Extension(
listOf("txt")
)
```

Expand Down Expand Up @@ -135,7 +140,8 @@ val isDirectory = file.isDirectory(context)

#### Platform-specific APIs

KmpFile is a wrapper around platform-specific APIs, so you can use the platform-specific APIs to read the file:
KmpFile is a wrapper around platform-specific APIs,
you can access the native APIs for each platform using the following properties:

##### Android
```kotlin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun FilePickerScreen(navigateBack: () -> Unit) {

val singlePickerLauncher =
rememberFilePickerLauncher(
type = FilePickerFileType.Extension(listOf("pdf")),
type = FilePickerFileType.All,
selectionMode = FilePickerSelectionMode.Single,
onResult = { files ->
fileNames = files.map { it.getName(context).orEmpty() }
Expand Down

0 comments on commit 9ee522e

Please sign in to comment.