mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 09:54:19 +01:00
downloads router page bugfix
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
import 'package:background_downloader/background_downloader.dart';
|
import 'package:background_downloader/background_downloader.dart';
|
||||||
|
import 'package:bot_toast/bot_toast.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||||
import 'package:nowser/const/base.dart';
|
import 'package:nowser/const/base.dart';
|
||||||
import 'package:nowser/main.dart';
|
import 'package:nowser/main.dart';
|
||||||
import 'package:nowser/util/file_size_util.dart';
|
import 'package:nowser/util/file_size_util.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
import '../generated/l10n.dart';
|
||||||
|
|
||||||
class DownloadListItemComponent extends StatefulWidget {
|
class DownloadListItemComponent extends StatefulWidget {
|
||||||
// DownloadLog downloadLog;
|
// DownloadLog downloadLog;
|
||||||
TaskRecord taskRecord;
|
TaskRecord taskRecord;
|
||||||
@@ -21,9 +25,12 @@ class DownloadListItemComponent extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _DownloadListItemComponent extends State<DownloadListItemComponent> {
|
class _DownloadListItemComponent extends State<DownloadListItemComponent> {
|
||||||
|
late S s;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var themeData = Theme.of(context);
|
var themeData = Theme.of(context);
|
||||||
|
s = S.of(context);
|
||||||
|
|
||||||
var taskRecord = widget.taskRecord;
|
var taskRecord = widget.taskRecord;
|
||||||
|
|
||||||
@@ -69,11 +76,33 @@ class _DownloadListItemComponent extends State<DownloadListItemComponent> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget rightIcon = GestureDetector(
|
Widget rightIcon = PopupMenuButton(
|
||||||
onTap: () {},
|
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.more_horiz,
|
Icons.more_horiz,
|
||||||
),
|
),
|
||||||
|
itemBuilder: (context) {
|
||||||
|
return <PopupMenuEntry>[
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(s.Copy_Link),
|
||||||
|
onTap: () {
|
||||||
|
Clipboard.setData(
|
||||||
|
ClipboardData(text: widget.taskRecord.task.url));
|
||||||
|
BotToast.showText(text: s.Copy_success);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(
|
||||||
|
s.Delete,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
downloadProvider.deleteTasks([widget.taskRecord.taskId]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (taskRecord.status == TaskStatus.running) {
|
if (taskRecord.status == TaskStatus.running) {
|
||||||
rightIcon = GestureDetector(
|
rightIcon = GestureDetector(
|
||||||
@@ -83,7 +112,7 @@ class _DownloadListItemComponent extends State<DownloadListItemComponent> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
Icons.stop_circle_outlined,
|
Icons.pause_circle_outline,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (taskRecord.status == TaskStatus.paused) {
|
} else if (taskRecord.status == TaskStatus.paused) {
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class _WebViewComponent extends State<WebViewComponent>
|
|||||||
},
|
},
|
||||||
onDownloadStartRequest: (InAppWebViewController controller,
|
onDownloadStartRequest: (InAppWebViewController controller,
|
||||||
DownloadStartRequest downloadStartRequest) {
|
DownloadStartRequest downloadStartRequest) {
|
||||||
String downloadUrl = downloadStartRequest.url.path;
|
String downloadUrl = downloadStartRequest.url.toString();
|
||||||
DownloadTaskDialog.show(context, downloadUrl);
|
DownloadTaskDialog.show(context, downloadUrl);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"Decrypt_zap_event": MessageLookupByLibrary.simpleMessage(
|
"Decrypt_zap_event": MessageLookupByLibrary.simpleMessage(
|
||||||
"Decrypt zap event",
|
"Decrypt zap event",
|
||||||
),
|
),
|
||||||
|
"Delete": MessageLookupByLibrary.simpleMessage("Delete"),
|
||||||
"Desktop": MessageLookupByLibrary.simpleMessage("Desktop"),
|
"Desktop": MessageLookupByLibrary.simpleMessage("Desktop"),
|
||||||
"Download_image": MessageLookupByLibrary.simpleMessage("Download image"),
|
"Download_image": MessageLookupByLibrary.simpleMessage("Download image"),
|
||||||
"Downloads": MessageLookupByLibrary.simpleMessage("Downloads"),
|
"Downloads": MessageLookupByLibrary.simpleMessage("Downloads"),
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||||||
"Decrypt04_name": MessageLookupByLibrary.simpleMessage("解密 (NIP-04)"),
|
"Decrypt04_name": MessageLookupByLibrary.simpleMessage("解密 (NIP-04)"),
|
||||||
"Decrypt44_name": MessageLookupByLibrary.simpleMessage("解密 (NIP-44)"),
|
"Decrypt44_name": MessageLookupByLibrary.simpleMessage("解密 (NIP-44)"),
|
||||||
"Decrypt_zap_event": MessageLookupByLibrary.simpleMessage("解密私密Zap"),
|
"Decrypt_zap_event": MessageLookupByLibrary.simpleMessage("解密私密Zap"),
|
||||||
|
"Delete": MessageLookupByLibrary.simpleMessage("删除"),
|
||||||
"Desktop": MessageLookupByLibrary.simpleMessage("桌面"),
|
"Desktop": MessageLookupByLibrary.simpleMessage("桌面"),
|
||||||
"Download_image": MessageLookupByLibrary.simpleMessage("下载图片"),
|
"Download_image": MessageLookupByLibrary.simpleMessage("下载图片"),
|
||||||
"Downloads": MessageLookupByLibrary.simpleMessage("下载"),
|
"Downloads": MessageLookupByLibrary.simpleMessage("下载"),
|
||||||
|
|||||||
@@ -724,6 +724,11 @@ class S {
|
|||||||
String get Login_fail {
|
String get Login_fail {
|
||||||
return Intl.message('Login_fail', name: 'Login_fail', desc: '', args: []);
|
return Intl.message('Login_fail', name: 'Login_fail', desc: '', args: []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `Delete`
|
||||||
|
String get Delete {
|
||||||
|
return Intl.message('Delete', name: 'Delete', desc: '', args: []);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
||||||
|
|||||||
@@ -94,5 +94,6 @@
|
|||||||
"Download_image": "Download image",
|
"Download_image": "Download image",
|
||||||
"or": "or",
|
"or": "or",
|
||||||
"Login_with_Nesigner": "Login with Nesigner",
|
"Login_with_Nesigner": "Login with Nesigner",
|
||||||
"Login_fail": "Login_fail"
|
"Login_fail": "Login_fail",
|
||||||
|
"Delete": "Delete"
|
||||||
}
|
}
|
||||||
@@ -94,5 +94,6 @@
|
|||||||
"Download_image": "下载图片",
|
"Download_image": "下载图片",
|
||||||
"or": "或者",
|
"or": "或者",
|
||||||
"Login_with_Nesigner": "使用 Nesigner 登录",
|
"Login_with_Nesigner": "使用 Nesigner 登录",
|
||||||
"Login_fail": "登录失败"
|
"Login_fail": "登录失败",
|
||||||
|
"Delete": "删除"
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ class DownloadProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
var downloadDirPath = downloadDir.absolute.path;
|
var downloadDirPath = downloadDir.absolute.path;
|
||||||
|
|
||||||
print("url $url fileName $fileName downloadDirPath $downloadDirPath");
|
// print("url $url fileName $fileName downloadDirPath $downloadDirPath");
|
||||||
|
|
||||||
final task = DownloadTask(
|
final task = DownloadTask(
|
||||||
url: url,
|
url: url,
|
||||||
@@ -56,7 +56,7 @@ class DownloadProvider extends ChangeNotifier {
|
|||||||
allowPause: true,
|
allowPause: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
var downloadResult = await fileDownloader.download(
|
fileDownloader.download(
|
||||||
task,
|
task,
|
||||||
onProgress: (progress) {
|
onProgress: (progress) {
|
||||||
print('Progress: ${progress * 100}%');
|
print('Progress: ${progress * 100}%');
|
||||||
@@ -64,11 +64,12 @@ class DownloadProvider extends ChangeNotifier {
|
|||||||
},
|
},
|
||||||
onStatus: (status) {
|
onStatus: (status) {
|
||||||
print('Status: $status');
|
print('Status: $status');
|
||||||
|
if (status == TaskStatus.running) {
|
||||||
|
reloadData();
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await reloadData();
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user