mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-16 21:33:41 +00:00
feat: adapt mobile extension list (#242)
This commit is contained in:
4 files changed
+42
-13
No files matched your search
@@ -21,6 +21,7 @@ import '../../../../api/model/install_extension.dart';
|
|||||||
import '../../../../api/model/switch_extension.dart';
|
import '../../../../api/model/switch_extension.dart';
|
||||||
import '../../../../util/util.dart';
|
import '../../../../util/util.dart';
|
||||||
import '../../../views/icon_button_loading.dart';
|
import '../../../views/icon_button_loading.dart';
|
||||||
|
import '../../../views/responsive_builder.dart';
|
||||||
import '../controllers/extension_controller.dart';
|
import '../controllers/extension_controller.dart';
|
||||||
|
|
||||||
class ExtensionView extends GetView<ExtensionController> {
|
class ExtensionView extends GetView<ExtensionController> {
|
||||||
@@ -96,7 +97,7 @@ class ExtensionView extends GetView<ExtensionController> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final extension = controller.extensions[index];
|
final extension = controller.extensions[index];
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 112,
|
height: ResponsiveBuilder.isNarrow(context) ? 152 : 112,
|
||||||
child: Card(
|
child: Card(
|
||||||
elevation: 4.0,
|
elevation: 4.0,
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -145,23 +146,32 @@ class ExtensionView extends GetView<ExtensionController> {
|
|||||||
title: Row(
|
title: Row(
|
||||||
children: () {
|
children: () {
|
||||||
final list = [
|
final list = [
|
||||||
Text(extension.title),
|
ResponsiveBuilder.isNarrow(context)
|
||||||
|
? Expanded(
|
||||||
|
child: Text(
|
||||||
|
extension.title,
|
||||||
|
overflow:
|
||||||
|
TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Text(extension.title),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Chip(
|
buildChip('v${extension.version}'),
|
||||||
label: Text('v${extension.version}'),
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
if (extension.devMode) {
|
if (extension.devMode) {
|
||||||
list.add(const SizedBox(width: 8));
|
list.add(const SizedBox(width: 8));
|
||||||
list.add(Chip(
|
list.add(buildChip('dev'));
|
||||||
label: Text('dev'.tr),
|
|
||||||
backgroundColor: Colors.redAccent,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}(),
|
}(),
|
||||||
),
|
),
|
||||||
subtitle: Text(extension.description),
|
subtitle: ResponsiveBuilder.isNarrow(context)
|
||||||
|
? Text(
|
||||||
|
extension.description,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
)
|
||||||
|
: Text(extension.description),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@@ -233,6 +243,13 @@ class ExtensionView extends GetView<ExtensionController> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildChip(String text) {
|
||||||
|
return Chip(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
label: Text(text, style: const TextStyle(fontSize: 12)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _showSettingDialog(Extension extension) async {
|
Future<void> _showSettingDialog(Extension extension) async {
|
||||||
final formKey = GlobalKey<FormBuilderState>();
|
final formKey = GlobalKey<FormBuilderState>();
|
||||||
final confrimController = RoundedLoadingButtonController();
|
final confrimController = RoundedLoadingButtonController();
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ class FileItem {
|
|||||||
FileItem(this.isDirectory, this.path, this.name, this.size);
|
FileItem(this.isDirectory, this.path, this.name, this.size);
|
||||||
|
|
||||||
String get fullPath => "${path == "/" ? path : "$path/"}$name";
|
String get fullPath => "${path == "/" ? path : "$path/"}$name";
|
||||||
|
|
||||||
|
String filePath(String optName) {
|
||||||
|
return optName.isEmpty
|
||||||
|
? fullPath
|
||||||
|
: "${path == "/" ? path : "$path/"}$optName";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TaskFilesController extends GetxController {
|
class TaskFilesController extends GetxController {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:open_file/open_file.dart';
|
import 'package:open_file/open_file.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
import '../../../../util/file_icon.dart';
|
import '../../../../util/file_icon.dart';
|
||||||
@@ -52,13 +53,17 @@ class TaskFilesView extends GetView<TaskFilesController> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final meta = controller.task.value!.meta;
|
final meta = controller.task.value!.meta;
|
||||||
final file = fileList[index];
|
final file = fileList[index];
|
||||||
final filePath = Util.safePathJoin(
|
final filePath = Util.safePathJoin([
|
||||||
[meta.opts.path, meta.res!.name, file.fullPath]);
|
meta.opts.path,
|
||||||
|
meta.res!.name,
|
||||||
|
file.filePath(meta.opts.name)
|
||||||
|
]);
|
||||||
|
final fileName = basename(filePath);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: file.isDirectory
|
leading: file.isDirectory
|
||||||
? const Icon(Icons.folder)
|
? const Icon(Icons.folder)
|
||||||
: Icon(FaIcons.allIcons[findIcon(file.name)]),
|
: Icon(FaIcons.allIcons[findIcon(file.name)]),
|
||||||
title: Text(fileList[index].name),
|
title: Text(fileName),
|
||||||
subtitle: file.isDirectory
|
subtitle: file.isDirectory
|
||||||
? Text('items'.trParams({
|
? Text('items'.trParams({
|
||||||
'count': controller
|
'count': controller
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class Util {
|
|||||||
|
|
||||||
static String safePathJoin(List<String> paths) {
|
static String safePathJoin(List<String> paths) {
|
||||||
return paths
|
return paths
|
||||||
|
.where((e) => e.isNotEmpty)
|
||||||
.map((e) => safeDir(e))
|
.map((e) => safeDir(e))
|
||||||
.join("/")
|
.join("/")
|
||||||
.replaceAll(RegExp(r'//'), "/");
|
.replaceAll(RegExp(r'//'), "/");
|
||||||
|
|||||||
Reference in new issue
Block a user