mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-11 00:10:29 -07:00
feat: Add download speed to progress bar
This commit is contained in:
parent
d22d340181
commit
5a5a4e4703
7 changed files with 95 additions and 68 deletions
|
|
@ -35,11 +35,19 @@ class SyncButton extends ConsumerWidget {
|
|||
),
|
||||
SizedBox.fromSize(
|
||||
size: const Size.fromRadius(10),
|
||||
child: CircularProgressIndicator(
|
||||
strokeCap: StrokeCap.round,
|
||||
strokeWidth: 1.5,
|
||||
color: status.color(context),
|
||||
value: status == TaskStatus.running ? progress.clamp(0.0, 1.0) : 0,
|
||||
child: TweenAnimationBuilder(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.easeInOut,
|
||||
tween: Tween<double>(
|
||||
begin: 0,
|
||||
end: progress,
|
||||
),
|
||||
builder: (context, value, child) => CircularProgressIndicator(
|
||||
strokeCap: StrokeCap.round,
|
||||
strokeWidth: 2,
|
||||
color: status.color(context),
|
||||
value: status == TaskStatus.running ? value.clamp(0.0, 1.0) : 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -56,25 +56,41 @@ class SyncProgressBar extends ConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final downloadStatus = task.status;
|
||||
final downloadProgress = task.progress;
|
||||
final downloadSpeed = task.downloadSpeed;
|
||||
final downloadTask = task.task;
|
||||
|
||||
if (!task.hasDownload) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(downloadStatus.name(context)),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Text(downloadStatus.name(context)),
|
||||
if (downloadSpeed.isNotEmpty) Opacity(opacity: 0.45, child: Text("($downloadSpeed)")),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Flexible(
|
||||
child: LinearProgressIndicator(
|
||||
minHeight: 8,
|
||||
value: downloadProgress,
|
||||
color: downloadStatus.color(context),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: TweenAnimationBuilder(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.easeInOut,
|
||||
tween: Tween<double>(
|
||||
begin: 0,
|
||||
end: downloadProgress,
|
||||
),
|
||||
builder: (context, value, child) => LinearProgressIndicator(
|
||||
minHeight: 8,
|
||||
value: value,
|
||||
color: downloadStatus.color(context),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
Opacity(opacity: 0.75, child: Text("${(downloadProgress * 100).toStringAsFixed(0)}%")),
|
||||
|
|
@ -85,14 +101,14 @@ class SyncProgressBar extends ConsumerWidget {
|
|||
icon: const Icon(IconsaxPlusBold.pause),
|
||||
),
|
||||
if (downloadStatus == TaskStatus.paused) ...[
|
||||
IconButton(
|
||||
onPressed: () => ref.read(syncProvider.notifier).deleteFullSyncFiles(item, downloadTask),
|
||||
icon: const Icon(IconsaxPlusBold.stop),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => ref.read(backgroundDownloaderProvider).resume(downloadTask),
|
||||
icon: const Icon(IconsaxPlusBold.play),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => ref.read(syncProvider.notifier).deleteFullSyncFiles(item, downloadTask),
|
||||
icon: const Icon(IconsaxPlusBold.stop),
|
||||
)
|
||||
],
|
||||
if (_cancellableStatuses.contains(downloadStatus)) ...[
|
||||
IconButton(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue