feat(ui): add download percentage and ETA display (#1238)

This commit is contained in:
Locon213 authored and GitHub committed 2026-01-14 09:47:45 +08:00
1 parent a9eee26be7
commit f86a379f93
2 files changed
+66 -5

No files matched your search

@@ -214,6 +214,43 @@ class BuildTaskListView extends GetView {
(total > 0 ? " / ${Util.fmtByte(total)}" : "");
}
// Get percentage text, e.g. " (50.5%)"
String getPercentText() {
final total = task.meta.res?.size ?? 0;
if (total <= 0 || isDone()) return "";
double p = getProgress();
return "(${(p * 100).toStringAsFixed(1)}%)";
}
// Get ETA text, e.g. "00:05:30"
String getEtaText() {
if (isDone()) return "";
final total = task.meta.res?.size ?? 0;
final downloaded = task.progress.downloaded;
final speed = task.progress.speed;
// If speed is 0 or file is downloaded, don't show time
if (total <= 0 || speed <= 0 || downloaded >= total) {
return "";
}
final remainingBytes = total - downloaded;
final remainingSeconds = remainingBytes ~/ speed;
// If time is too long (e.g. > 1 day), return > 1d
if (remainingSeconds > 86400) return "> 1d";
Duration duration = Duration(seconds: remainingSeconds);
String twoDigits(int n) => n.toString().padLeft(2, "0");
if (duration.inHours > 0) {
return "${twoDigits(duration.inHours)}:${twoDigits(duration.inMinutes.remainder(60))}:${twoDigits(duration.inSeconds.remainder(60))}";
} else {
return "${twoDigits(duration.inMinutes.remainder(60))}:${twoDigits(duration.inSeconds.remainder(60))}";
}
}
final taskController = Get.find<TaskController>();
final taskListController = taskController.tabIndex.value == 0
? Get.find<TaskDownloadingController>()
@@ -308,18 +345,41 @@ class BuildTaskListView extends GetView {
)),
Row(
children: [
// Left side: Progress text + Percentage
Expanded(
flex: 1,
child: Text(
getProgressText(),
style: Get.textTheme.bodyLarge
?.copyWith(color: Get.theme.disabledColor),
child: Row(
children: [
Text(
getProgressText(),
style: Get.textTheme.bodyLarge
?.copyWith(color: Get.theme.disabledColor),
),
const SizedBox(width: 8),
Text(
getPercentText(),
style: Get.textTheme.bodyLarge
?.copyWith(color: Get.theme.disabledColor),
),
],
).padding(left: 18)),
// Right side: ETA + Speed + Actions
Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
getEtaText(),
style: Get.textTheme.titleSmall,
),
Text(
" | ",
style: Get.textTheme.titleSmall?.copyWith(
color: Get.theme.disabledColor,
fontWeight: FontWeight.w300,
),
).padding(horizontal: 4),
Text("${Util.fmtByte(task.progress.speed)} / s",
style: Get.textTheme.titleSmall),
...buildActions()
+2 -1
View File
@@ -38,7 +38,8 @@ const frFR = {
'useServerCtime':
'Utiliser l\'heure du serveur pour la création de fichier',
'maxRunning': 'Tâches en cours maximum',
'autoStartTasks': 'Démarrer automatiquement les tâches incomplètes au lancement',
'autoStartTasks':
'Démarrer automatiquement les tâches incomplètes au lancement',
'items': '@count éléments',
'subscribeTracker': 'S\'abonner au tracker',
'subscribeFail':