Skip to content

Commit

Permalink
feat(iOS): FileOpenPicker limit multiple file selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Jun 6, 2024
1 parent ce2d123 commit a19cf32
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/Uno.UWP/Storage/Pickers/FileOpenPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,27 @@ internal void SetMultipleFileLimit(int limit)

public static class FileOpenPickerExtensions
{
#if __IOS__
/// <summary>
/// Sets the file limit a user can select when picking multiple files.
/// </summary>
/// <param name="limit">The maximum number of files that the user can pick.</param>
public static void SetLimit(this FileOpenPicker picker, int limit)
{
picker.SetMultipleFileLimit(limit);
}

/// <summary>
/// Shows the file picker so that the user can pick multiple files.
/// </summary>
/// <param name="limit">The maximum number of files that the user can pick.</param>
/// <returns>When the call to this method completes successfully, it returns a <see cref="FilePickerSelectedFilesArray"/> object that contains
/// all the files that were picked by the user. Picked files in this array are represented by <see cref="StorageFile"/> objects.</returns>
public static IAsyncOperation<IReadOnlyList<StorageFile>> PickMultipleFilesAsync(this FileOpenPicker picker, int limit)
{
picker.SetMultipleFileLimit(limit);
return picker.PickMultipleFilesAsync();
}
#endif
}
}
2 changes: 1 addition & 1 deletion src/Uno.UWP/Storage/Pickers/FileOpenPicker.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private UIViewController GetViewController(bool multiple, int limit, TaskComplet
var documentTypes = UTTypeMapper.GetDocumentTypes(FileTypeFilter);
return new UIDocumentPickerViewController(documentTypes, UIDocumentPickerMode.Open)
{
AllowsMultipleSelection = multiple,
AllowsMultipleSelection = multiple,
ShouldShowFileExtensions = true,
Delegate = new FileOpenPickerDelegate(completionSource)
};
Expand Down

0 comments on commit a19cf32

Please sign in to comment.