TF-654 Update datasource/repository for download attachment on web

This commit is contained in:
dab246
2022-08-06 19:51:25 +07:00
committed by Dat H. Pham
parent 88ca9dbc9a
commit 6ad10cad4a
6 changed files with 121 additions and 21 deletions
@@ -1,18 +1,64 @@
import 'dart:typed_data';
import 'package:core/core.dart';
import 'package:model/model.dart';
class StartDownloadAttachmentForWeb extends UIState {
final DownloadTaskId taskId;
final Attachment attachment;
StartDownloadAttachmentForWeb(this.taskId, this.attachment);
@override
List<Object> get props => [taskId, attachment];
}
class DownloadingAttachmentForWeb extends UIState {
final DownloadTaskId taskId;
final Attachment attachment;
final double progress;
final int downloaded;
final int total;
DownloadingAttachmentForWeb(
this.taskId,
this.attachment,
this.progress,
this.downloaded,
this.total
);
@override
List<Object> get props => [
taskId,
attachment,
progress,
downloaded,
total
];
}
class DownloadAttachmentForWebSuccess extends UIState {
DownloadAttachmentForWebSuccess();
final DownloadTaskId taskId;
final Attachment attachment;
final Uint8List bytes;
DownloadAttachmentForWebSuccess(this.taskId, this.attachment, this.bytes);
@override
List<Object> get props => [];
List<Object> get props => [taskId, attachment, bytes];
}
class DownloadAttachmentForWebFailure extends FeatureFailure {
final DownloadTaskId taskId;
final dynamic exception;
DownloadAttachmentForWebFailure(this.exception);
DownloadAttachmentForWebFailure(this.taskId, this.exception);
@override
List<Object> get props => [exception];
List<Object> get props => [taskId, exception];
}