mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 04:43:41 +00:00
feat: support double click to open task file (#516)
This commit is contained in:
2 files changed
+29
-16
No files matched your search
@@ -89,7 +89,7 @@ class TaskFilesView extends GetView<TaskFilesController> {
|
|||||||
return [
|
return [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon:
|
icon:
|
||||||
const Icon(Icons.play_circle),
|
const Icon(Icons.open_in_new),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
launchUrl(Uri.parse(accessUrl),
|
launchUrl(Uri.parse(accessUrl),
|
||||||
webOnlyWindowName:
|
webOnlyWindowName:
|
||||||
@@ -106,12 +106,7 @@ class TaskFilesView extends GetView<TaskFilesController> {
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.play_circle),
|
icon: const Icon(Icons.play_circle),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
print(filePath);
|
await OpenFilex.open(filePath);
|
||||||
try {
|
|
||||||
await OpenFilex.open(filePath);
|
|
||||||
} catch (e) {
|
|
||||||
print(e);
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.share),
|
icon: const Icon(Icons.share),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:open_filex/open_filex.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
@@ -57,8 +58,12 @@ class BuildTaskListView extends GetView {
|
|||||||
return task.status == Status.running;
|
return task.status == Status.running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isFolderTask() {
|
||||||
|
return task.meta.res?.name.isNotEmpty ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
String buildExplorerUrl(Task task) {
|
String buildExplorerUrl(Task task) {
|
||||||
if (task.meta.res!.name.isEmpty) {
|
if (!isFolderTask()) {
|
||||||
return path.join(Util.safeDir(task.meta.opts.path),
|
return path.join(Util.safeDir(task.meta.opts.path),
|
||||||
Util.safeDir(task.meta.res!.files[0].path), fileName(task.meta));
|
Util.safeDir(task.meta.res!.files[0].path), fileName(task.meta));
|
||||||
} else {
|
} else {
|
||||||
@@ -107,18 +112,22 @@ class BuildTaskListView extends GetView {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toTaskFilesView() {
|
||||||
|
if (Util.isDesktop()) {
|
||||||
|
FileExplorer.openAndSelectFile(buildExplorerUrl(task));
|
||||||
|
} else {
|
||||||
|
Get.rootDelegate
|
||||||
|
.toNamed(Routes.TASK_FILES, parameters: {'id': task.id});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Widget> buildActions() {
|
List<Widget> buildActions() {
|
||||||
final list = <Widget>[];
|
final list = <Widget>[];
|
||||||
if (isDone()) {
|
if (isDone()) {
|
||||||
list.add(IconButton(
|
list.add(IconButton(
|
||||||
icon: const Icon(Icons.folder_open),
|
icon: const Icon(Icons.folder_open),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (Util.isDesktop()) {
|
toTaskFilesView();
|
||||||
FileExplorer.openAndSelectFile(buildExplorerUrl(task));
|
|
||||||
} else {
|
|
||||||
Get.rootDelegate
|
|
||||||
.toNamed(Routes.TASK_FILES, parameters: {'id': task.id});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
@@ -176,14 +185,23 @@ class BuildTaskListView extends GetView {
|
|||||||
elevation: 4.0,
|
elevation: 4.0,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
|
onDoubleTap: () {
|
||||||
|
if (isDone()) {
|
||||||
|
if (isFolderTask()) {
|
||||||
|
toTaskFilesView();
|
||||||
|
} else {
|
||||||
|
OpenFilex.open(buildExplorerUrl(task));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(fileName(task.meta)),
|
title: Text(fileName(task.meta)),
|
||||||
leading: (task.meta.res?.name.isNotEmpty ?? false
|
leading: isFolderTask()
|
||||||
? const Icon(FaIcons.folder)
|
? const Icon(FaIcons.folder)
|
||||||
: Icon(FaIcons.allIcons[findIcon(fileName(task.meta))]))),
|
: Icon(FaIcons.allIcons[findIcon(fileName(task.meta))])),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|||||||
Reference in new issue
Block a user