Pablo
01/15/2025, 2:30 PMFileDialog
file picker? is not a Composable... but it displays a view on top of my composables:
fun openFilePicker(title: String, onFileSelected: (String) -> Unit) {
val fileDialog = FileDialog(Frame(), title, FileDialog.LOAD)
fileDialog.isVisible = true
// Centering dialog
val screenSize: Dimension = Toolkit.getDefaultToolkit().screenSize
val centerX = screenSize.width / 2
val centerY = screenSize.height / 2
fileDialog.setLocation(centerX, centerY)
val selectedFilePath = fileDialog.file?.let { "${fileDialog.directory}$it" }
selectedFilePath?.let {
extractZipToFolder(it, "gtfs-files")
onFileSelected(it)
}
}
At this moment I have it on my class where I have my screen composables, but I'm trying to figure out if I must place it on my viewmodel or where must place it and how to manage it's result.
I display it on my Composable when a button is pressed, just adding this on my composable onclick:
openFilePicker(
title = filePickerDialogTitle,
onFileSelected = {
vm.updateGTFSFile(it)
}
)
Sanlorng
01/15/2025, 3:40 PMPablo
01/15/2025, 4:08 PMSanlorng
01/15/2025, 5:28 PMSanlorng
01/15/2025, 5:30 PMPablo
01/15/2025, 5:35 PMSanlorng
01/15/2025, 11:21 PM