mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 05:43:41 +00:00
Merge branch 'main' into fix/create-task-panel-mobile-ui
This commit is contained in:
36 files changed
+1884
-263
No files matched your search
@@ -95,11 +95,21 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
super.initState();
|
||||
_urlController.addListener(_handleUrlChanged);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
final task = widget.initialTask ?? ref.read(pendingCreateTaskProvider);
|
||||
_applyInitialTask(task);
|
||||
if (widget.initialTask == null) {
|
||||
ref.read(pendingCreateTaskProvider.notifier).clear();
|
||||
}
|
||||
if (widget.windowController == null && widget.initialTask == null) {
|
||||
// Navigating to /create again reuses this page, so consume subsequent
|
||||
// browser/share requests as well as the initial pending task.
|
||||
ref.listenManual(pendingCreateTaskProvider, (_, next) {
|
||||
if (next == null) return;
|
||||
ref.read(pendingCreateTaskProvider.notifier).clear();
|
||||
_applyInitialTask(next);
|
||||
});
|
||||
}
|
||||
if (task == null || _urlController.text.trim().isEmpty) {
|
||||
unawaited(_loadClipboardUrl());
|
||||
}
|
||||
@@ -181,6 +191,13 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
final opts = task.opts;
|
||||
setState(() {
|
||||
if (req?.url.isNotEmpty == true) {
|
||||
_fileDataUri = '';
|
||||
_renameController.clear();
|
||||
_httpMethod = 'GET';
|
||||
_httpBody = '';
|
||||
_replaceHttpHeaders(const {'User-Agent': '', 'Cookie': '', 'Referer': ''});
|
||||
_trackersController.clear();
|
||||
_protocolTab = 0;
|
||||
_urlController.text = req!.url;
|
||||
_initialRawUrl = req.rawUrl;
|
||||
_initialLabels = req.labels == null ? null : Map<String, String>.of(req.labels!);
|
||||
@@ -754,15 +771,10 @@ class _CreateTaskWindowPageState extends ConsumerState<CreateTaskWindowPage> {
|
||||
}
|
||||
|
||||
Future<void> _pickTorrentFile() async {
|
||||
final result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: const ['torrent'],
|
||||
withData: kIsWeb,
|
||||
);
|
||||
final file = result?.files.single;
|
||||
final file = await FilePicker.pickFile(type: FileType.custom, allowedExtensions: const ['torrent']);
|
||||
if (file == null) return;
|
||||
|
||||
await _applyTorrentFile(name: file.name, filePath: file.path, bytes: file.bytes);
|
||||
await _applyTorrentFile(name: file.name, filePath: file.path, readBytes: file.readAsBytes);
|
||||
}
|
||||
|
||||
Future<void> _handleDroppedTorrent(DropDoneDetails details) async {
|
||||
|
||||
@@ -109,7 +109,7 @@ class _TaskFileManagerViewState extends State<TaskFileManagerView> {
|
||||
try {
|
||||
final renderBox = actionContext.findRenderObject();
|
||||
final origin = renderBox is RenderBox ? renderBox.localToGlobal(Offset.zero) & renderBox.size : null;
|
||||
await Share.shareXFiles([XFile(_localPath(entry))], sharePositionOrigin: origin);
|
||||
await SharePlus.instance.share(ShareParams(files: [XFile(_localPath(entry))], sharePositionOrigin: origin));
|
||||
} catch (error) {
|
||||
if (mounted) showAppToast(context, error.toString(), type: AppToastType.error);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user