FileOpenDialogs.swift 1.2 KB

12345678910111213141516171819202122232425262728
  1. import Foundation
  2. extension BackendFeatures {
  3. /// Backend methods for file open dialogs.
  4. ///
  5. /// These are used by ``EnvironmentValues/chooseFile``.
  6. @MainActor
  7. public protocol FileOpenDialogs: Core {
  8. /// Presents an 'Open file' dialog to the user for selecting files or
  9. /// folders.
  10. ///
  11. /// - Parameters:
  12. /// - fileDialogOptions: The general file dialog options to use.
  13. /// - openDialogOptions: The open dialog-specific options to use.
  14. /// - window: The window to attach the dialog to. If `nil`, the backend
  15. /// can either make the dialog a whole app modal, a standalone window,
  16. /// or a modal for a window of its choosing.
  17. /// - handleResult: The action to perform when the user chooses an item
  18. /// (or multiple items) or cancels the dialog. Receives a
  19. /// `DialogResult<[URL]>`.
  20. func showOpenDialog(
  21. fileDialogOptions: FileDialogOptions,
  22. openDialogOptions: OpenDialogOptions,
  23. window: Window?,
  24. resultHandler handleResult: @escaping (DialogResult<[URL]>) -> Void
  25. )
  26. }
  27. }