-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(share_plus)!: Native share UI for Windows #1158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
03107dd
ci: enable share_plus integration tests for windows
alexmercerind 8ac8a22
fix: windows support in share_plus example
alexmercerind 98d31e6
test: update share_plus_windows tests
alexmercerind 4517fcf
feat(share_plus)!: native share dialog for windows
alexmercerind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/share_plus/share_plus/example/lib/utils/file_picker_web.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /// Dummy implementation for non `dart.library.io` platforms. | ||
| Future<String?> pickFile() async { | ||
| throw UnimplementedError(); | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/share_plus/share_plus/example/lib/utils/file_picker_win.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import 'package:filepicker_windows/filepicker_windows.dart'; | ||
|
|
||
| /// Picks a file from the file system on Windows & returns it's path as [String]. | ||
| Future<String?> pickFile() async { | ||
| final picker = OpenFilePicker() | ||
| ..filterSpecification = {'Images': '*.jpg;*.jpeg;*.png;*.gif'}; | ||
| final result = picker.getFile(); | ||
| return result?.path; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Defines the Chromium style for automatic reformatting. | ||
| # http://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
| BasedOnStyle: Chromium | ||
| # This defaults to 'Auto'. Explicitly set it for a while, so that | ||
| # 'vector<vector<int> >' in existing files gets formatted to | ||
| # 'vector<vector<int>>'. ('Auto' means that clang-format will only use | ||
| # 'int>>' if the file already contains at least one such instance.) | ||
| Standard: Cpp11 | ||
| SortIncludes: true | ||
| --- | ||
| Language: ObjC | ||
| ColumnLimit: 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/share_plus/share_plus_windows/lib/src/version_helper.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import 'dart:io'; | ||
| import 'dart:ffi'; | ||
| import 'package:ffi/ffi.dart'; | ||
| import 'package:win32/win32.dart'; | ||
|
|
||
| class VersionHelper { | ||
| static VersionHelper instance = VersionHelper._(); | ||
|
|
||
| /// Whether the current OS is Windows 10 Redstone 5 or later. | ||
| /// This is used to determine whether the modern Share UI i.e. `DataTransferManager` is available or not. | ||
| /// | ||
| /// References: https://en.wikipedia.org/wiki/Windows_10_version_history | ||
| /// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa | ||
| /// | ||
| bool isWindows10RS5OrGreater = false; | ||
|
|
||
| static const int _kWindows10RS5BuildNumber = 17763; | ||
|
|
||
| VersionHelper._() { | ||
| if (Platform.isWindows) { | ||
| final pointer = calloc<OSVERSIONINFOEX>(); | ||
| pointer.ref | ||
| ..dwOSVersionInfoSize = sizeOf<OSVERSIONINFOEX>() | ||
| ..dwBuildNumber = 0 | ||
| ..dwMajorVersion = 0 | ||
| ..dwMinorVersion = 0 | ||
| ..dwPlatformId = 0 | ||
| ..szCSDVersion = '' | ||
| ..wServicePackMajor = 0 | ||
| ..wServicePackMinor = 0 | ||
| ..wSuiteMask = 0 | ||
| ..wProductType = 0 | ||
| ..wReserved = 0; | ||
| final rtlGetVersion = DynamicLibrary.open('ntdll.dll').lookupFunction< | ||
| Void Function(Pointer<OSVERSIONINFOEX>), | ||
| void Function(Pointer<OSVERSIONINFOEX>)>('RtlGetVersion'); | ||
| rtlGetVersion(pointer); | ||
| isWindows10RS5OrGreater = | ||
| pointer.ref.dwBuildNumber >= _kWindows10RS5BuildNumber; | ||
| calloc.free(pointer); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 55 additions & 23 deletions
78
packages/share_plus/share_plus_windows/test/share_plus_windows_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| flutter/ | ||
|
|
||
| # Visual Studio user-specific files. | ||
| *.suo | ||
| *.user | ||
| *.userosscache | ||
| *.sln.docstates | ||
|
|
||
| # Visual Studio build-related files. | ||
| x64/ | ||
| x86/ | ||
|
|
||
| # Visual Studio cache files | ||
| # files ending in .cache can be ignored | ||
| *.[Cc]ache | ||
| # but keep track of directories ending in .cache | ||
| !*.[Cc]ache/ |
53 changes: 53 additions & 0 deletions
53
packages/share_plus/share_plus_windows/windows/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # The Flutter tooling requires that developers have a version of Visual Studio | ||
| # installed that includes CMake 3.14 or later. You should not increase this | ||
| # version, as doing so will cause the plugin to fail to compile for some | ||
| # customers of the plugin. | ||
| cmake_minimum_required(VERSION 3.14) | ||
|
|
||
| # Project-level configuration. | ||
| set(PROJECT_NAME "share_plus_windows") | ||
| project(${PROJECT_NAME} LANGUAGES CXX) | ||
|
|
||
| # This value is used when generating builds using this plugin, so it must | ||
| # not be changed | ||
| set(PLUGIN_NAME "share_plus_windows_plugin") | ||
|
|
||
| # Any new source files that you add to the plugin should be added here. | ||
| list(APPEND PLUGIN_SOURCES | ||
| "share_plus_windows_plugin.cpp" | ||
| "share_plus_windows_plugin.h" | ||
| ) | ||
|
|
||
| # Define the plugin library target. Its name must not be changed (see comment | ||
| # on PLUGIN_NAME above). | ||
| add_library(${PLUGIN_NAME} SHARED | ||
| "include/share_plus_windows/share_plus_windows_plugin_c_api.h" | ||
| "share_plus_windows_plugin_c_api.cpp" | ||
| ${PLUGIN_SOURCES} | ||
| ) | ||
|
|
||
| # Apply a standard set of build settings that are configured in the | ||
| # application-level CMakeLists.txt. This can be removed for plugins that want | ||
| # full control over build settings. | ||
| apply_standard_settings(${PLUGIN_NAME}) | ||
|
|
||
| # Symbols are hidden by default to reduce the chance of accidental conflicts | ||
| # between plugins. This should not be removed; any symbols that should be | ||
| # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. | ||
| set_target_properties(${PLUGIN_NAME} PROPERTIES | ||
| CXX_VISIBILITY_PRESET hidden) | ||
| target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) | ||
|
|
||
| # Source include directories and library dependencies. Add any plugin-specific | ||
| # dependencies here. | ||
| target_include_directories(${PLUGIN_NAME} INTERFACE | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/include") | ||
| target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) | ||
|
|
||
| # List of absolute paths to libraries that should be bundled with the plugin. | ||
| # This list could contain prebuilt libraries, or libraries created by an | ||
| # external build triggered from this build file. | ||
| set(share_plus_windows_bundled_libraries | ||
| "" | ||
| PARENT_SCOPE | ||
| ) |
23 changes: 23 additions & 0 deletions
23
...s/share_plus_windows/windows/include/share_plus_windows/share_plus_windows_plugin_c_api.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #ifndef FLUTTER_PLUGIN_SHARE_PLUS_WINDOWS_PLUGIN_C_API_H_ | ||
| #define FLUTTER_PLUGIN_SHARE_PLUS_WINDOWS_PLUGIN_C_API_H_ | ||
|
|
||
| #include <flutter_plugin_registrar.h> | ||
|
|
||
| #ifdef FLUTTER_PLUGIN_IMPL | ||
| #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) | ||
| #else | ||
| #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) | ||
| #endif | ||
|
|
||
| #if defined(__cplusplus) | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| FLUTTER_PLUGIN_EXPORT void SharePlusWindowsPluginCApiRegisterWithRegistrar( | ||
| FlutterDesktopPluginRegistrarRef registrar); | ||
|
|
||
| #if defined(__cplusplus) | ||
| } // extern "C" | ||
| #endif | ||
|
|
||
| #endif // FLUTTER_PLUGIN_SHARE_PLUS_WINDOWS_PLUGIN_C_API_H_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.