Skip to content

Conversation

@alexmercerind
Copy link
Contributor

@alexmercerind alexmercerind commented Oct 4, 2022

Description

This brings support for all the existing package:share_plus methods to Windows:

  • share
  • shareFiles
  • shareWithResult
  • shareFilesWithResult
  • shareXFiles

This pull request adds the modern Share UI (i.e. DataTransferManager) for Windows 10 or greater.
It is very rich in experience & uses same UWP API through WRL.

The feature parity is equivalent as other platforms. Text, subject, images & files are supported.

On older Windows versions, existing behavior is kept (opening mailto: URL with subject & body).

Demo

share_plus_windows_alexmercerind.mp4

Related Issues

This PR closes following issues:

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I haven't updated the version in pubspec.yaml and CHANGELOG.md.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@alexmercerind
Copy link
Contributor Author

alexmercerind commented Oct 4, 2022

This is not exactly a breaking change.
But, since the change causes a big behavioural change from existing, I think it's best to ship it in a major version increment.

EDIT: Feel free to share your feedback. GitHub actions are all green now.

@alexmercerind
Copy link
Contributor Author

Adding integration tests & withResult implementation.

@alexmercerind alexmercerind changed the title [share_plus] share & shareFiles for Windows [share_plus] Native share UI for Windows Oct 5, 2022
@CodeDoctorDE
Copy link
Contributor

The latest release uses XFiles, does it support it?

@alexmercerind
Copy link
Contributor Author

The latest release uses XFiles, does it support it?

Web specific.

@CodeDoctorDE
Copy link
Contributor

Yeah, because of that. But shareFiles is now unsupported

@alexmercerind
Copy link
Contributor Author

alexmercerind commented Oct 5, 2022

Yeah, because of that. But shareFiles is now unsupported

It still uses shareFilesWithResult platform implementation internally. No changes have been introduced to native code of Android, iOS, macOS or Linux in original PR.

This Windows implementation is equivalent & still working similarly.

@override
Future<ShareResult> shareXFiles(
List<XFile> files, {
String? subject,
String? text,
Rect? sharePositionOrigin,
}) {
final mimeTypes =
files.map((e) => e.mimeType ?? _mimeTypeForPath(e.path)).toList();
return shareFilesWithResult(
files.map((e) => e.path).toList(),
mimeTypes: mimeTypes,
subject: subject,
text: text,
sharePositionOrigin: sharePositionOrigin,
);
}

@miquelbeltran
Copy link
Member

Thanks for taking care of the changes in main @alexmercerind !

@alexmercerind
Copy link
Contributor Author

alexmercerind commented Oct 5, 2022

If version 4.5.0 is decided to be merged into 5.0.0, that's something we can do in CHANGELOG.
Other than that, PR is ready. Integration test for Windows is succeeding.

## 5.0.0
- Add support for the Windows Share Dialog i.e. DataTransferManager.
- Add platform specific plugin implementation for Windows.
## 4.5.0
- Add `shareXFiles` implementations
- Deprecate `shareFiles*` implementations
- Enable `shareXFiles` implementations on Web

Copy link
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

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

Tentatively looks good :) But I am not a Windows dev so I cannot comment, any devs familiar with Windows want to give it a look and comment?

@miquelbeltran miquelbeltran added Hacktoberfest Issues taking part in Hacktoberfest hacktoberfest-accepted labels Oct 5, 2022
@miquelbeltran miquelbeltran changed the title [share_plus] Native share UI for Windows feat(share_plus)!: Native share UI for Windows Oct 6, 2022
@miquelbeltran
Copy link
Member

Hey! Due to changes in our contributor guidelines, all PRs should now:

  • Have a title that follows the Conventional Commits format. e.g. feat(package_name)!: feature description
  • DO NOT modify the CHANGELOG.md or the version in the pubspec.yaml. This is going to be an automated process now.

We would ask you kindly to update the PR following these changes.

Thanks!

* Platform specific implementation for using DataTransferManager on Windows
* DataTransferManager is only used on (& available for) Windows 10 builds 17763 or higher.
* On older Windows versions, existing old implementation is used i.e. launching mailto: URIs with subject & body query parameters.
* Getting the share result is not supported on Windows. Thus, shareWithResult & shareFilesWithResult always return ShareResultStatus.unavailable.
* This platform specific implementation beings supports for all existing methods available in package:share_plus to Windows, namely: share, shareFiles, shareWithResult, shareFilesWithResult, shareXFiles.
@alexmercerind
Copy link
Contributor Author

alexmercerind commented Oct 7, 2022

Hi!
I've removed any version changes in pubspec.yaml & edits to CHANGELOG.md.
Also, I've rebased & cleaned-up commit history to keep things tidy.

Thanks for the review process!

@miquelbeltran
Copy link
Member

Later today I will check this on my Windows machine

@miquelbeltran miquelbeltran self-assigned this Oct 7, 2022
@miquelbeltran
Copy link
Member

I checked this locally and works flawlessly, let's go!

@miquelbeltran miquelbeltran merged commit 8e051b4 into fluttercommunity:main Oct 7, 2022
@miquelbeltran
Copy link
Member

Thanks for the work @alexmercerind !

@alexmercerind alexmercerind deleted the win branch November 4, 2022 06:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Hacktoberfest Issues taking part in Hacktoberfest hacktoberfest-accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Add support for the Windows Share Dialog Share.shareFiles Windows.

3 participants