fsprojects / Avalonia.FuncUI

Develop cross-plattform GUI Applications using F# and Avalonia!
https://funcui.avaloniaui.net/
MIT License
889 stars 72 forks source link

Change the Elmish music player example to use IStorageProvider instea… #407

Open Numpsy opened 3 months ago

Numpsy commented 3 months ago

…d of the obsoleted OpenFileDialog/OpenFolderDialog

As it stands, there are a bunch of build warnings about using the deprecated file / folder picker APIs, and this is an attempt to sort those by changing it to use the newer IStorageProvider interfaces.

Notes: 1) Only changes the picker access, the files/folder are still stored as string file paths 2) IStorageFolder has functions for listing items in the folder, but they're async, so I left populateFromDirectory mapping back into paths to avoid further changes for now.

Numpsy commented 3 months ago

Only presently tested on Windows - will try to try it on a mac next week.

Hmm, the only mac I have to try it on is an old Intel iMac, but on that the existing example code crashes with an error about drag regions being invalidated off the main thread when I click the open menu items :-(

JaggerJo commented 3 months ago

@Numpsy I can test on a modern mac if you want.

Numpsy commented 3 months ago

@Numpsy I can test on a modern mac if you want.

Making it call the open-picker functions through Dispatcher.UIThread.InvokeAsync has got it working on the old iMac and on Windows and I can try it on Ubuntu later, so if you'd be able to try it on a newer mac that'd be useful (my knowledge of how this interops with runWithAvaloniaSyncDispatch in Elmish programs is rather thin)

I can try it on Ubuntu later

Ok, it worked on my Ubuntu 22.04 / Gnome / Wayland laptop but it needed an update to a newer version of LibVLCSharp to fix some startup errors about libX11, so I'll see about doing that too.

Numpsy commented 1 month ago

Anyway, this works for me on

Windows Ubuntu 22.04 (Gnome / Wayland) macOS 10.15

When in only worked on Windows before.

@JaggerJo If you're able to test on a current mac before merging that would be nice (I've seen other bugs where the file dialog behaviour got changed in macOS updates, so may as well try even though it's only an example I think)