Skip to content

Commit

Permalink
Add back file_picker
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbengtsson committed Sep 2, 2024
1 parent 1de9985 commit 8dc3ffe
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 8 deletions.
50 changes: 50 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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):
Expand All @@ -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`)
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
41 changes: 33 additions & 8 deletions lib/interface/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -541,15 +542,15 @@ class HomeScreenState extends ConsumerState<HomeScreen>
title: const Text('Media'),
onTap: () async {
Navigator.of(context).pop();
openFilePicker(true);
openFilePicker(FileType.media);
},
),
ListTile(
leading: const Icon(Icons.description),
title: const Text('Files'),
onTap: () async {
Navigator.of(context).pop();
openFilePicker(false);
openFilePicker(FileType.any);
},
),
],
Expand All @@ -558,13 +559,37 @@ class HomeScreenState extends ConsumerState<HomeScreen>
});
}

Future<void> openFilePicker(bool mediaOnly) async {
Future<void> openFilePicker(FileType type) async {
isPickingFile = true;
var result = await openFiles();
List<File> 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}');
}
Expand Down Expand Up @@ -756,7 +781,7 @@ class HomeScreenState extends ConsumerState<HomeScreen>
if (Platform.isIOS) {
openPhotoAndFileBottomSheet();
} else {
openFilePicker(false);
openFilePicker(FileType.any);
}
}

Expand Down
16 changes: 16 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8dc3ffe

Please sign in to comment.