Merge pull request #1981 from Decodetalkers/supportxdp
feat: support xdp selector for linux
This commit is contained in:
commit
c8d2bd8d0a
3 changed files with 17 additions and 38 deletions
|
|
@ -3,7 +3,6 @@ import 'package:flutter/widgets.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:file_selector/file_selector.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/app_lock.dart';
|
||||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||||
|
|
||||||
|
|
@ -13,31 +12,18 @@ Future<List<XFile>> selectFiles(
|
||||||
FileSelectorType type = FileSelectorType.any,
|
FileSelectorType type = FileSelectorType.any,
|
||||||
bool allowMultiple = false,
|
bool allowMultiple = false,
|
||||||
}) async {
|
}) async {
|
||||||
if (!PlatformInfos.isLinux) {
|
final result = await AppLock.of(context).pauseWhile(
|
||||||
final result = await AppLock.of(context).pauseWhile(
|
showFutureLoadingDialog(
|
||||||
showFutureLoadingDialog(
|
context: context,
|
||||||
context: context,
|
future: () => FilePicker.platform.pickFiles(
|
||||||
future: () => FilePicker.platform.pickFiles(
|
compressionQuality: 0,
|
||||||
compressionQuality: 0,
|
allowMultiple: allowMultiple,
|
||||||
allowMultiple: allowMultiple,
|
type: type.filePickerType,
|
||||||
type: type.filePickerType,
|
allowedExtensions: type.extensions,
|
||||||
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 result.result?.xFiles ?? [];
|
||||||
return [file];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FileSelectorType {
|
enum FileSelectorType {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:file_selector/file_selector.dart';
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
|
|
@ -20,18 +19,12 @@ extension MatrixFileExtension on MatrixFile {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final downloadPath = !PlatformInfos.isMobile
|
final downloadPath = await FilePicker.platform.saveFile(
|
||||||
? (await getSaveLocation(
|
dialogTitle: L10n.of(context).saveFile,
|
||||||
suggestedName: name,
|
fileName: name,
|
||||||
confirmButtonText: L10n.of(context).saveFile,
|
type: filePickerFileType,
|
||||||
))
|
bytes: bytes,
|
||||||
?.path
|
);
|
||||||
: await FilePicker.platform.saveFile(
|
|
||||||
dialogTitle: L10n.of(context).saveFile,
|
|
||||||
fileName: name,
|
|
||||||
type: filePickerFileType,
|
|
||||||
bytes: bytes,
|
|
||||||
);
|
|
||||||
if (downloadPath == null) return;
|
if (downloadPath == null) return;
|
||||||
|
|
||||||
if (PlatformInfos.isDesktop) {
|
if (PlatformInfos.isDesktop) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue