feat: support double click to open task file (#516)

This commit is contained in:
Levi authored and GitHub committed 2024-05-02 13:22:57 +08:00
1 parent cea454b015
commit 54347f41b6
2 files changed
+29 -16

No files matched your search

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:open_filex/open_filex.dart';
import 'package:path/path.dart' as path;
import 'package:styled_widget/styled_widget.dart';
@@ -57,8 +58,12 @@ class BuildTaskListView extends GetView {
return task.status == Status.running;
}
bool isFolderTask() {
return task.meta.res?.name.isNotEmpty ?? false;
}
String buildExplorerUrl(Task task) {
if (task.meta.res!.name.isEmpty) {
if (!isFolderTask()) {
return path.join(Util.safeDir(task.meta.opts.path),
Util.safeDir(task.meta.res!.files[0].path), fileName(task.meta));
} 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() {
final list = <Widget>[];
if (isDone()) {
list.add(IconButton(
icon: const Icon(Icons.folder_open),
onPressed: () {
if (Util.isDesktop()) {
FileExplorer.openAndSelectFile(buildExplorerUrl(task));
} else {
Get.rootDelegate
.toNamed(Routes.TASK_FILES, parameters: {'id': task.id});
}
toTaskFilesView();
},
));
} else {
@@ -176,14 +185,23 @@ class BuildTaskListView extends GetView {
elevation: 4.0,
child: InkWell(
onTap: () {},
onDoubleTap: () {
if (isDone()) {
if (isFolderTask()) {
toTaskFilesView();
} else {
OpenFilex.open(buildExplorerUrl(task));
}
}
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text(fileName(task.meta)),
leading: (task.meta.res?.name.isNotEmpty ?? false
leading: isFolderTask()
? const Icon(FaIcons.folder)
: Icon(FaIcons.allIcons[findIcon(fileName(task.meta))]))),
: Icon(FaIcons.allIcons[findIcon(fileName(task.meta))])),
Row(
children: [
Expanded(