diff --git a/packages/desktop_drop/.gitignore b/packages/desktop_drop/.gitignore index 477b8832..0e070347 100644 --- a/packages/desktop_drop/.gitignore +++ b/packages/desktop_drop/.gitignore @@ -10,4 +10,4 @@ build/ *.iml -pubspec.lock \ No newline at end of file +/pubspec.lock \ No newline at end of file diff --git a/packages/desktop_drop/CHANGELOG.md b/packages/desktop_drop/CHANGELOG.md index bf90c2dc..cb5ea765 100644 --- a/packages/desktop_drop/CHANGELOG.md +++ b/packages/desktop_drop/CHANGELOG.md @@ -1,12 +1,21 @@ # Changelog +## 0.4.1 + +* [macOS] improve enumerateDraggingItems on macOS. + ## 0.4.0 -* [Android] update to later version of kotlin(1.5.2). [#155](https://github.com/MixinNetwork/flutter-plugins/pull/155) by [Cal Holloway](https://github.com/CalHoll) -* [macOS] Fix broken gestures when used with modified MainFlutterWindow. [#162](https://github.com/MixinNetwork/flutter-plugins/pull/162) by [Josh Matthews](https://github.com/jmatth) + +* [Android] update to later version of kotlin(1.5.2). [#155](https://github.com/MixinNetwork/flutter-plugins/pull/155) + by [Cal Holloway](https://github.com/CalHoll) +* [macOS] Fix broken gestures when used with modified + MainFlutterWindow. [#162](https://github.com/MixinNetwork/flutter-plugins/pull/162) + by [Josh Matthews](https://github.com/jmatth) ## 0.3.3 -* Fix dragging multiple files at once from Apple Music does not work well. [#72](https://github.com/MixinNetwork/flutter-plugins/issues/72) +* Fix dragging multiple files at once from Apple Music does not work + well. [#72](https://github.com/MixinNetwork/flutter-plugins/issues/72) ## 0.3.2 @@ -19,6 +28,7 @@ ## 0.3.0 ** BREAK CHANGES** + * replace DropDoneDetails property `urls: List` to `files: List`. which is more general. ## 0.2.0 diff --git a/packages/desktop_drop/example/lib/main.dart b/packages/desktop_drop/example/lib/main.dart index aacb23c5..0a65ec37 100644 --- a/packages/desktop_drop/example/lib/main.dart +++ b/packages/desktop_drop/example/lib/main.dart @@ -96,7 +96,7 @@ class _ExampleDragTargetState extends State { alignment: Alignment.topRight, child: Text( '$offset', - style: Theme.of(context).textTheme.caption, + style: Theme.of(context).textTheme.bodySmall, ), ) ], diff --git a/packages/desktop_drop/example/macos/Podfile b/packages/desktop_drop/example/macos/Podfile index dade8dfa..049abe29 100644 --- a/packages/desktop_drop/example/macos/Podfile +++ b/packages/desktop_drop/example/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.11' +platform :osx, '10.14' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/desktop_drop/example/macos/Podfile.lock b/packages/desktop_drop/example/macos/Podfile.lock index 264250f3..1486ff39 100644 --- a/packages/desktop_drop/example/macos/Podfile.lock +++ b/packages/desktop_drop/example/macos/Podfile.lock @@ -15,8 +15,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898 - FlutterMacOS: ae6af50a8ea7d6103d888583d46bd8328a7e9811 + FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 -PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c +PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7 COCOAPODS: 1.11.3 diff --git a/packages/desktop_drop/example/macos/Runner.xcodeproj/project.pbxproj b/packages/desktop_drop/example/macos/Runner.xcodeproj/project.pbxproj index 62ca5c5f..c7e0ff64 100644 --- a/packages/desktop_drop/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/desktop_drop/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -203,7 +203,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 33CC10EC2044A3C60003C045 = { @@ -256,6 +256,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3399D490228B24CF009A79C7 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -404,7 +405,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -483,7 +484,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -530,7 +531,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.11; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/packages/desktop_drop/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/desktop_drop/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index d02ece03..a9aec884 100644 --- a/packages/desktop_drop/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/desktop_drop/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =2.17.0-0 <3.0.0" + dart: ">=2.18.0 <3.0.0" flutter: ">=1.22.0" diff --git a/packages/desktop_drop/macos/Classes/DesktopDropPlugin.swift b/packages/desktop_drop/macos/Classes/DesktopDropPlugin.swift index b1d42f06..8a4acbda 100644 --- a/packages/desktop_drop/macos/Classes/DesktopDropPlugin.swift +++ b/packages/desktop_drop/macos/Classes/DesktopDropPlugin.swift @@ -28,17 +28,9 @@ public class DesktopDropPlugin: NSObject, FlutterPlugin { let d = DropTarget(frame: vc.view.bounds, channel: channel) d.autoresizingMask = [.width, .height] - var dragTypes = [NSPasteboard.PasteboardType]() + d.registerForDraggedTypes(NSFilePromiseReceiver.readableDraggedTypes.map { NSPasteboard.PasteboardType($0) }) + d.registerForDraggedTypes([NSPasteboard.PasteboardType.fileURL]) - if #available(macOS 10.12, *) { - dragTypes.append(contentsOf: NSFilePromiseReceiver.readableDraggedTypes.map { NSPasteboard.PasteboardType($0) }) - } - - if #available(macOS 10.13, *) { - dragTypes.append(.fileURL) - } - dragTypes.append(.filePromise) - d.registerForDraggedTypes(dragTypes) vc.view.addSubview(d) registrar.addMethodCallDelegate(instance, channel: channel) @@ -98,32 +90,24 @@ class DropTarget: NSView { let group = DispatchGroup() - if #available(macOS 10.12, *) { - // retrieve NSFilePromise. - sender.enumerateDraggingItems(options: [], for: nil, classes: [NSFilePromiseReceiver.self], searchOptions: searchOptions) { draggingItem, _, _ in - if let filePromiseReceiver = draggingItem.item as? NSFilePromiseReceiver { - group.enter() - filePromiseReceiver.receivePromisedFiles(atDestination: self.destinationURL, options: [:], operationQueue: self.workQueue) { fileURL, error in - if let error = error { - debugPrint("error: \(error)") - } else { - urls.append(fileURL.path) - } - group.leave() + // retrieve NSFilePromise. + sender.enumerateDraggingItems(options: [], for: nil, classes: [NSFilePromiseReceiver.self, NSURL.self], searchOptions: searchOptions) { draggingItem, _, _ in + switch draggingItem.item { + case let filePromiseReceiver as NSFilePromiseReceiver: + group.enter() + filePromiseReceiver.receivePromisedFiles(atDestination: self.destinationURL, options: [:], operationQueue: self.workQueue) { fileURL, error in + if let error = error { + debugPrint("error: \(error)") + } else { + urls.append(fileURL.path) } - return + group.leave() } - } - } - - let pasteboardObjects = sender.draggingPasteboard.readObjects(forClasses: [NSURL.self], options: searchOptions) - - pasteboardObjects?.forEach({ item in - if let fileURL = item as? URL { + case let fileURL as URL: urls.append(fileURL.path) - return + default: break } - }) + } group.notify(queue: .main) { self.channel.invokeMethod("performOperation", arguments: urls) diff --git a/packages/desktop_drop/pubspec.yaml b/packages/desktop_drop/pubspec.yaml index c17d3604..911819a7 100644 --- a/packages/desktop_drop/pubspec.yaml +++ b/packages/desktop_drop/pubspec.yaml @@ -1,6 +1,6 @@ name: desktop_drop description: A plugin which allows user dragging files to your flutter desktop applications. -version: 0.4.0 +version: 0.4.1 homepage: https://github.com/MixinNetwork/flutter-plugins/tree/main/packages/desktop_drop environment: