From b020c90ac579a3c80441b6c7b3cab2181b31930a Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Tue, 12 Aug 2025 09:50:43 +0900 Subject: [PATCH] feat: support xdp selector for linux use xdp selector --- lib/utils/file_selector.dart | 34 ++++++------------- .../matrix_file_extension.dart | 19 ++++------- pubspec.lock | 4 +-- pubspec.yaml | 4 +-- 4 files changed, 20 insertions(+), 41 deletions(-) diff --git a/lib/utils/file_selector.dart b/lib/utils/file_selector.dart index fd35891af..2e09b492f 100644 --- a/lib/utils/file_selector.dart +++ b/lib/utils/file_selector.dart @@ -3,7 +3,6 @@ import 'package:flutter/widgets.dart'; import 'package:file_picker/file_picker.dart'; import 'package:file_selector/file_selector.dart'; -import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/widgets/app_lock.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; @@ -13,31 +12,18 @@ Future> selectFiles( FileSelectorType type = FileSelectorType.any, bool allowMultiple = false, }) async { - if (!PlatformInfos.isLinux) { - final result = await AppLock.of(context).pauseWhile( - showFutureLoadingDialog( - context: context, - future: () => FilePicker.platform.pickFiles( - compressionQuality: 0, - allowMultiple: allowMultiple, - type: type.filePickerType, - allowedExtensions: type.extensions, - ), + final result = await AppLock.of(context).pauseWhile( + showFutureLoadingDialog( + context: context, + future: () => FilePicker.platform.pickFiles( + compressionQuality: 0, + allowMultiple: allowMultiple, + type: type.filePickerType, + allowedExtensions: type.extensions, ), - ); - return result.result?.xFiles ?? []; - } - - if (allowMultiple) { - return await AppLock.of(context).pauseWhile( - openFiles(confirmButtonText: title, acceptedTypeGroups: type.groups), - ); - } - final file = await AppLock.of(context).pauseWhile( - openFile(confirmButtonText: title, acceptedTypeGroups: type.groups), + ), ); - if (file == null) return []; - return [file]; + return result.result?.xFiles ?? []; } enum FileSelectorType { diff --git a/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart b/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart index 069b6ec8b..f84f21996 100644 --- a/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart +++ b/lib/utils/matrix_sdk_extensions/matrix_file_extension.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:file_picker/file_picker.dart'; -import 'package:file_selector/file_selector.dart'; import 'package:matrix/matrix.dart'; import 'package:share_plus/share_plus.dart'; import 'package:universal_html/html.dart' as html; @@ -20,18 +19,12 @@ extension MatrixFileExtension on MatrixFile { return; } - final downloadPath = !PlatformInfos.isMobile - ? (await getSaveLocation( - suggestedName: name, - confirmButtonText: L10n.of(context).saveFile, - )) - ?.path - : await FilePicker.platform.saveFile( - dialogTitle: L10n.of(context).saveFile, - fileName: name, - type: filePickerFileType, - bytes: bytes, - ); + final downloadPath = await FilePicker.platform.saveFile( + dialogTitle: L10n.of(context).saveFile, + fileName: name, + type: filePickerFileType, + bytes: bytes, + ); if (downloadPath == null) return; if (PlatformInfos.isDesktop) { diff --git a/pubspec.lock b/pubspec.lock index 4fa2798d4..913d28b74 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -410,10 +410,10 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "8f9f429998f9232d65bc4757af74475ce44fc80f10704ff5dfa8b1d14fc429b9" + sha256: ef7d2a085c1b1d69d17b6842d0734aad90156de08df6bd3c12496d0bd6ddf8e2 url: "https://pub.dev" source: hosted - version: "10.2.3" + version: "10.3.1" file_selector: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 28360a08a..59bc2f7d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: dynamic_color: ^1.8.1 emoji_picker_flutter: ^4.3.0 emojis: ^0.9.9 - file_picker: ^10.2.3 + file_picker: ^10.3.1 file_selector: ^1.0.3 flutter: sdk: flutter @@ -144,4 +144,4 @@ dependency_overrides: git: url: https://github.com/ThexXTURBOXx/flutter_web_auth_2.git ref: 3.x-without-v1 - path: flutter_web_auth_2 \ No newline at end of file + path: flutter_web_auth_2