High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
import 'package:background_downloader/background_downloader.dart';
import 'package:flutter/material.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:immich_mobile/generated/translations.g.dart';
class DownloadTaskTile extends StatelessWidget {
final double progress;
final String fileName;
final TaskStatus status;
final VoidCallback onCancelDownload;
const DownloadTaskTile({
super.key,
required this.progress,
required this.fileName,
required this.status,
required this.onCancelDownload,
});
@override
Widget build(BuildContext context) {
final isComplete = status == TaskStatus.complete;
final progressPercent = (progress * 100).round();
String getStatusText() => switch (status) {
TaskStatus.running => context.t.downloading,
TaskStatus.complete => context.t.download_complete,
TaskStatus.failed => context.t.download_failed,
TaskStatus.canceled => context.t.download_canceled,
TaskStatus.paused => context.t.download_paused,
TaskStatus.enqueued => context.t.download_enqueue,
TaskStatus.notFound => context.t.download_notfound,
TaskStatus.waitingToRetry => context.t.download_waiting_to_retry,
};
return SizedBox(
key: const ValueKey('download_progress'),
width: context.width - 32,
child: Card(
clipBehavior: Clip.antiAlias,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
child: ListTile(
minVerticalPadding: 18,
leading: const Icon(Icons.video_file_outlined),
title: Text(getStatusText(), style: context.textTheme.labelLarge),
trailing: IconButton(
icon: Icon(
isComplete ? Icons.download_done : Icons.close,
color: isComplete ? context.colorScheme.primary : context.colorScheme.onError,
),
onPressed: onCancelDownload,
style: isComplete
? null
: ElevatedButton.styleFrom(backgroundColor: context.colorScheme.error.withAlpha(200)),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(fileName, style: context.textTheme.labelMedium),
Row(
children: [
Expanded(
child: LinearProgressIndicator(
minHeight: 8.0,
value: progress,
borderRadius: const BorderRadius.all(Radius.circular(10.0)),
),
),
const SizedBox(width: 8),
Text('$progressPercent%', style: context.textTheme.labelSmall),
],
),
],
),
),
),
);
}
}