Skip to content

Make ordered selection optional in the iOS photo picker - #2242

Open
vicajilau wants to merge 3 commits into
mainfrom
feat/darwin-ordered-selection-option
Open

vicajilau wants to merge 3 commits into
mainfrom
feat/darwin-ordered-selection-option

Conversation

@vicajilau

Copy link
Copy Markdown
Owner

Fixes #2241

Problem

Since 12.x the iOS photo library picker always uses PHPickerConfiguration.Selection.ordered, added in #2047 to keep the results in selection order (#1866). Ordered selection also disables selecting several items by swiping across the grid, so users have to tap every photo one by one, which is a real regression for apps that pick many photos at once.

#2047 made two changes: it stores the results by index, which keeps them in the order PHPicker returns them, and it enables .ordered. Only .ordered is documented to return the results in the order the user selected them, so simply removing it could bring #1866 back.

Change

  • New DarwinOptions.orderedSelection, true by default, so the selection order keeps being guaranteed and nothing changes for existing apps.
  • IOSFilePickerHandler only applies .ordered when it is enabled. Apps that do not care about the order can set it to false to restore swipe to select.
  • README section next to the photo library asset representation one, and a toggle in the example.

file_picker_platform_interface 4.1.0 (new field) and file_picker_darwin 2.2.0, which raises its interface lower bound to ^4.1.0.

Testing

  • New tests for the default value and for the option being sent over the method channel, true by default and false when disabled, for both pickFile() and pickFiles().
  • Analysis is clean across the workspace and the example builds for the iOS simulator.
  • PHPicker cannot be driven from tests, so this still needs a manual check: with the toggle on, swipe to select stays disabled and the photos come back in selection order, and with it off, swipe to select works.

The photo library picker always used PHPickerConfiguration.Selection.ordered, added in #2047 to keep results in selection order. Ordered selection also disables selecting several items by swiping across the grid, so users of apps that pick many photos have to tap each one.

Add DarwinOptions.orderedSelection, true by default so the order keeps being guaranteed, and only apply .ordered when it is enabled. Apps that do not care about the order can set it to false to restore swipe to select. The example gets a toggle for it.

Bumps file_picker_platform_interface to 4.1.0 and file_picker_darwin to 2.2.0.

Fixes #2241
The doc said it had no effect with the iOS document picker, which does not tell which FileType uses which picker. Name image, video and media, the types that go through the photo library picker.
79efba3 picked up a local DEVELOPMENT_TEAM change to the example's Xcode project by accident.
@vicajilau

Copy link
Copy Markdown
Owner Author

Heads up @navaronbracke: could #2244 land before this one? Both bump file_picker_darwin (2.1.4 there, 2.2.0 here), and #2244 is a bug fix that can ship on its own. Once it's in, I'll bring main into this branch so the changelog reads 2.2.0 on top of 2.1.4. Thanks! 🙂


test('pickFile and pickFiles send orderedSelection', () async {
final picker = FilePickerDarwin();
bool? received;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool? received;
bool? orderedSelection;

);
expect(received, isFalse);

await picker.pickFile(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await picker.pickFile(type: FileType.media); is not tested (the default for pickFile)

## 2.2.0

- Added support for `DarwinOptions.orderedSelection`. Setting it to `false` restores swipe to select in the iOS photo library picker, which ordered selection disables. [#2241](https://github.com/vicajilau/flutter_file_picker/issues/2241)
- Raised the `file_picker_platform_interface` lower bound to `^4.1.0`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis line is redundant, since the lockfile will tell the user

- Raised the `file_picker_platform_interface` lower bound to `^4.1.0`.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] configuration.selection = .ordered disables swipe-to-select in media picker

2 participants