diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 4afef18..ce80649 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,6 +1,40 @@ PODS: - device_info_plus (0.0.1): - Flutter + - DKImagePickerController/Core (4.3.9): + - DKImagePickerController/ImageDataManager + - DKImagePickerController/Resource + - DKImagePickerController/ImageDataManager (4.3.9) + - DKImagePickerController/PhotoGallery (4.3.9): + - DKImagePickerController/Core + - DKPhotoGallery + - DKImagePickerController/Resource (4.3.9) + - DKPhotoGallery (0.0.19): + - DKPhotoGallery/Core (= 0.0.19) + - DKPhotoGallery/Model (= 0.0.19) + - DKPhotoGallery/Preview (= 0.0.19) + - DKPhotoGallery/Resource (= 0.0.19) + - SDWebImage + - SwiftyGif + - DKPhotoGallery/Core (0.0.19): + - DKPhotoGallery/Model + - DKPhotoGallery/Preview + - SDWebImage + - SwiftyGif + - DKPhotoGallery/Model (0.0.19): + - SDWebImage + - SwiftyGif + - DKPhotoGallery/Preview (0.0.19): + - DKPhotoGallery/Model + - DKPhotoGallery/Resource + - SDWebImage + - SwiftyGif + - DKPhotoGallery/Resource (0.0.19): + - SDWebImage + - SwiftyGif + - file_picker (0.0.1): + - DKImagePickerController/PhotoGallery + - Flutter - file_selector_ios (0.0.1): - Flutter - Flutter (1.0.0) @@ -22,6 +56,9 @@ PODS: - Flutter - receive_sharing_intent (1.8.0): - Flutter + - SDWebImage (5.19.7): + - SDWebImage/Core (= 5.19.7) + - SDWebImage/Core (5.19.7) - Sentry/HybridSDK (8.35.1) - sentry_flutter (8.8.0): - Flutter @@ -32,6 +69,7 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS + - SwiftyGif (5.4.5) - url_launcher_ios (0.0.1): - Flutter - wakelock (0.0.1): @@ -40,6 +78,7 @@ PODS: DEPENDENCIES: - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) + - file_picker (from `.symlinks/plugins/file_picker/ios`) - file_selector_ios (from `.symlinks/plugins/file_selector_ios/ios`) - Flutter (from `Flutter`) - flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`) @@ -58,12 +97,18 @@ DEPENDENCIES: SPEC REPOS: trunk: + - DKImagePickerController + - DKPhotoGallery + - SDWebImage - Sentry + - SwiftyGif - WebRTC-SDK EXTERNAL SOURCES: device_info_plus: :path: ".symlinks/plugins/device_info_plus/ios" + file_picker: + :path: ".symlinks/plugins/file_picker/ios" file_selector_ios: :path: ".symlinks/plugins/file_selector_ios/ios" Flutter: @@ -97,6 +142,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d + DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c + DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60 + file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655 file_selector_ios: f0670c1064a8c8450e38145d8043160105d0b97c Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_webrtc: 75b868e4f9e817c7a9a42ca4b6169063de4eec9f @@ -107,10 +155,12 @@ SPEC CHECKSUMS: path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 quick_look: 59394001d6b484c13fd5f73b555398d523726c8c receive_sharing_intent: df9c334dc9feadcbd3266e5cb49c8443405e1c9f + SDWebImage: 8a6b7b160b4d710e2a22b6900e25301075c34cb3 Sentry: 1fe34e9c2cbba1e347623610d26db121dcb569f1 sentry_flutter: a39c2a2d67d5e5b9cb0b94a4985c76dd5b3fc737 share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 + SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f WebRTC-SDK: c3d69a87e7185fad3568f6f3cff7c9ac5890acf3 diff --git a/lib/interface/home.dart b/lib/interface/home.dart index 8de31b0..b1f6db8 100644 --- a/lib/interface/home.dart +++ b/lib/interface/home.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:desktop_drop/desktop_drop.dart'; +import 'package:file_picker/file_picker.dart'; import 'package:file_selector/file_selector.dart'; import 'package:firedart/firedart.dart'; import 'package:flutter/foundation.dart'; @@ -541,7 +542,7 @@ class HomeScreenState extends ConsumerState title: const Text('Media'), onTap: () async { Navigator.of(context).pop(); - openFilePicker(true); + openFilePicker(FileType.media); }, ), ListTile( @@ -549,7 +550,7 @@ class HomeScreenState extends ConsumerState title: const Text('Files'), onTap: () async { Navigator.of(context).pop(); - openFilePicker(false); + openFilePicker(FileType.any); }, ), ], @@ -558,13 +559,37 @@ class HomeScreenState extends ConsumerState }); } - Future openFilePicker(bool mediaOnly) async { + Future openFilePicker(FileType type) async { isPickingFile = true; - var result = await openFiles(); + List files = []; + if (type == FileType.media) { + // Only use file_picker on mobile iOS to picker media. + // file_picker was not working without hacks on linux + var result = await FilePicker.platform.pickFiles( + dialogTitle: 'Image or Video', + type: FileType.media, + lockParentWindow: true, + withData: false, + allowCompression: false, + withReadStream: true, + allowMultiple: true, + ); + if (result != null) { + for (var file in result.files) { + String? filePath = file.path; + if (filePath == null) { + continue; + } + files.add(File(filePath)); + } + } + } else { + var xfiles = await openFiles(); + files = xfiles.map((it) => File(it.path)).toList(); + } - if (result.isNotEmpty) { - var files = result.map((it) => File(it.path!)).toList(); - var param = mediaOnly ? 'media' : 'fileManager'; + if (files.isNotEmpty) { + var param = type == FileType.media ? 'media' : 'fileManager'; await setPayload(FilePayload(files), param); logger('HOME: File selected ${files.length}'); } @@ -756,7 +781,7 @@ class HomeScreenState extends ConsumerState if (Platform.isIOS) { openPhotoAndFileBottomSheet(); } else { - openFilePicker(false); + openFilePicker(FileType.any); } } diff --git a/pubspec.lock b/pubspec.lock index 150f639..9c5e810 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -222,6 +222,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + file_picker: + dependency: "direct main" + description: + name: file_picker + sha256: "167bb619cdddaa10ef2907609feb8a79c16dfa479d3afaf960f8e223f754bf12" + url: "https://pub.dev" + source: hosted + version: "8.1.2" file_selector: dependency: "direct main" description: @@ -320,6 +328,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "9ee02950848f61c4129af3d6ec84a1cfc0e47931abc746b03e7a3bc3e8ff6eda" + url: "https://pub.dev" + source: hosted + version: "2.0.22" flutter_riverpod: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b6ebb31..4297dfb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,6 +38,7 @@ dependencies: pasteboard: ^0.2.0 file_selector: ^1.0.3 in_app_review: ^2.0.9 + file_picker: ^8.1.2 dev_dependencies: integration_test: