TF-654 Add DownloadController to manage list task download

This commit is contained in:
dab246
2022-08-06 19:49:18 +07:00
committed by Dat H. Pham
parent 06fc28a5fe
commit 88ca9dbc9a
3 changed files with 84 additions and 0 deletions
@@ -0,0 +1,41 @@
import 'package:equatable/equatable.dart';
import 'package:model/download/download_task_id.dart';
import 'package:model/email/attachment.dart';
class DownloadTaskState with EquatableMixin {
final DownloadTaskId taskId;
final Attachment attachment;
final double progress;
final int downloaded;
final int total;
DownloadTaskState({
required this.taskId,
required this.attachment,
this.progress = 0,
this.downloaded = 0,
this.total = 0
});
DownloadTaskState copyWith({
DownloadTaskId? taskId,
Attachment? attachment,
double? progress,
int? downloaded,
int? total
}) {
return DownloadTaskState(
taskId: taskId ?? this.taskId,
attachment: attachment ?? this.attachment,
progress: progress ?? this.progress,
downloaded: downloaded ?? this.downloaded,
total: total ?? this.total
);
}
double get percentDownloading => progress / 100;
@override
List<Object?> get props => [taskId, attachment, progress, downloaded, total];
}