fix: downloader display

This commit is contained in:
xkeyC
2025-12-05 18:03:56 +08:00
parent 53ffab783f
commit 3f5aaaecd9
13 changed files with 1047 additions and 966 deletions

View File

@@ -58,6 +58,7 @@ class HomeDownloaderUI extends HookConsumerWidget {
final statusStr = model.getStatusString(task.status);
final isActive = task.status == DownloadTaskStatus.live;
final isPaused = task.status == DownloadTaskStatus.paused;
final isChecking = task.status == DownloadTaskStatus.checking;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -110,6 +111,8 @@ class HomeDownloaderUI extends HookConsumerWidget {
Text(
S.current.downloader_info_downloading((task.progress * 100).toStringAsFixed(2)),
)
else if (isChecking)
Text(model.getCheckingProgressString(task))
else
Text(S.current.downloader_info_status(model.statusMap[statusStr] ?? "Unknown")),
const SizedBox(width: 24),
@@ -126,9 +129,17 @@ class HomeDownloaderUI extends HookConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(S.current.downloader_info_uploaded(FileSize.getSize(task.uploadedBytes.toInt()))),
Text(
S.current.downloader_info_downloaded(FileSize.getSize(task.downloadedBytes.toInt())),
),
// 校验状态下downloadedBytes 显示为校验进度
if (isChecking)
Text(
S.current.downloader_info_checked(FileSize.getSize(task.downloadedBytes.toInt())),
)
else
Text(
S.current.downloader_info_downloaded(
FileSize.getSize(task.downloadedBytes.toInt()),
),
),
],
),
const SizedBox(width: 18),

View File

@@ -142,6 +142,12 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
}
}
/// 获取校验进度字符串(百分比)
String getCheckingProgressString(DownloadTaskInfo task) {
final percent = (task.progress * 100).toStringAsFixed(1);
return S.current.downloader_info_checking_progress(percent);
}
Future<void> resumeTask(int taskId) async {
final downloadManager = ref.read(downloadManagerProvider.notifier);
await downloadManager.resumeTask(taskId);