Repository: unoplatform/uno
File: src/Uno.UWP/Storage/Pickers/FileOpenPicker.iOS.cs (C#)

Code before:

					return controller;

				case PickerLocationId.PicturesLibrary when multiple is true && iOS14AndAbove is true:
					var hasImages = FileTypeFilter.Count == 0 || FileTypeFilter.Contains("*") ||
					                FilterHasImage(FileTypeFilter);
					var hasVideos = FileTypeFilter.Count == 0 || FileTypeFilter.Contains("*") ||
					                FilterHasVideo(FileTypeFilter);

					PHPickerFilter? pickerFilter = null;
					if (hasImages && hasVideos)
					{
						// Support both images and videos
						pickerFilter = PHPickerFilter.GetAnyFilterMatchingSubfilters([
							PHPickerFilter.ImagesFilter, PHPickerFilter.VideosFilter
						]);
					}
					else if (hasImages)
					{
						pickerFilter = PHPickerFilter.ImagesFilter;
					}
					else if (hasVideos)
					{
						pickerFilter = PHPickerFilter.VideosFilter;
					}

					var imageConfiguration = new PHPickerConfiguration
					{
						Filter = pickerFilter, SelectionLimit = limit
					};
					return new PHPickerViewController(imageConfiguration)
					{
						Delegate = new PhotoPickerDelegate(completionSource)
					};
				case PickerLocationId.VideosLibrary when multiple is true && iOS14AndAbove is true:
					var videoConfiguration = new PHPickerConfiguration
					{
						Filter = PHPickerFilter.VideosFilter,
						SelectionLimit = limit
					};
					return new PHPickerViewController(videoConfiguration)
					{
						Delegate = new PhotoPickerDelegate(completionSource)
					};

				default:
					var documentTypes = UTTypeMapper.GetDocumentTypes(FileTypeFilter);
					return new UIDocumentPickerViewController(documentTypes, UIDocumentPickerMode.Open)
					{
						AllowsMultipleSelection = multiple,
						ShouldShowFileExtensions = true,

Review comment (suggestion):
I feel like we are duplicating code here. Couldn't we merge the two cases to handle both photos and videos? Like so:

```csharp
case PickerLocationId.PicturesLibrary when multiple is true && iOS14AndAbove is true:
case PickerLocationId.VideosLibrary when multiple is true && iOS14AndAbove is true:
	var pickerFilter = GetPhotoPickerFilter(FileTypeFilter);
	var pickerConfiguration = new PHPickerConfiguration
	{
		Filter = pickerFilter,
		SelectionLimit = limit
	};
	return new PHPickerViewController(pickerConfiguration)
```

and 

```csharp
private static PHPickerFilter? GetPhotoPickerFilter(IList<string> fileTypeFilter)
{
	var acceptsAll = fileTypeFilter.Count == 0 || fileTypeFilter.Contains("*");
	var hasImages = acceptsAll || FilterHasImage(fileTypeFilter);
	var hasVideos = acceptsAll || FilterHasVideo(fileTypeFilter);

	return (hasImages, hasVideos) switch
	{
		(true, true) => PHPickerFilter.GetAnyFilterMatchingSubfilters([PHPickerFilter.ImagesFilter, PHPickerFilter.VideosFilter]),
		(true, false) => PHPickerFilter.ImagesFilter,
		(false, true) => PHPickerFilter.VideosFilter,
		_ => null
	};
}
```

Code after:

					return controller;

				case PickerLocationId.PicturesLibrary when multiple is true && iOS14AndAbove is true:
				case PickerLocationId.VideosLibrary when multiple is true && iOS14AndAbove is true:
					var pickerFilter = GetPhotoPickerFilter(FileTypeFilter);
					var pickerConfiguration = new PHPickerConfiguration
					{
						Filter = pickerFilter,
						SelectionLimit = limit
					};
					return new PHPickerViewController(pickerConfiguration)
					{
						Delegate = new PhotoPickerDelegate(completionSource)
					};

				default:
					var documentTypes = UTTypeMapper.GetDocumentTypes(FileTypeFilter);
					return new UIDocumentPickerViewController(documentTypes, UIDocumentPickerMode.Open)
					{
						AllowsMultipleSelection = multiple,
						ShouldShowFileExtensions = true,
						Delegate = new FileOpenPickerDelegate(completionSource)
					};
			}
		}

		private async Task<FilePickerSelectedFilesArray> PickFilesAsync(bool multiple, CancellationToken token)
		{
			var rootController = UIApplication.SharedApplication?.KeyWindow?.RootViewController;
			if (rootController == null)
			{
				throw new InvalidOperationException("Root controller not initialized yet. FolderPicker invoked too early.");
			}

			var completionSource = new TaskCompletionSource<StorageFile?[]>();

			using var viewController = this.GetViewController(multiple, _multipleFileLimit, completionSource);

			viewController.OverrideUserInterfaceStyle = CoreApplication.RequestedTheme == SystemTheme.Light ?
				UIUserInterfaceStyle.Light : UIUserInterfaceStyle.Dark;

			if (viewController.PresentationController != null)
			{
				viewController.PresentationController.Delegate = new FileOpenPickerPresentationControllerDelegate(completionSource);
			}

			await rootController.PresentViewControllerAsync(viewController, true);

			var files = await completionSource.Task;