-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from MohamedRejeb/0.5.x
Add file picker extensions support
- Loading branch information
Showing
30 changed files
with
3,537 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...picker/src/desktopMain/kotlin/com/mohamedrejeb/calf/picker/platform/PlatformFilePicker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.mohamedrejeb.calf.picker.platform | ||
|
||
import com.mohamedrejeb.calf.picker.FilePickerFileType | ||
import com.mohamedrejeb.calf.picker.FilePickerSelectionMode | ||
import com.mohamedrejeb.calf.picker.platform.awt.AwtFilePicker | ||
import com.mohamedrejeb.calf.picker.platform.mac.MacOSFilePicker | ||
import com.mohamedrejeb.calf.picker.platform.util.Platform | ||
import com.mohamedrejeb.calf.picker.platform.util.PlatformUtil | ||
import com.mohamedrejeb.calf.picker.platform.windows.WindowsFilePicker | ||
import java.awt.Window | ||
import java.io.File | ||
|
||
interface PlatformFilePicker { | ||
|
||
suspend fun launchFilePicker( | ||
initialDirectory: String?, | ||
type: FilePickerFileType, | ||
selectionMode: FilePickerSelectionMode, | ||
title: String?, | ||
parentWindow: Window?, | ||
onResult: (List<File>) -> Unit, | ||
) | ||
|
||
suspend fun launchDirectoryPicker( | ||
initialDirectory: String?, | ||
title: String?, | ||
parentWindow: Window?, | ||
onResult: (File?) -> Unit, | ||
) | ||
|
||
companion object { | ||
val current: PlatformFilePicker by lazy { createPlatformFilePicker() } | ||
|
||
private fun createPlatformFilePicker(): PlatformFilePicker { | ||
return when (PlatformUtil.current) { | ||
Platform.Windows -> | ||
WindowsFilePicker() | ||
|
||
Platform.MacOS -> | ||
MacOSFilePicker() | ||
|
||
Platform.Linux -> | ||
AwtFilePicker() | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.