Compare commits
2 Commits
b40afde00f
...
b8d24876c8
| Author | SHA1 | Date | |
|---|---|---|---|
|
b8d24876c8
|
|||
|
0493661f9a
|
@@ -59,6 +59,8 @@ void main() async {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await EasyLocalization.ensureInitialized();
|
await EasyLocalization.ensureInitialized();
|
||||||
|
// Disable logs
|
||||||
|
EasyLocalization.logger.enableBuildModes = [];
|
||||||
|
|
||||||
if (kIsWeb || !Platform.isLinux) {
|
if (kIsWeb || !Platform.isLinux) {
|
||||||
await Firebase.initializeApp(
|
await Firebase.initializeApp(
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
|
|
||||||
part 'upload_task.freezed.dart';
|
part 'drive_task.freezed.dart';
|
||||||
part 'upload_task.g.dart';
|
part 'drive_task.g.dart';
|
||||||
|
|
||||||
enum UploadTaskStatus {
|
enum DriveTaskStatus {
|
||||||
pending,
|
pending,
|
||||||
inProgress,
|
inProgress,
|
||||||
paused,
|
paused,
|
||||||
@@ -15,10 +15,10 @@ enum UploadTaskStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
sealed class UploadTask with _$UploadTask {
|
sealed class DriveTask with _$DriveTask {
|
||||||
const UploadTask._();
|
const DriveTask._();
|
||||||
|
|
||||||
const factory UploadTask({
|
const factory DriveTask({
|
||||||
required String id,
|
required String id,
|
||||||
required String taskId,
|
required String taskId,
|
||||||
required String fileName,
|
required String fileName,
|
||||||
@@ -27,9 +27,10 @@ sealed class UploadTask with _$UploadTask {
|
|||||||
required int uploadedBytes,
|
required int uploadedBytes,
|
||||||
required int totalChunks,
|
required int totalChunks,
|
||||||
required int uploadedChunks,
|
required int uploadedChunks,
|
||||||
required UploadTaskStatus status,
|
required DriveTaskStatus status,
|
||||||
required DateTime createdAt,
|
required DateTime createdAt,
|
||||||
required DateTime updatedAt,
|
required DateTime updatedAt,
|
||||||
|
required String type, // Task type (e.g., 'FileUpload')
|
||||||
double? transmissionProgress, // Local file upload progress (0.0-1.0)
|
double? transmissionProgress, // Local file upload progress (0.0-1.0)
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
SnCloudFile? result,
|
SnCloudFile? result,
|
||||||
@@ -37,10 +38,10 @@ sealed class UploadTask with _$UploadTask {
|
|||||||
String? bundleId,
|
String? bundleId,
|
||||||
String? encryptPassword,
|
String? encryptPassword,
|
||||||
String? expiredAt,
|
String? expiredAt,
|
||||||
}) = _UploadTask;
|
}) = _DriveTask;
|
||||||
|
|
||||||
factory UploadTask.fromJson(Map<String, dynamic> json) =>
|
factory DriveTask.fromJson(Map<String, dynamic> json) =>
|
||||||
_$UploadTaskFromJson(json);
|
_$DriveTaskFromJson(json);
|
||||||
|
|
||||||
double get progress => totalChunks > 0 ? uploadedChunks / totalChunks : 0.0;
|
double get progress => totalChunks > 0 ? uploadedChunks / totalChunks : 0.0;
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
part of 'upload_task.dart';
|
part of 'drive_task.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FreezedGenerator
|
// FreezedGenerator
|
||||||
@@ -13,43 +13,44 @@ part of 'upload_task.dart';
|
|||||||
T _$identity<T>(T value) => value;
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$UploadTask {
|
mixin _$DriveTask {
|
||||||
|
|
||||||
String get id; String get taskId; String get fileName; String get contentType; int get fileSize; int get uploadedBytes; int get totalChunks; int get uploadedChunks; UploadTaskStatus get status; DateTime get createdAt; DateTime get updatedAt; double? get transmissionProgress;// Local file upload progress (0.0-1.0)
|
String get id; String get taskId; String get fileName; String get contentType; int get fileSize; int get uploadedBytes; int get totalChunks; int get uploadedChunks; DriveTaskStatus get status; DateTime get createdAt; DateTime get updatedAt; String get type;// Task type (e.g., 'FileUpload')
|
||||||
|
double? get transmissionProgress;// Local file upload progress (0.0-1.0)
|
||||||
String? get errorMessage; SnCloudFile? get result; String? get poolId; String? get bundleId; String? get encryptPassword; String? get expiredAt;
|
String? get errorMessage; SnCloudFile? get result; String? get poolId; String? get bundleId; String? get encryptPassword; String? get expiredAt;
|
||||||
/// Create a copy of UploadTask
|
/// Create a copy of DriveTask
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
$UploadTaskCopyWith<UploadTask> get copyWith => _$UploadTaskCopyWithImpl<UploadTask>(this as UploadTask, _$identity);
|
$DriveTaskCopyWith<DriveTask> get copyWith => _$DriveTaskCopyWithImpl<DriveTask>(this as DriveTask, _$identity);
|
||||||
|
|
||||||
/// Serializes this UploadTask to a JSON map.
|
/// Serializes this DriveTask to a JSON map.
|
||||||
Map<String, dynamic> toJson();
|
Map<String, dynamic> toJson();
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UploadTask&&(identical(other.id, id) || other.id == id)&&(identical(other.taskId, taskId) || other.taskId == taskId)&&(identical(other.fileName, fileName) || other.fileName == fileName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.fileSize, fileSize) || other.fileSize == fileSize)&&(identical(other.uploadedBytes, uploadedBytes) || other.uploadedBytes == uploadedBytes)&&(identical(other.totalChunks, totalChunks) || other.totalChunks == totalChunks)&&(identical(other.uploadedChunks, uploadedChunks) || other.uploadedChunks == uploadedChunks)&&(identical(other.status, status) || other.status == status)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.transmissionProgress, transmissionProgress) || other.transmissionProgress == transmissionProgress)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.result, result) || other.result == result)&&(identical(other.poolId, poolId) || other.poolId == poolId)&&(identical(other.bundleId, bundleId) || other.bundleId == bundleId)&&(identical(other.encryptPassword, encryptPassword) || other.encryptPassword == encryptPassword)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is DriveTask&&(identical(other.id, id) || other.id == id)&&(identical(other.taskId, taskId) || other.taskId == taskId)&&(identical(other.fileName, fileName) || other.fileName == fileName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.fileSize, fileSize) || other.fileSize == fileSize)&&(identical(other.uploadedBytes, uploadedBytes) || other.uploadedBytes == uploadedBytes)&&(identical(other.totalChunks, totalChunks) || other.totalChunks == totalChunks)&&(identical(other.uploadedChunks, uploadedChunks) || other.uploadedChunks == uploadedChunks)&&(identical(other.status, status) || other.status == status)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.type, type) || other.type == type)&&(identical(other.transmissionProgress, transmissionProgress) || other.transmissionProgress == transmissionProgress)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.result, result) || other.result == result)&&(identical(other.poolId, poolId) || other.poolId == poolId)&&(identical(other.bundleId, bundleId) || other.bundleId == bundleId)&&(identical(other.encryptPassword, encryptPassword) || other.encryptPassword == encryptPassword)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,taskId,fileName,contentType,fileSize,uploadedBytes,totalChunks,uploadedChunks,status,createdAt,updatedAt,transmissionProgress,errorMessage,result,poolId,bundleId,encryptPassword,expiredAt);
|
int get hashCode => Object.hashAll([runtimeType,id,taskId,fileName,contentType,fileSize,uploadedBytes,totalChunks,uploadedChunks,status,createdAt,updatedAt,type,transmissionProgress,errorMessage,result,poolId,bundleId,encryptPassword,expiredAt]);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UploadTask(id: $id, taskId: $taskId, fileName: $fileName, contentType: $contentType, fileSize: $fileSize, uploadedBytes: $uploadedBytes, totalChunks: $totalChunks, uploadedChunks: $uploadedChunks, status: $status, createdAt: $createdAt, updatedAt: $updatedAt, transmissionProgress: $transmissionProgress, errorMessage: $errorMessage, result: $result, poolId: $poolId, bundleId: $bundleId, encryptPassword: $encryptPassword, expiredAt: $expiredAt)';
|
return 'DriveTask(id: $id, taskId: $taskId, fileName: $fileName, contentType: $contentType, fileSize: $fileSize, uploadedBytes: $uploadedBytes, totalChunks: $totalChunks, uploadedChunks: $uploadedChunks, status: $status, createdAt: $createdAt, updatedAt: $updatedAt, type: $type, transmissionProgress: $transmissionProgress, errorMessage: $errorMessage, result: $result, poolId: $poolId, bundleId: $bundleId, encryptPassword: $encryptPassword, expiredAt: $expiredAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract mixin class $UploadTaskCopyWith<$Res> {
|
abstract mixin class $DriveTaskCopyWith<$Res> {
|
||||||
factory $UploadTaskCopyWith(UploadTask value, $Res Function(UploadTask) _then) = _$UploadTaskCopyWithImpl;
|
factory $DriveTaskCopyWith(DriveTask value, $Res Function(DriveTask) _then) = _$DriveTaskCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, UploadTaskStatus status, DateTime createdAt, DateTime updatedAt, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt
|
String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, DriveTaskStatus status, DateTime createdAt, DateTime updatedAt, String type, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -57,16 +58,16 @@ $SnCloudFileCopyWith<$Res>? get result;
|
|||||||
|
|
||||||
}
|
}
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$UploadTaskCopyWithImpl<$Res>
|
class _$DriveTaskCopyWithImpl<$Res>
|
||||||
implements $UploadTaskCopyWith<$Res> {
|
implements $DriveTaskCopyWith<$Res> {
|
||||||
_$UploadTaskCopyWithImpl(this._self, this._then);
|
_$DriveTaskCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
final UploadTask _self;
|
final DriveTask _self;
|
||||||
final $Res Function(UploadTask) _then;
|
final $Res Function(DriveTask) _then;
|
||||||
|
|
||||||
/// Create a copy of UploadTask
|
/// Create a copy of DriveTask
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? taskId = null,Object? fileName = null,Object? contentType = null,Object? fileSize = null,Object? uploadedBytes = null,Object? totalChunks = null,Object? uploadedChunks = null,Object? status = null,Object? createdAt = null,Object? updatedAt = null,Object? transmissionProgress = freezed,Object? errorMessage = freezed,Object? result = freezed,Object? poolId = freezed,Object? bundleId = freezed,Object? encryptPassword = freezed,Object? expiredAt = freezed,}) {
|
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? taskId = null,Object? fileName = null,Object? contentType = null,Object? fileSize = null,Object? uploadedBytes = null,Object? totalChunks = null,Object? uploadedChunks = null,Object? status = null,Object? createdAt = null,Object? updatedAt = null,Object? type = null,Object? transmissionProgress = freezed,Object? errorMessage = freezed,Object? result = freezed,Object? poolId = freezed,Object? bundleId = freezed,Object? encryptPassword = freezed,Object? expiredAt = freezed,}) {
|
||||||
return _then(_self.copyWith(
|
return _then(_self.copyWith(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,taskId: null == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable
|
as String,taskId: null == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -77,9 +78,10 @@ as int,uploadedBytes: null == uploadedBytes ? _self.uploadedBytes : uploadedByte
|
|||||||
as int,totalChunks: null == totalChunks ? _self.totalChunks : totalChunks // ignore: cast_nullable_to_non_nullable
|
as int,totalChunks: null == totalChunks ? _self.totalChunks : totalChunks // ignore: cast_nullable_to_non_nullable
|
||||||
as int,uploadedChunks: null == uploadedChunks ? _self.uploadedChunks : uploadedChunks // ignore: cast_nullable_to_non_nullable
|
as int,uploadedChunks: null == uploadedChunks ? _self.uploadedChunks : uploadedChunks // ignore: cast_nullable_to_non_nullable
|
||||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||||
as UploadTaskStatus,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
as DriveTaskStatus,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,transmissionProgress: freezed == transmissionProgress ? _self.transmissionProgress : transmissionProgress // ignore: cast_nullable_to_non_nullable
|
as DateTime,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,transmissionProgress: freezed == transmissionProgress ? _self.transmissionProgress : transmissionProgress // ignore: cast_nullable_to_non_nullable
|
||||||
as double?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
as double?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
||||||
as SnCloudFile?,poolId: freezed == poolId ? _self.poolId : poolId // ignore: cast_nullable_to_non_nullable
|
as SnCloudFile?,poolId: freezed == poolId ? _self.poolId : poolId // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -89,7 +91,7 @@ as String?,expiredAt: freezed == expiredAt ? _self.expiredAt : expiredAt // igno
|
|||||||
as String?,
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
/// Create a copy of UploadTask
|
/// Create a copy of DriveTask
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
@override
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@@ -105,8 +107,8 @@ $SnCloudFileCopyWith<$Res>? get result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Adds pattern-matching-related methods to [UploadTask].
|
/// Adds pattern-matching-related methods to [DriveTask].
|
||||||
extension UploadTaskPatterns on UploadTask {
|
extension DriveTaskPatterns on DriveTask {
|
||||||
/// A variant of `map` that fallback to returning `orElse`.
|
/// A variant of `map` that fallback to returning `orElse`.
|
||||||
///
|
///
|
||||||
/// It is equivalent to doing:
|
/// It is equivalent to doing:
|
||||||
@@ -119,10 +121,10 @@ extension UploadTaskPatterns on UploadTask {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UploadTask value)? $default,{required TResult orElse(),}){
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _DriveTask value)? $default,{required TResult orElse(),}){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UploadTask() when $default != null:
|
case _DriveTask() when $default != null:
|
||||||
return $default(_that);case _:
|
return $default(_that);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
@@ -141,10 +143,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UploadTask value) $default,){
|
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _DriveTask value) $default,){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UploadTask():
|
case _DriveTask():
|
||||||
return $default(_that);}
|
return $default(_that);}
|
||||||
}
|
}
|
||||||
/// A variant of `map` that fallback to returning `null`.
|
/// A variant of `map` that fallback to returning `null`.
|
||||||
@@ -159,10 +161,10 @@ return $default(_that);}
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UploadTask value)? $default,){
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _DriveTask value)? $default,){
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UploadTask() when $default != null:
|
case _DriveTask() when $default != null:
|
||||||
return $default(_that);case _:
|
return $default(_that);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -180,10 +182,10 @@ return $default(_that);case _:
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, UploadTaskStatus status, DateTime createdAt, DateTime updatedAt, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt)? $default,{required TResult orElse(),}) {final _that = this;
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, DriveTaskStatus status, DateTime createdAt, DateTime updatedAt, String type, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UploadTask() when $default != null:
|
case _DriveTask() when $default != null:
|
||||||
return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fileSize,_that.uploadedBytes,_that.totalChunks,_that.uploadedChunks,_that.status,_that.createdAt,_that.updatedAt,_that.transmissionProgress,_that.errorMessage,_that.result,_that.poolId,_that.bundleId,_that.encryptPassword,_that.expiredAt);case _:
|
return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fileSize,_that.uploadedBytes,_that.totalChunks,_that.uploadedChunks,_that.status,_that.createdAt,_that.updatedAt,_that.type,_that.transmissionProgress,_that.errorMessage,_that.result,_that.poolId,_that.bundleId,_that.encryptPassword,_that.expiredAt);case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -201,10 +203,10 @@ return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fil
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, UploadTaskStatus status, DateTime createdAt, DateTime updatedAt, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt) $default,) {final _that = this;
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, DriveTaskStatus status, DateTime createdAt, DateTime updatedAt, String type, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt) $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UploadTask():
|
case _DriveTask():
|
||||||
return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fileSize,_that.uploadedBytes,_that.totalChunks,_that.uploadedChunks,_that.status,_that.createdAt,_that.updatedAt,_that.transmissionProgress,_that.errorMessage,_that.result,_that.poolId,_that.bundleId,_that.encryptPassword,_that.expiredAt);}
|
return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fileSize,_that.uploadedBytes,_that.totalChunks,_that.uploadedChunks,_that.status,_that.createdAt,_that.updatedAt,_that.type,_that.transmissionProgress,_that.errorMessage,_that.result,_that.poolId,_that.bundleId,_that.encryptPassword,_that.expiredAt);}
|
||||||
}
|
}
|
||||||
/// A variant of `when` that fallback to returning `null`
|
/// A variant of `when` that fallback to returning `null`
|
||||||
///
|
///
|
||||||
@@ -218,10 +220,10 @@ return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fil
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, UploadTaskStatus status, DateTime createdAt, DateTime updatedAt, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt)? $default,) {final _that = this;
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, DriveTaskStatus status, DateTime createdAt, DateTime updatedAt, String type, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt)? $default,) {final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _UploadTask() when $default != null:
|
case _DriveTask() when $default != null:
|
||||||
return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fileSize,_that.uploadedBytes,_that.totalChunks,_that.uploadedChunks,_that.status,_that.createdAt,_that.updatedAt,_that.transmissionProgress,_that.errorMessage,_that.result,_that.poolId,_that.bundleId,_that.encryptPassword,_that.expiredAt);case _:
|
return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fileSize,_that.uploadedBytes,_that.totalChunks,_that.uploadedChunks,_that.status,_that.createdAt,_that.updatedAt,_that.type,_that.transmissionProgress,_that.errorMessage,_that.result,_that.poolId,_that.bundleId,_that.encryptPassword,_that.expiredAt);case _:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -232,9 +234,9 @@ return $default(_that.id,_that.taskId,_that.fileName,_that.contentType,_that.fil
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
|
|
||||||
class _UploadTask extends UploadTask {
|
class _DriveTask extends DriveTask {
|
||||||
const _UploadTask({required this.id, required this.taskId, required this.fileName, required this.contentType, required this.fileSize, required this.uploadedBytes, required this.totalChunks, required this.uploadedChunks, required this.status, required this.createdAt, required this.updatedAt, this.transmissionProgress, this.errorMessage, this.result, this.poolId, this.bundleId, this.encryptPassword, this.expiredAt}): super._();
|
const _DriveTask({required this.id, required this.taskId, required this.fileName, required this.contentType, required this.fileSize, required this.uploadedBytes, required this.totalChunks, required this.uploadedChunks, required this.status, required this.createdAt, required this.updatedAt, required this.type, this.transmissionProgress, this.errorMessage, this.result, this.poolId, this.bundleId, this.encryptPassword, this.expiredAt}): super._();
|
||||||
factory _UploadTask.fromJson(Map<String, dynamic> json) => _$UploadTaskFromJson(json);
|
factory _DriveTask.fromJson(Map<String, dynamic> json) => _$DriveTaskFromJson(json);
|
||||||
|
|
||||||
@override final String id;
|
@override final String id;
|
||||||
@override final String taskId;
|
@override final String taskId;
|
||||||
@@ -244,9 +246,11 @@ class _UploadTask extends UploadTask {
|
|||||||
@override final int uploadedBytes;
|
@override final int uploadedBytes;
|
||||||
@override final int totalChunks;
|
@override final int totalChunks;
|
||||||
@override final int uploadedChunks;
|
@override final int uploadedChunks;
|
||||||
@override final UploadTaskStatus status;
|
@override final DriveTaskStatus status;
|
||||||
@override final DateTime createdAt;
|
@override final DateTime createdAt;
|
||||||
@override final DateTime updatedAt;
|
@override final DateTime updatedAt;
|
||||||
|
@override final String type;
|
||||||
|
// Task type (e.g., 'FileUpload')
|
||||||
@override final double? transmissionProgress;
|
@override final double? transmissionProgress;
|
||||||
// Local file upload progress (0.0-1.0)
|
// Local file upload progress (0.0-1.0)
|
||||||
@override final String? errorMessage;
|
@override final String? errorMessage;
|
||||||
@@ -256,40 +260,40 @@ class _UploadTask extends UploadTask {
|
|||||||
@override final String? encryptPassword;
|
@override final String? encryptPassword;
|
||||||
@override final String? expiredAt;
|
@override final String? expiredAt;
|
||||||
|
|
||||||
/// Create a copy of UploadTask
|
/// Create a copy of DriveTask
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
_$UploadTaskCopyWith<_UploadTask> get copyWith => __$UploadTaskCopyWithImpl<_UploadTask>(this, _$identity);
|
_$DriveTaskCopyWith<_DriveTask> get copyWith => __$DriveTaskCopyWithImpl<_DriveTask>(this, _$identity);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return _$UploadTaskToJson(this, );
|
return _$DriveTaskToJson(this, );
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UploadTask&&(identical(other.id, id) || other.id == id)&&(identical(other.taskId, taskId) || other.taskId == taskId)&&(identical(other.fileName, fileName) || other.fileName == fileName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.fileSize, fileSize) || other.fileSize == fileSize)&&(identical(other.uploadedBytes, uploadedBytes) || other.uploadedBytes == uploadedBytes)&&(identical(other.totalChunks, totalChunks) || other.totalChunks == totalChunks)&&(identical(other.uploadedChunks, uploadedChunks) || other.uploadedChunks == uploadedChunks)&&(identical(other.status, status) || other.status == status)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.transmissionProgress, transmissionProgress) || other.transmissionProgress == transmissionProgress)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.result, result) || other.result == result)&&(identical(other.poolId, poolId) || other.poolId == poolId)&&(identical(other.bundleId, bundleId) || other.bundleId == bundleId)&&(identical(other.encryptPassword, encryptPassword) || other.encryptPassword == encryptPassword)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt));
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _DriveTask&&(identical(other.id, id) || other.id == id)&&(identical(other.taskId, taskId) || other.taskId == taskId)&&(identical(other.fileName, fileName) || other.fileName == fileName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.fileSize, fileSize) || other.fileSize == fileSize)&&(identical(other.uploadedBytes, uploadedBytes) || other.uploadedBytes == uploadedBytes)&&(identical(other.totalChunks, totalChunks) || other.totalChunks == totalChunks)&&(identical(other.uploadedChunks, uploadedChunks) || other.uploadedChunks == uploadedChunks)&&(identical(other.status, status) || other.status == status)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.type, type) || other.type == type)&&(identical(other.transmissionProgress, transmissionProgress) || other.transmissionProgress == transmissionProgress)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.result, result) || other.result == result)&&(identical(other.poolId, poolId) || other.poolId == poolId)&&(identical(other.bundleId, bundleId) || other.bundleId == bundleId)&&(identical(other.encryptPassword, encryptPassword) || other.encryptPassword == encryptPassword)&&(identical(other.expiredAt, expiredAt) || other.expiredAt == expiredAt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType,id,taskId,fileName,contentType,fileSize,uploadedBytes,totalChunks,uploadedChunks,status,createdAt,updatedAt,transmissionProgress,errorMessage,result,poolId,bundleId,encryptPassword,expiredAt);
|
int get hashCode => Object.hashAll([runtimeType,id,taskId,fileName,contentType,fileSize,uploadedBytes,totalChunks,uploadedChunks,status,createdAt,updatedAt,type,transmissionProgress,errorMessage,result,poolId,bundleId,encryptPassword,expiredAt]);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'UploadTask(id: $id, taskId: $taskId, fileName: $fileName, contentType: $contentType, fileSize: $fileSize, uploadedBytes: $uploadedBytes, totalChunks: $totalChunks, uploadedChunks: $uploadedChunks, status: $status, createdAt: $createdAt, updatedAt: $updatedAt, transmissionProgress: $transmissionProgress, errorMessage: $errorMessage, result: $result, poolId: $poolId, bundleId: $bundleId, encryptPassword: $encryptPassword, expiredAt: $expiredAt)';
|
return 'DriveTask(id: $id, taskId: $taskId, fileName: $fileName, contentType: $contentType, fileSize: $fileSize, uploadedBytes: $uploadedBytes, totalChunks: $totalChunks, uploadedChunks: $uploadedChunks, status: $status, createdAt: $createdAt, updatedAt: $updatedAt, type: $type, transmissionProgress: $transmissionProgress, errorMessage: $errorMessage, result: $result, poolId: $poolId, bundleId: $bundleId, encryptPassword: $encryptPassword, expiredAt: $expiredAt)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract mixin class _$UploadTaskCopyWith<$Res> implements $UploadTaskCopyWith<$Res> {
|
abstract mixin class _$DriveTaskCopyWith<$Res> implements $DriveTaskCopyWith<$Res> {
|
||||||
factory _$UploadTaskCopyWith(_UploadTask value, $Res Function(_UploadTask) _then) = __$UploadTaskCopyWithImpl;
|
factory _$DriveTaskCopyWith(_DriveTask value, $Res Function(_DriveTask) _then) = __$DriveTaskCopyWithImpl;
|
||||||
@override @useResult
|
@override @useResult
|
||||||
$Res call({
|
$Res call({
|
||||||
String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, UploadTaskStatus status, DateTime createdAt, DateTime updatedAt, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt
|
String id, String taskId, String fileName, String contentType, int fileSize, int uploadedBytes, int totalChunks, int uploadedChunks, DriveTaskStatus status, DateTime createdAt, DateTime updatedAt, String type, double? transmissionProgress, String? errorMessage, SnCloudFile? result, String? poolId, String? bundleId, String? encryptPassword, String? expiredAt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -297,17 +301,17 @@ $Res call({
|
|||||||
|
|
||||||
}
|
}
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$UploadTaskCopyWithImpl<$Res>
|
class __$DriveTaskCopyWithImpl<$Res>
|
||||||
implements _$UploadTaskCopyWith<$Res> {
|
implements _$DriveTaskCopyWith<$Res> {
|
||||||
__$UploadTaskCopyWithImpl(this._self, this._then);
|
__$DriveTaskCopyWithImpl(this._self, this._then);
|
||||||
|
|
||||||
final _UploadTask _self;
|
final _DriveTask _self;
|
||||||
final $Res Function(_UploadTask) _then;
|
final $Res Function(_DriveTask) _then;
|
||||||
|
|
||||||
/// Create a copy of UploadTask
|
/// Create a copy of DriveTask
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? taskId = null,Object? fileName = null,Object? contentType = null,Object? fileSize = null,Object? uploadedBytes = null,Object? totalChunks = null,Object? uploadedChunks = null,Object? status = null,Object? createdAt = null,Object? updatedAt = null,Object? transmissionProgress = freezed,Object? errorMessage = freezed,Object? result = freezed,Object? poolId = freezed,Object? bundleId = freezed,Object? encryptPassword = freezed,Object? expiredAt = freezed,}) {
|
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? taskId = null,Object? fileName = null,Object? contentType = null,Object? fileSize = null,Object? uploadedBytes = null,Object? totalChunks = null,Object? uploadedChunks = null,Object? status = null,Object? createdAt = null,Object? updatedAt = null,Object? type = null,Object? transmissionProgress = freezed,Object? errorMessage = freezed,Object? result = freezed,Object? poolId = freezed,Object? bundleId = freezed,Object? encryptPassword = freezed,Object? expiredAt = freezed,}) {
|
||||||
return _then(_UploadTask(
|
return _then(_DriveTask(
|
||||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||||
as String,taskId: null == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable
|
as String,taskId: null == taskId ? _self.taskId : taskId // ignore: cast_nullable_to_non_nullable
|
||||||
as String,fileName: null == fileName ? _self.fileName : fileName // ignore: cast_nullable_to_non_nullable
|
as String,fileName: null == fileName ? _self.fileName : fileName // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -317,9 +321,10 @@ as int,uploadedBytes: null == uploadedBytes ? _self.uploadedBytes : uploadedByte
|
|||||||
as int,totalChunks: null == totalChunks ? _self.totalChunks : totalChunks // ignore: cast_nullable_to_non_nullable
|
as int,totalChunks: null == totalChunks ? _self.totalChunks : totalChunks // ignore: cast_nullable_to_non_nullable
|
||||||
as int,uploadedChunks: null == uploadedChunks ? _self.uploadedChunks : uploadedChunks // ignore: cast_nullable_to_non_nullable
|
as int,uploadedChunks: null == uploadedChunks ? _self.uploadedChunks : uploadedChunks // ignore: cast_nullable_to_non_nullable
|
||||||
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
as int,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
||||||
as UploadTaskStatus,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
as DriveTaskStatus,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
as DateTime,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable
|
||||||
as DateTime,transmissionProgress: freezed == transmissionProgress ? _self.transmissionProgress : transmissionProgress // ignore: cast_nullable_to_non_nullable
|
as DateTime,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,transmissionProgress: freezed == transmissionProgress ? _self.transmissionProgress : transmissionProgress // ignore: cast_nullable_to_non_nullable
|
||||||
as double?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
as double?,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
|
||||||
as SnCloudFile?,poolId: freezed == poolId ? _self.poolId : poolId // ignore: cast_nullable_to_non_nullable
|
as SnCloudFile?,poolId: freezed == poolId ? _self.poolId : poolId // ignore: cast_nullable_to_non_nullable
|
||||||
@@ -330,7 +335,7 @@ as String?,
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a copy of UploadTask
|
/// Create a copy of DriveTask
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
@override
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
part of 'upload_task.dart';
|
part of 'drive_task.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
_UploadTask _$UploadTaskFromJson(Map<String, dynamic> json) => _UploadTask(
|
_DriveTask _$DriveTaskFromJson(Map<String, dynamic> json) => _DriveTask(
|
||||||
id: json['id'] as String,
|
id: json['id'] as String,
|
||||||
taskId: json['task_id'] as String,
|
taskId: json['task_id'] as String,
|
||||||
fileName: json['file_name'] as String,
|
fileName: json['file_name'] as String,
|
||||||
@@ -15,9 +15,10 @@ _UploadTask _$UploadTaskFromJson(Map<String, dynamic> json) => _UploadTask(
|
|||||||
uploadedBytes: (json['uploaded_bytes'] as num).toInt(),
|
uploadedBytes: (json['uploaded_bytes'] as num).toInt(),
|
||||||
totalChunks: (json['total_chunks'] as num).toInt(),
|
totalChunks: (json['total_chunks'] as num).toInt(),
|
||||||
uploadedChunks: (json['uploaded_chunks'] as num).toInt(),
|
uploadedChunks: (json['uploaded_chunks'] as num).toInt(),
|
||||||
status: $enumDecode(_$UploadTaskStatusEnumMap, json['status']),
|
status: $enumDecode(_$DriveTaskStatusEnumMap, json['status']),
|
||||||
createdAt: DateTime.parse(json['created_at'] as String),
|
createdAt: DateTime.parse(json['created_at'] as String),
|
||||||
updatedAt: DateTime.parse(json['updated_at'] as String),
|
updatedAt: DateTime.parse(json['updated_at'] as String),
|
||||||
|
type: json['type'] as String,
|
||||||
transmissionProgress: (json['transmission_progress'] as num?)?.toDouble(),
|
transmissionProgress: (json['transmission_progress'] as num?)?.toDouble(),
|
||||||
errorMessage: json['error_message'] as String?,
|
errorMessage: json['error_message'] as String?,
|
||||||
result:
|
result:
|
||||||
@@ -30,7 +31,7 @@ _UploadTask _$UploadTaskFromJson(Map<String, dynamic> json) => _UploadTask(
|
|||||||
expiredAt: json['expired_at'] as String?,
|
expiredAt: json['expired_at'] as String?,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$UploadTaskToJson(_UploadTask instance) =>
|
Map<String, dynamic> _$DriveTaskToJson(_DriveTask instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'id': instance.id,
|
'id': instance.id,
|
||||||
'task_id': instance.taskId,
|
'task_id': instance.taskId,
|
||||||
@@ -40,9 +41,10 @@ Map<String, dynamic> _$UploadTaskToJson(_UploadTask instance) =>
|
|||||||
'uploaded_bytes': instance.uploadedBytes,
|
'uploaded_bytes': instance.uploadedBytes,
|
||||||
'total_chunks': instance.totalChunks,
|
'total_chunks': instance.totalChunks,
|
||||||
'uploaded_chunks': instance.uploadedChunks,
|
'uploaded_chunks': instance.uploadedChunks,
|
||||||
'status': _$UploadTaskStatusEnumMap[instance.status]!,
|
'status': _$DriveTaskStatusEnumMap[instance.status]!,
|
||||||
'created_at': instance.createdAt.toIso8601String(),
|
'created_at': instance.createdAt.toIso8601String(),
|
||||||
'updated_at': instance.updatedAt.toIso8601String(),
|
'updated_at': instance.updatedAt.toIso8601String(),
|
||||||
|
'type': instance.type,
|
||||||
'transmission_progress': instance.transmissionProgress,
|
'transmission_progress': instance.transmissionProgress,
|
||||||
'error_message': instance.errorMessage,
|
'error_message': instance.errorMessage,
|
||||||
'result': instance.result?.toJson(),
|
'result': instance.result?.toJson(),
|
||||||
@@ -52,12 +54,12 @@ Map<String, dynamic> _$UploadTaskToJson(_UploadTask instance) =>
|
|||||||
'expired_at': instance.expiredAt,
|
'expired_at': instance.expiredAt,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$UploadTaskStatusEnumMap = {
|
const _$DriveTaskStatusEnumMap = {
|
||||||
UploadTaskStatus.pending: 'pending',
|
DriveTaskStatus.pending: 'pending',
|
||||||
UploadTaskStatus.inProgress: 'inProgress',
|
DriveTaskStatus.inProgress: 'inProgress',
|
||||||
UploadTaskStatus.paused: 'paused',
|
DriveTaskStatus.paused: 'paused',
|
||||||
UploadTaskStatus.completed: 'completed',
|
DriveTaskStatus.completed: 'completed',
|
||||||
UploadTaskStatus.failed: 'failed',
|
DriveTaskStatus.failed: 'failed',
|
||||||
UploadTaskStatus.expired: 'expired',
|
DriveTaskStatus.expired: 'expired',
|
||||||
UploadTaskStatus.cancelled: 'cancelled',
|
DriveTaskStatus.cancelled: 'cancelled',
|
||||||
};
|
};
|
||||||
@@ -6,7 +6,7 @@ part of 'messages_notifier.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$messagesNotifierHash() => r'b1d5d583199941d55dfdc707e1a22eec9616b7f1';
|
String _$messagesNotifierHash() => r'c009eb8598e8b5fbcece2d0b5213b2e434edb3b2';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ import 'dart:typed_data';
|
|||||||
import 'package:cross_file/cross_file.dart';
|
import 'package:cross_file/cross_file.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:island/models/file.dart';
|
import 'package:island/models/file.dart';
|
||||||
import 'package:island/models/upload_task.dart';
|
import 'package:island/models/drive_task.dart';
|
||||||
import 'package:island/pods/network.dart';
|
import 'package:island/pods/network.dart';
|
||||||
import 'package:island/pods/websocket.dart';
|
import 'package:island/pods/websocket.dart';
|
||||||
import 'package:island/services/file_uploader.dart';
|
import 'package:island/services/file_uploader.dart';
|
||||||
import 'package:island/talker.dart';
|
import 'package:island/talker.dart';
|
||||||
|
|
||||||
final uploadTasksProvider =
|
final uploadTasksProvider =
|
||||||
StateNotifierProvider<UploadTasksNotifier, List<UploadTask>>(
|
StateNotifierProvider<UploadTasksNotifier, List<DriveTask>>(
|
||||||
(ref) => UploadTasksNotifier(ref),
|
(ref) => UploadTasksNotifier(ref),
|
||||||
);
|
);
|
||||||
|
|
||||||
class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
class UploadTasksNotifier extends StateNotifier<List<DriveTask>> {
|
||||||
final Ref ref;
|
final Ref ref;
|
||||||
StreamSubscription? _websocketSubscription;
|
StreamSubscription? _websocketSubscription;
|
||||||
final Map<String, Map<String, dynamic>> _pendingUploads = {};
|
final Map<String, Map<String, dynamic>> _pendingUploads = {};
|
||||||
@@ -73,7 +73,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
state.map((task) {
|
state.map((task) {
|
||||||
if (task.taskId == taskId) {
|
if (task.taskId == taskId) {
|
||||||
return task.copyWith(
|
return task.copyWith(
|
||||||
status: UploadTaskStatus.pending,
|
status: DriveTaskStatus.pending,
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
talker.info('[UploadTasks] Creating task with full metadata');
|
talker.info('[UploadTasks] Creating task with full metadata');
|
||||||
// Create task with full metadata
|
// Create task with full metadata
|
||||||
final uploadTask = UploadTask(
|
final uploadTask = DriveTask(
|
||||||
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
taskId: taskId,
|
taskId: taskId,
|
||||||
fileName: metadata['fileName'] as String,
|
fileName: metadata['fileName'] as String,
|
||||||
@@ -98,9 +98,10 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
uploadedBytes: 0,
|
uploadedBytes: 0,
|
||||||
totalChunks: metadata['totalChunks'] as int,
|
totalChunks: metadata['totalChunks'] as int,
|
||||||
uploadedChunks: 0,
|
uploadedChunks: 0,
|
||||||
status: UploadTaskStatus.pending,
|
status: DriveTaskStatus.pending,
|
||||||
createdAt: DateTime.now(),
|
createdAt: DateTime.now(),
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
|
type: 'FileUpload',
|
||||||
poolId: metadata['poolId'] as String?,
|
poolId: metadata['poolId'] as String?,
|
||||||
bundleId: metadata['bundleId'] as String?,
|
bundleId: metadata['bundleId'] as String?,
|
||||||
encryptPassword: metadata['encryptPassword'] as String?,
|
encryptPassword: metadata['encryptPassword'] as String?,
|
||||||
@@ -116,7 +117,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
} else {
|
} else {
|
||||||
talker.info('[UploadTasks] No metadata found, creating minimal task');
|
talker.info('[UploadTasks] No metadata found, creating minimal task');
|
||||||
// Create minimal task if no metadata is stored
|
// Create minimal task if no metadata is stored
|
||||||
final uploadTask = UploadTask(
|
final uploadTask = DriveTask(
|
||||||
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
taskId: taskId,
|
taskId: taskId,
|
||||||
fileName: data['name'] as String? ?? 'Unknown file',
|
fileName: data['name'] as String? ?? 'Unknown file',
|
||||||
@@ -125,9 +126,10 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
uploadedBytes: 0,
|
uploadedBytes: 0,
|
||||||
totalChunks: 0,
|
totalChunks: 0,
|
||||||
uploadedChunks: 0,
|
uploadedChunks: 0,
|
||||||
status: UploadTaskStatus.pending,
|
status: DriveTaskStatus.pending,
|
||||||
createdAt: DateTime.now(),
|
createdAt: DateTime.now(),
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
|
type: 'FileUpload',
|
||||||
);
|
);
|
||||||
|
|
||||||
state = [...state, uploadTask];
|
state = [...state, uploadTask];
|
||||||
@@ -146,7 +148,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
final uploadedBytes = (progress / 100.0 * task.fileSize).toInt();
|
final uploadedBytes = (progress / 100.0 * task.fileSize).toInt();
|
||||||
return task.copyWith(
|
return task.copyWith(
|
||||||
uploadedBytes: uploadedBytes,
|
uploadedBytes: uploadedBytes,
|
||||||
status: UploadTaskStatus.inProgress,
|
status: DriveTaskStatus.inProgress,
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -161,7 +163,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
state.map((task) {
|
state.map((task) {
|
||||||
if (task.taskId == taskId) {
|
if (task.taskId == taskId) {
|
||||||
return task.copyWith(
|
return task.copyWith(
|
||||||
status: UploadTaskStatus.completed,
|
status: DriveTaskStatus.completed,
|
||||||
uploadedChunks: task.totalChunks,
|
uploadedChunks: task.totalChunks,
|
||||||
uploadedBytes: task.fileSize,
|
uploadedBytes: task.fileSize,
|
||||||
// Update file information from Results if available
|
// Update file information from Results if available
|
||||||
@@ -186,7 +188,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
state.map((task) {
|
state.map((task) {
|
||||||
if (task.taskId == taskId) {
|
if (task.taskId == taskId) {
|
||||||
return task.copyWith(
|
return task.copyWith(
|
||||||
status: UploadTaskStatus.failed,
|
status: DriveTaskStatus.failed,
|
||||||
errorMessage: errorMessage,
|
errorMessage: errorMessage,
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
);
|
);
|
||||||
@@ -195,7 +197,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addUploadTask(UploadTask task) {
|
void addUploadTask(DriveTask task) {
|
||||||
state = [...state, task];
|
state = [...state, task];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +226,7 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
|
|
||||||
void updateTaskStatus(
|
void updateTaskStatus(
|
||||||
String taskId,
|
String taskId,
|
||||||
UploadTaskStatus status, {
|
DriveTaskStatus status, {
|
||||||
String? errorMessage,
|
String? errorMessage,
|
||||||
}) {
|
}) {
|
||||||
state =
|
state =
|
||||||
@@ -262,26 +264,26 @@ class UploadTasksNotifier extends StateNotifier<List<UploadTask>> {
|
|||||||
state
|
state
|
||||||
.where(
|
.where(
|
||||||
(task) =>
|
(task) =>
|
||||||
task.status != UploadTaskStatus.completed &&
|
task.status != DriveTaskStatus.completed &&
|
||||||
task.status != UploadTaskStatus.failed &&
|
task.status != DriveTaskStatus.failed &&
|
||||||
task.status != UploadTaskStatus.cancelled &&
|
task.status != DriveTaskStatus.cancelled &&
|
||||||
task.status != UploadTaskStatus.expired,
|
task.status != DriveTaskStatus.expired,
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
UploadTask? getTask(String taskId) {
|
DriveTask? getTask(String taskId) {
|
||||||
return state.where((task) => task.taskId == taskId).firstOrNull;
|
return state.where((task) => task.taskId == taskId).firstOrNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<UploadTask> getActiveTasks() {
|
List<DriveTask> getActiveTasks() {
|
||||||
return state
|
return state
|
||||||
.where(
|
.where(
|
||||||
(task) =>
|
(task) =>
|
||||||
task.status == UploadTaskStatus.pending ||
|
task.status == DriveTaskStatus.pending ||
|
||||||
task.status == UploadTaskStatus.inProgress ||
|
task.status == DriveTaskStatus.inProgress ||
|
||||||
task.status == UploadTaskStatus.paused ||
|
task.status == DriveTaskStatus.paused ||
|
||||||
task.status == UploadTaskStatus.completed,
|
task.status == DriveTaskStatus.completed,
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
@@ -378,7 +380,7 @@ class EnhancedFileUploader extends FileUploader {
|
|||||||
createResponse['task_id'] as String? ??
|
createResponse['task_id'] as String? ??
|
||||||
'existing-${DateTime.now().millisecondsSinceEpoch}';
|
'existing-${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
|
||||||
final uploadTask = UploadTask(
|
final uploadTask = DriveTask(
|
||||||
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||||
taskId: taskId,
|
taskId: taskId,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
@@ -387,9 +389,10 @@ class EnhancedFileUploader extends FileUploader {
|
|||||||
uploadedBytes: totalSize,
|
uploadedBytes: totalSize,
|
||||||
totalChunks: 1, // For existing files, we consider it as 1 chunk
|
totalChunks: 1, // For existing files, we consider it as 1 chunk
|
||||||
uploadedChunks: 1,
|
uploadedChunks: 1,
|
||||||
status: UploadTaskStatus.completed,
|
status: DriveTaskStatus.completed,
|
||||||
createdAt: DateTime.now(),
|
createdAt: DateTime.now(),
|
||||||
updatedAt: DateTime.now(),
|
updatedAt: DateTime.now(),
|
||||||
|
type: 'FileUpload',
|
||||||
poolId: poolId,
|
poolId: poolId,
|
||||||
bundleId: bundleId,
|
bundleId: bundleId,
|
||||||
encryptPassword: encryptPassword,
|
encryptPassword: encryptPassword,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:island/models/upload_task.dart';
|
import 'package:island/models/drive_task.dart';
|
||||||
import 'package:island/pods/upload_tasks.dart';
|
import 'package:island/pods/upload_tasks.dart';
|
||||||
import 'package:island/services/responsive.dart';
|
import 'package:island/services/responsive.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
@@ -20,10 +20,10 @@ class UploadOverlay extends HookConsumerWidget {
|
|||||||
uploadTasks
|
uploadTasks
|
||||||
.where(
|
.where(
|
||||||
(task) =>
|
(task) =>
|
||||||
task.status == UploadTaskStatus.pending ||
|
task.status == DriveTaskStatus.pending ||
|
||||||
task.status == UploadTaskStatus.inProgress ||
|
task.status == DriveTaskStatus.inProgress ||
|
||||||
task.status == UploadTaskStatus.paused ||
|
task.status == DriveTaskStatus.paused ||
|
||||||
task.status == UploadTaskStatus.completed,
|
task.status == DriveTaskStatus.completed,
|
||||||
)
|
)
|
||||||
.toList()
|
.toList()
|
||||||
..sort((a, b) => b.createdAt.compareTo(a.createdAt)); // Newest first
|
..sort((a, b) => b.createdAt.compareTo(a.createdAt)); // Newest first
|
||||||
@@ -67,7 +67,7 @@ class UploadOverlay extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UploadOverlayContent extends HookConsumerWidget {
|
class _UploadOverlayContent extends HookConsumerWidget {
|
||||||
final List<UploadTask> activeTasks;
|
final List<DriveTask> activeTasks;
|
||||||
|
|
||||||
const _UploadOverlayContent({required this.activeTasks});
|
const _UploadOverlayContent({required this.activeTasks});
|
||||||
|
|
||||||
@@ -290,46 +290,46 @@ class _UploadOverlayContent extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _getOverallProgress(List<UploadTask> tasks) {
|
double _getOverallProgress(List<DriveTask> tasks) {
|
||||||
if (tasks.isEmpty) return 0.0;
|
if (tasks.isEmpty) return 0.0;
|
||||||
final totalProgress = tasks.fold<double>(
|
final totalProgress = tasks.fold<double>(
|
||||||
0.0,
|
0.0,
|
||||||
(sum, task) =>
|
(sum, task) =>
|
||||||
sum +
|
sum +
|
||||||
(task.status == UploadTaskStatus.inProgress
|
(task.status == DriveTaskStatus.inProgress
|
||||||
? task.progress
|
? task.progress
|
||||||
: task.status == UploadTaskStatus.completed
|
: task.status == DriveTaskStatus.completed
|
||||||
? 1
|
? 1
|
||||||
: 0),
|
: 0),
|
||||||
);
|
);
|
||||||
return totalProgress / tasks.length;
|
return totalProgress / tasks.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getOverallProgressText(List<UploadTask> tasks) {
|
String _getOverallProgressText(List<DriveTask> tasks) {
|
||||||
final overallProgress = _getOverallProgress(tasks);
|
final overallProgress = _getOverallProgress(tasks);
|
||||||
return '${(overallProgress * 100).toStringAsFixed(0)}%';
|
return '${(overallProgress * 100).toStringAsFixed(0)}%';
|
||||||
}
|
}
|
||||||
|
|
||||||
IconData _getOverallStatusIcon(List<UploadTask> tasks) {
|
IconData _getOverallStatusIcon(List<DriveTask> tasks) {
|
||||||
if (tasks.isEmpty) return Symbols.upload;
|
if (tasks.isEmpty) return Symbols.upload;
|
||||||
|
|
||||||
final hasInProgress = tasks.any(
|
final hasInProgress = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.inProgress,
|
(task) => task.status == DriveTaskStatus.inProgress,
|
||||||
);
|
);
|
||||||
final hasPending = tasks.any(
|
final hasPending = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.pending,
|
(task) => task.status == DriveTaskStatus.pending,
|
||||||
);
|
);
|
||||||
final hasPaused = tasks.any(
|
final hasPaused = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.paused,
|
(task) => task.status == DriveTaskStatus.paused,
|
||||||
);
|
);
|
||||||
final hasFailed = tasks.any(
|
final hasFailed = tasks.any(
|
||||||
(task) =>
|
(task) =>
|
||||||
task.status == UploadTaskStatus.failed ||
|
task.status == DriveTaskStatus.failed ||
|
||||||
task.status == UploadTaskStatus.cancelled ||
|
task.status == DriveTaskStatus.cancelled ||
|
||||||
task.status == UploadTaskStatus.expired,
|
task.status == DriveTaskStatus.expired,
|
||||||
);
|
);
|
||||||
final hasCompleted = tasks.any(
|
final hasCompleted = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.completed,
|
(task) => task.status == DriveTaskStatus.completed,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Priority order: in progress > pending > paused > failed > completed
|
// Priority order: in progress > pending > paused > failed > completed
|
||||||
@@ -348,26 +348,26 @@ class _UploadOverlayContent extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getOverallStatusText(List<UploadTask> tasks) {
|
String _getOverallStatusText(List<DriveTask> tasks) {
|
||||||
if (tasks.isEmpty) return '0 tasks';
|
if (tasks.isEmpty) return '0 tasks';
|
||||||
|
|
||||||
final hasInProgress = tasks.any(
|
final hasInProgress = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.inProgress,
|
(task) => task.status == DriveTaskStatus.inProgress,
|
||||||
);
|
);
|
||||||
final hasPending = tasks.any(
|
final hasPending = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.pending,
|
(task) => task.status == DriveTaskStatus.pending,
|
||||||
);
|
);
|
||||||
final hasPaused = tasks.any(
|
final hasPaused = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.paused,
|
(task) => task.status == DriveTaskStatus.paused,
|
||||||
);
|
);
|
||||||
final hasFailed = tasks.any(
|
final hasFailed = tasks.any(
|
||||||
(task) =>
|
(task) =>
|
||||||
task.status == UploadTaskStatus.failed ||
|
task.status == DriveTaskStatus.failed ||
|
||||||
task.status == UploadTaskStatus.cancelled ||
|
task.status == DriveTaskStatus.cancelled ||
|
||||||
task.status == UploadTaskStatus.expired,
|
task.status == DriveTaskStatus.expired,
|
||||||
);
|
);
|
||||||
final hasCompleted = tasks.any(
|
final hasCompleted = tasks.any(
|
||||||
(task) => task.status == UploadTaskStatus.completed,
|
(task) => task.status == DriveTaskStatus.completed,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Priority order: in progress > pending > paused > failed > completed
|
// Priority order: in progress > pending > paused > failed > completed
|
||||||
@@ -386,19 +386,19 @@ class _UploadOverlayContent extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _hasCompletedTasks(List<UploadTask> tasks) {
|
bool _hasCompletedTasks(List<DriveTask> tasks) {
|
||||||
return tasks.any(
|
return tasks.any(
|
||||||
(task) =>
|
(task) =>
|
||||||
task.status == UploadTaskStatus.completed ||
|
task.status == DriveTaskStatus.completed ||
|
||||||
task.status == UploadTaskStatus.failed ||
|
task.status == DriveTaskStatus.failed ||
|
||||||
task.status == UploadTaskStatus.cancelled ||
|
task.status == DriveTaskStatus.cancelled ||
|
||||||
task.status == UploadTaskStatus.expired,
|
task.status == DriveTaskStatus.expired,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UploadTaskTile extends StatefulWidget {
|
class UploadTaskTile extends StatefulWidget {
|
||||||
final UploadTask task;
|
final DriveTask task;
|
||||||
|
|
||||||
const UploadTaskTile({super.key, required this.task});
|
const UploadTaskTile({super.key, required this.task});
|
||||||
|
|
||||||
@@ -507,31 +507,31 @@ class _UploadTaskTileState extends State<UploadTaskTile>
|
|||||||
Color color;
|
Color color;
|
||||||
|
|
||||||
switch (widget.task.status) {
|
switch (widget.task.status) {
|
||||||
case UploadTaskStatus.pending:
|
case DriveTaskStatus.pending:
|
||||||
icon = Symbols.schedule;
|
icon = Symbols.schedule;
|
||||||
color = Theme.of(context).colorScheme.secondary;
|
color = Theme.of(context).colorScheme.secondary;
|
||||||
break;
|
break;
|
||||||
case UploadTaskStatus.inProgress:
|
case DriveTaskStatus.inProgress:
|
||||||
icon = Symbols.upload;
|
icon = Symbols.upload;
|
||||||
color = Theme.of(context).colorScheme.primary;
|
color = Theme.of(context).colorScheme.primary;
|
||||||
break;
|
break;
|
||||||
case UploadTaskStatus.paused:
|
case DriveTaskStatus.paused:
|
||||||
icon = Symbols.pause_circle;
|
icon = Symbols.pause_circle;
|
||||||
color = Theme.of(context).colorScheme.tertiary;
|
color = Theme.of(context).colorScheme.tertiary;
|
||||||
break;
|
break;
|
||||||
case UploadTaskStatus.completed:
|
case DriveTaskStatus.completed:
|
||||||
icon = Symbols.check_circle;
|
icon = Symbols.check_circle;
|
||||||
color = Colors.green;
|
color = Colors.green;
|
||||||
break;
|
break;
|
||||||
case UploadTaskStatus.failed:
|
case DriveTaskStatus.failed:
|
||||||
icon = Symbols.error;
|
icon = Symbols.error;
|
||||||
color = Theme.of(context).colorScheme.error;
|
color = Theme.of(context).colorScheme.error;
|
||||||
break;
|
break;
|
||||||
case UploadTaskStatus.cancelled:
|
case DriveTaskStatus.cancelled:
|
||||||
icon = Symbols.cancel;
|
icon = Symbols.cancel;
|
||||||
color = Theme.of(context).colorScheme.error;
|
color = Theme.of(context).colorScheme.error;
|
||||||
break;
|
break;
|
||||||
case UploadTaskStatus.expired:
|
case DriveTaskStatus.expired:
|
||||||
icon = Symbols.timer_off;
|
icon = Symbols.timer_off;
|
||||||
color = Theme.of(context).colorScheme.error;
|
color = Theme.of(context).colorScheme.error;
|
||||||
break;
|
break;
|
||||||
@@ -541,119 +541,177 @@ class _UploadTaskTileState extends State<UploadTaskTile>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildExpandedDetails(BuildContext context) {
|
Widget _buildExpandedDetails(BuildContext context) {
|
||||||
final transmissionProgress = widget.task.transmissionProgress ?? 0.0;
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: switch (widget.task.type) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
'FileUpload' => _buildFileUploadDetails(context),
|
||||||
children: [
|
_ => _buildGenericTaskDetails(context),
|
||||||
// Server Processing Progress
|
},
|
||||||
Text(
|
);
|
||||||
'Server Processing',
|
}
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 2),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'${(widget.task.progress * 100).toStringAsFixed(1)}%',
|
|
||||||
style: Theme.of(
|
|
||||||
context,
|
|
||||||
).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${widget.task.uploadedChunks}/${widget.task.totalChunks} chunks',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
LinearProgressIndicator(
|
|
||||||
value: widget.task.progress,
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
|
||||||
Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 8),
|
Widget _buildFileUploadDetails(BuildContext context) {
|
||||||
|
final transmissionProgress = widget.task.transmissionProgress ?? 0.0;
|
||||||
|
|
||||||
// File Transmission Progress
|
return Column(
|
||||||
Text(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
'File Transmission',
|
children: [
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
// Server Processing Progress
|
||||||
fontWeight: FontWeight.w600,
|
Text(
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
'Server Processing',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${(widget.task.progress * 100).toStringAsFixed(1)}%',
|
||||||
|
style: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
const SizedBox(height: 2),
|
'${widget.task.uploadedChunks}/${widget.task.totalChunks} chunks',
|
||||||
Row(
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'${(transmissionProgress * 100).toStringAsFixed(1)}%',
|
|
||||||
style: Theme.of(
|
|
||||||
context,
|
|
||||||
).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${_formatFileSize((transmissionProgress * widget.task.fileSize).toInt())} / ${_formatFileSize(widget.task.fileSize)}',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
LinearProgressIndicator(
|
|
||||||
value: transmissionProgress,
|
|
||||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(
|
|
||||||
Theme.of(context).colorScheme.secondary,
|
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
LinearProgressIndicator(
|
||||||
|
value: widget.task.progress,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// Speed and ETA
|
// File Transmission Progress
|
||||||
Row(
|
Text(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
'File Transmission',
|
||||||
children: [
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${(transmissionProgress * 100).toStringAsFixed(1)}%',
|
||||||
|
style: Theme.of(
|
||||||
|
context,
|
||||||
|
).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${_formatFileSize((transmissionProgress * widget.task.fileSize).toInt())} / ${_formatFileSize(widget.task.fileSize)}',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
LinearProgressIndicator(
|
||||||
|
value: transmissionProgress,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
|
||||||
|
// Speed and ETA
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
_formatBytesPerSecond(widget.task),
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.task.status == DriveTaskStatus.inProgress)
|
||||||
Text(
|
Text(
|
||||||
_formatBytesPerSecond(widget.task),
|
'ETA: ${_formatDuration(widget.task.estimatedTimeRemaining)}',
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.task.status == UploadTaskStatus.inProgress)
|
],
|
||||||
Text(
|
),
|
||||||
'ETA: ${_formatDuration(widget.task.estimatedTimeRemaining)}',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// Error message if failed
|
// Error message if failed
|
||||||
if (widget.task.errorMessage != null) ...[
|
if (widget.task.errorMessage != null) ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
widget.task.errorMessage!,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildGenericTaskDetails(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Generic task progress
|
||||||
|
Text(
|
||||||
|
'Progress',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
Text(
|
Text(
|
||||||
widget.task.errorMessage!,
|
'${(widget.task.progress * 100).toStringAsFixed(1)}%',
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: Theme.of(
|
||||||
color: Theme.of(context).colorScheme.error,
|
context,
|
||||||
),
|
).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.task.status.name,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
LinearProgressIndicator(
|
||||||
|
value: widget.task.progress,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Error message if failed
|
||||||
|
if (widget.task.errorMessage != null) ...[
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
widget.task.errorMessage!,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,7 +727,7 @@ class _UploadTaskTileState extends State<UploadTaskTile>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _formatBytesPerSecond(UploadTask task) {
|
String _formatBytesPerSecond(DriveTask task) {
|
||||||
if (task.uploadedBytes == 0) return '0 B/s';
|
if (task.uploadedBytes == 0) return '0 B/s';
|
||||||
|
|
||||||
final elapsedSeconds = DateTime.now().difference(task.createdAt).inSeconds;
|
final elapsedSeconds = DateTime.now().difference(task.createdAt).inSeconds;
|
||||||
|
|||||||
Reference in New Issue
Block a user