Giter Club home page Giter Club logo

compose-multiplatform-file-picker's Introduction

Compose Multiplatform File Picker

MIT License Latest Release

badge-platform-windows badge-platform-linux badge-platform-macos badge-platform-android badge-platform-js badge-platform-macosX64

badge-kotlin

A multiplatform compose widget for picking files with each platform's Native File Picker Dialog.

Include in your project:

implementation("com.darkrockstudios:mpfilepicker:2.1.0")

How to use

In your shared jetbrains compose multiplatform code, add one of the following.

To show the dialog, simply set the boolean state to true via a button or what ever you want.

Pick a file with a filter:

var showFilePicker by remember { mutableStateOf(false) }

val fileType = listOf("jpg", "png")
FilePicker(show, fileExtensions = fileType) { file ->
    showFilePicker = false
    // do something with the file
}

Pick a directory:

var showDirPicker by remember { mutableStateOf(false) }

DirectoryPicker(showDirPicker) { path ->
    showDirPicker = false
    // do something with path
}

On each supported platform, it will update the platform native file picker dialog. On desktop, it will fall back to the Swing file picker if the native one can't be used for some reason.

Screenshots

Windows

Windows native file picker

Android

Android native file picker

Desktop/JVM Implementation

The native desktop dialog implementation is derived from the Pacmc project but uses TinyFileDialogs

See FileChooser.kt as well as the lwjgl gradle filter.

Building

Intellij IDEA should be able to build the project except Android variant. To build and run Android examples, use Android Studio.

JS

run jsBrowserDevelopmentRun via Gradle, it will build a JS example and open it in a browser.

MacOS and JVM

Click on a green button next to the main function in examples/jvm/.../Main.kt or examples/macosX64/.../main.kt.

Android

Open the project in Android Studio. A run configuration for Android should be added automatically. Clicking on it will run it on an emulator.

compose-multiplatform-file-picker's People

Contributors

shalva97 avatar wavesonics avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.