feat: downloader update

This commit is contained in:
xkeyC
2025-12-06 15:31:11 +08:00
parent 8ea5373dec
commit fbf40580cf
24 changed files with 281 additions and 69 deletions

View File

@@ -86,6 +86,7 @@ Future<void> downloaderResume({required BigInt taskId}) =>
RustLib.instance.api.crateApiDownloaderApiDownloaderResume(taskId: taskId);
/// Remove a download task
/// Handles both active tasks (task_id < 10000) and cached completed tasks (task_id >= 10000)
Future<void> downloaderRemove({
required BigInt taskId,
required bool deleteFiles,
@@ -100,7 +101,7 @@ Future<DownloadTaskInfo> downloaderGetTaskInfo({required BigInt taskId}) =>
taskId: taskId,
);
/// Get all tasks
/// Get all tasks (includes both active and completed tasks from cache)
Future<List<DownloadTaskInfo>> downloaderGetAllTasks() =>
RustLib.instance.api.crateApiDownloaderApiDownloaderGetAllTasks();
@@ -109,10 +110,17 @@ Future<DownloadGlobalStat> downloaderGetGlobalStats() =>
RustLib.instance.api.crateApiDownloaderApiDownloaderGetGlobalStats();
/// Check if a task with given name exists
Future<bool> downloaderIsNameInTask({required String name}) => RustLib
.instance
.api
.crateApiDownloaderApiDownloaderIsNameInTask(name: name);
///
/// Parameters:
/// - name: Task name to search for
/// - downloading_only: If true, only search in active/waiting tasks. If false, include completed tasks (default: true)
Future<bool> downloaderIsNameInTask({
required String name,
bool? downloadingOnly,
}) => RustLib.instance.api.crateApiDownloaderApiDownloaderIsNameInTask(
name: name,
downloadingOnly: downloadingOnly,
);
/// Pause all tasks
Future<void> downloaderPauseAll() =>

View File

@@ -148,6 +148,7 @@ abstract class RustLibApi extends BaseApi {
Future<bool> crateApiDownloaderApiDownloaderIsNameInTask({
required String name,
bool? downloadingOnly,
});
Future<void> crateApiDownloaderApiDownloaderPause({required BigInt taskId});
@@ -912,15 +913,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
@override
Future<bool> crateApiDownloaderApiDownloaderIsNameInTask({
required String name,
bool? downloadingOnly,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
var arg0 = cst_encode_String(name);
var arg1 = cst_encode_opt_box_autoadd_bool(downloadingOnly);
return wire
.wire__crate__api__downloader_api__downloader_is_name_in_task(
port_,
arg0,
arg1,
);
},
codec: DcoCodec(
@@ -928,7 +932,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
decodeErrorData: null,
),
constMeta: kCrateApiDownloaderApiDownloaderIsNameInTaskConstMeta,
argValues: [name],
argValues: [name, downloadingOnly],
apiImpl: this,
),
);
@@ -937,7 +941,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
TaskConstMeta get kCrateApiDownloaderApiDownloaderIsNameInTaskConstMeta =>
const TaskConstMeta(
debugName: "downloader_is_name_in_task",
argNames: ["name"],
argNames: ["name", "downloadingOnly"],
);
@override

View File

@@ -1494,10 +1494,12 @@ class RustLibWire implements BaseWire {
void wire__crate__api__downloader_api__downloader_is_name_in_task(
int port_,
ffi.Pointer<wire_cst_list_prim_u_8_strict> name,
ffi.Pointer<ffi.Bool> downloading_only,
) {
return _wire__crate__api__downloader_api__downloader_is_name_in_task(
port_,
name,
downloading_only,
);
}
@@ -1507,6 +1509,7 @@ class RustLibWire implements BaseWire {
ffi.Void Function(
ffi.Int64,
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<ffi.Bool>,
)
>
>(
@@ -1515,7 +1518,11 @@ class RustLibWire implements BaseWire {
late final _wire__crate__api__downloader_api__downloader_is_name_in_task =
_wire__crate__api__downloader_api__downloader_is_name_in_taskPtr
.asFunction<
void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)
void Function(
int,
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
ffi.Pointer<ffi.Bool>,
)
>();
void wire__crate__api__downloader_api__downloader_pause(

View File

@@ -596,6 +596,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_cancel_download": MessageLookupByLibrary.simpleMessage(
"Cancel Download",
),
"downloader_action_clear_completed": MessageLookupByLibrary.simpleMessage(
"Clear Completed",
),
"downloader_action_confirm_cancel_all_tasks":
MessageLookupByLibrary.simpleMessage(
"Confirm cancellation of all tasks?",
@@ -616,6 +619,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_pause_download": MessageLookupByLibrary.simpleMessage(
"Pause Download",
),
"downloader_action_remove_record": MessageLookupByLibrary.simpleMessage(
"Remove Record",
),
"downloader_action_restart_later": MessageLookupByLibrary.simpleMessage(
"Apply Later",
),

View File

@@ -539,6 +539,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_cancel_download": MessageLookupByLibrary.simpleMessage(
"ダウンロードをキャンセル",
),
"downloader_action_clear_completed": MessageLookupByLibrary.simpleMessage(
"完了をクリア",
),
"downloader_action_confirm_cancel_all_tasks":
MessageLookupByLibrary.simpleMessage("すべてのタスクをキャンセルしますか?"),
"downloader_action_confirm_cancel_download":
@@ -553,6 +556,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_pause_download": MessageLookupByLibrary.simpleMessage(
"ダウンロードを一時停止",
),
"downloader_action_remove_record": MessageLookupByLibrary.simpleMessage(
"レコードを削除",
),
"downloader_action_restart_later": MessageLookupByLibrary.simpleMessage(
"後で適用",
),

View File

@@ -579,6 +579,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_cancel_download": MessageLookupByLibrary.simpleMessage(
"Отменить загрузку",
),
"downloader_action_clear_completed": MessageLookupByLibrary.simpleMessage(
"Очистить завершённые",
),
"downloader_action_confirm_cancel_all_tasks":
MessageLookupByLibrary.simpleMessage("Подтвердите отмену всех задач?"),
"downloader_action_confirm_cancel_download":
@@ -593,6 +596,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_pause_download": MessageLookupByLibrary.simpleMessage(
"Приостановить загрузку",
),
"downloader_action_remove_record": MessageLookupByLibrary.simpleMessage(
"Удалить запись",
),
"downloader_action_restart_later": MessageLookupByLibrary.simpleMessage(
"Применить позже",
),

View File

@@ -528,6 +528,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_cancel_download": MessageLookupByLibrary.simpleMessage(
"取消下载",
),
"downloader_action_clear_completed": MessageLookupByLibrary.simpleMessage(
"清除已完成",
),
"downloader_action_confirm_cancel_all_tasks":
MessageLookupByLibrary.simpleMessage("确认取消全部任务?"),
"downloader_action_confirm_cancel_download":
@@ -540,6 +543,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_pause_download": MessageLookupByLibrary.simpleMessage(
"暂停下载",
),
"downloader_action_remove_record": MessageLookupByLibrary.simpleMessage(
"移除记录",
),
"downloader_action_restart_later": MessageLookupByLibrary.simpleMessage(
"下次启动时生效",
),

View File

@@ -512,6 +512,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_cancel_download": MessageLookupByLibrary.simpleMessage(
"取消下載",
),
"downloader_action_clear_completed": MessageLookupByLibrary.simpleMessage(
"清除已完成",
),
"downloader_action_confirm_cancel_all_tasks":
MessageLookupByLibrary.simpleMessage("確認取消全部任務?"),
"downloader_action_confirm_cancel_download":
@@ -524,6 +527,9 @@ class MessageLookup extends MessageLookupByLibrary {
"downloader_action_pause_download": MessageLookupByLibrary.simpleMessage(
"暫停下載",
),
"downloader_action_remove_record": MessageLookupByLibrary.simpleMessage(
"移除記錄",
),
"downloader_action_restart_later": MessageLookupByLibrary.simpleMessage(
"稍後套用",
),

View File

@@ -28,10 +28,9 @@ class S {
static const AppLocalizationDelegate delegate = AppLocalizationDelegate();
static Future<S> load(Locale locale) {
final name =
(locale.countryCode?.isEmpty ?? false)
? locale.languageCode
: locale.toString();
final name = (locale.countryCode?.isEmpty ?? false)
? locale.languageCode
: locale.toString();
final localeName = Intl.canonicalizedLocale(name);
return initializeMessages(localeName).then((_) {
Intl.defaultLocale = localeName;
@@ -425,6 +424,26 @@ class S {
);
}
/// `Clear Completed`
String get downloader_action_clear_completed {
return Intl.message(
'Clear Completed',
name: 'downloader_action_clear_completed',
desc: '',
args: [],
);
}
/// `Remove Record`
String get downloader_action_remove_record {
return Intl.message(
'Remove Record',
name: 'downloader_action_remove_record',
desc: '',
args: [],
);
}
/// `No download tasks`
String get downloader_info_no_download_tasks {
return Intl.message(

View File

@@ -77,6 +77,10 @@
"@downloader_action_resume_all": {},
"downloader_action_cancel_all": "Cancel All",
"@downloader_action_cancel_all": {},
"downloader_action_clear_completed": "Clear Completed",
"@downloader_action_clear_completed": {},
"downloader_action_remove_record": "Remove Record",
"@downloader_action_remove_record": {},
"downloader_info_no_download_tasks": "No download tasks",
"@downloader_info_no_download_tasks": {},
"downloader_info_total_size": "Total Size: {v1}",

View File

@@ -77,6 +77,10 @@
"@downloader_action_resume_all": {},
"downloader_action_cancel_all": "すべてキャンセル",
"@downloader_action_cancel_all": {},
"downloader_action_clear_completed": "完了をクリア",
"@downloader_action_clear_completed": {},
"downloader_action_remove_record": "レコードを削除",
"@downloader_action_remove_record": {},
"downloader_info_no_download_tasks": "ダウンロードタスクはありません",
"@downloader_info_no_download_tasks": {},
"downloader_info_total_size": "合計サイズ:{v1}",

View File

@@ -77,6 +77,10 @@
"@downloader_action_resume_all": {},
"downloader_action_cancel_all": "Отменить все",
"@downloader_action_cancel_all": {},
"downloader_action_clear_completed": "Очистить завершённые",
"@downloader_action_clear_completed": {},
"downloader_action_remove_record": "Удалить запись",
"@downloader_action_remove_record": {},
"downloader_info_no_download_tasks": "Нет задач загрузки",
"@downloader_info_no_download_tasks": {},
"downloader_info_total_size": "Общий размер: {v1}",

View File

@@ -76,6 +76,10 @@
"@downloader_action_resume_all": {},
"downloader_action_cancel_all": "全部取消",
"@downloader_action_cancel_all": {},
"downloader_action_clear_completed": "清除已完成",
"@downloader_action_clear_completed": {},
"downloader_action_remove_record": "移除记录",
"@downloader_action_remove_record": {},
"downloader_info_no_download_tasks": "无下载任务",
"@downloader_info_no_download_tasks": {},
"downloader_info_total_size": "总大小:{v1}",

View File

@@ -77,6 +77,10 @@
"@downloader_action_resume_all": {},
"downloader_action_cancel_all": "全部取消",
"@downloader_action_cancel_all": {},
"downloader_action_clear_completed": "清除已完成",
"@downloader_action_clear_completed": {},
"downloader_action_remove_record": "移除記錄",
"@downloader_action_remove_record": {},
"downloader_info_no_download_tasks": "無下載任務",
"@downloader_info_no_download_tasks": {},
"downloader_info_total_size": "總大小:{v1}",

View File

@@ -178,11 +178,11 @@ class DownloadManager extends _$DownloadManager {
return await downloader_api.downloaderGetAllTasks();
}
Future<bool> isNameInTask(String name) async {
Future<bool> isNameInTask(String name, {bool downloadingOnly = true}) async {
if (!state.isInitialized) {
return false;
}
return await downloader_api.downloaderIsNameInTask(name: name);
return await downloader_api.downloaderIsNameInTask(name: name, downloadingOnly: downloadingOnly);
}
Future<void> pauseAll() async {

View File

@@ -41,7 +41,7 @@ final class DownloadManagerProvider
}
}
String _$downloadManagerHash() => r'55c92224a5eb6bb0f84f0a97fd0585b94f61f711';
String _$downloadManagerHash() => r'feed17eda191d6b618b30e01afb75b7245fe0a83';
abstract class _$DownloadManager extends $Notifier<DownloadManagerState> {
DownloadManagerState build();

View File

@@ -33,6 +33,8 @@ class HomeDownloaderUI extends HookConsumerWidget {
const MapEntry("resume_all", FluentIcons.download): S.current.downloader_action_resume_all,
if (state.activeTasks.isNotEmpty || state.waitingTasks.isNotEmpty)
const MapEntry("cancel_all", FluentIcons.cancel): S.current.downloader_action_cancel_all,
if (state.completedTasks.isNotEmpty || state.errorTasks.isNotEmpty)
const MapEntry("clear_completed", FluentIcons.clear): S.current.downloader_action_clear_completed,
}.entries)
Padding(
padding: const EdgeInsets.only(left: 6, right: 6),
@@ -151,7 +153,7 @@ class HomeDownloaderUI extends HookConsumerWidget {
],
),
const SizedBox(width: 32),
if (type != "stopped")
if (type != "completed" && type != "error")
DropDownButton(
closeAfterClick: true,
title: Padding(
@@ -183,6 +185,26 @@ class HomeDownloaderUI extends HookConsumerWidget {
onPressed: () => model.openFolder(task),
),
],
)
else
DropDownButton(
closeAfterClick: true,
title: Padding(
padding: const EdgeInsets.all(3),
child: Text(S.current.downloader_action_options),
),
items: [
MenuFlyoutItem(
leading: const Icon(FluentIcons.chrome_close, size: 14),
text: Text(S.current.downloader_action_remove_record),
onPressed: () => model.removeTask(task.id.toInt()),
),
MenuFlyoutItem(
leading: const Icon(FluentIcons.folder_open, size: 14),
text: Text(S.current.action_open_folder),
onPressed: () => model.openFolder(task),
),
],
),
const SizedBox(width: 12),
],

View File

@@ -22,7 +22,8 @@ abstract class HomeDownloaderUIState with _$HomeDownloaderUIState {
factory HomeDownloaderUIState({
@Default([]) List<DownloadTaskInfo> activeTasks,
@Default([]) List<DownloadTaskInfo> waitingTasks,
@Default([]) List<DownloadTaskInfo> stoppedTasks,
@Default([]) List<DownloadTaskInfo> completedTasks,
@Default([]) List<DownloadTaskInfo> errorTasks,
DownloadGlobalStat? globalStat,
}) = _HomeDownloaderUIState;
}
@@ -48,7 +49,8 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
final listHeaderStatusMap = {
"active": S.current.downloader_title_downloading,
"waiting": S.current.downloader_info_waiting,
"stopped": S.current.downloader_title_ended,
"completed": S.current.downloader_title_ended,
"error": S.current.downloader_info_download_failed,
};
@override
@@ -92,6 +94,17 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
}
}
return;
case "clear_completed":
if (!downloadManagerState.isRunning) return;
try {
final allTasks = [...state.completedTasks, ...state.errorTasks];
for (var task in allTasks) {
await downloadManager.removeTask(task.id.toInt(), deleteFiles: false);
}
} catch (e) {
dPrint("DownloadsUIModel clear_completed Error: $e");
}
return;
case "settings":
_showDownloadSpeedSettings(context);
return;
@@ -99,19 +112,33 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
}
int getTasksLen() {
return state.activeTasks.length + state.waitingTasks.length + state.stoppedTasks.length;
return state.activeTasks.length + state.waitingTasks.length + state.completedTasks.length + state.errorTasks.length;
}
(DownloadTaskInfo, String, bool) getTaskAndType(int index) {
final tempList = <DownloadTaskInfo>[...state.activeTasks, ...state.waitingTasks, ...state.stoppedTasks];
final tempList = <DownloadTaskInfo>[
...state.activeTasks,
...state.waitingTasks,
...state.completedTasks,
...state.errorTasks,
];
if (index >= 0 && index < state.activeTasks.length) {
return (tempList[index], "active", index == 0);
}
if (index >= state.activeTasks.length && index < state.activeTasks.length + state.waitingTasks.length) {
return (tempList[index], "waiting", index == state.activeTasks.length);
}
if (index >= state.activeTasks.length + state.waitingTasks.length && index < tempList.length) {
return (tempList[index], "stopped", index == state.activeTasks.length + state.waitingTasks.length);
if (index >= state.activeTasks.length + state.waitingTasks.length &&
index < state.activeTasks.length + state.waitingTasks.length + state.completedTasks.length) {
return (tempList[index], "completed", index == state.activeTasks.length + state.waitingTasks.length);
}
if (index >= state.activeTasks.length + state.waitingTasks.length + state.completedTasks.length &&
index < tempList.length) {
return (
tempList[index],
"error",
index == state.activeTasks.length + state.waitingTasks.length + state.completedTasks.length,
);
}
throw Exception("Index out of range or element is null");
}
@@ -172,6 +199,11 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
}
}
Future<void> removeTask(int taskId) async {
final downloadManager = ref.read(downloadManagerProvider.notifier);
await downloadManager.removeTask(taskId, deleteFiles: false);
}
void openFolder(DownloadTaskInfo task) {
final outputFolder = task.outputFolder;
if (outputFolder.isNotEmpty) {
@@ -190,7 +222,8 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
final activeTasks = <DownloadTaskInfo>[];
final waitingTasks = <DownloadTaskInfo>[];
final stoppedTasks = <DownloadTaskInfo>[];
final completedTasks = <DownloadTaskInfo>[];
final errorTasks = <DownloadTaskInfo>[];
for (var task in allTasks) {
switch (task.status) {
@@ -202,8 +235,10 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
waitingTasks.add(task);
break;
case DownloadTaskStatus.finished:
completedTasks.add(task);
break;
case DownloadTaskStatus.error:
stoppedTasks.add(task);
errorTasks.add(task);
break;
}
}
@@ -211,11 +246,18 @@ class HomeDownloaderUIModel extends _$HomeDownloaderUIModel {
state = state.copyWith(
activeTasks: activeTasks,
waitingTasks: waitingTasks,
stoppedTasks: stoppedTasks,
completedTasks: completedTasks,
errorTasks: errorTasks,
globalStat: downloadManagerState.globalStat,
);
} else {
state = state.copyWith(activeTasks: [], waitingTasks: [], stoppedTasks: [], globalStat: null);
state = state.copyWith(
activeTasks: [],
waitingTasks: [],
completedTasks: [],
errorTasks: [],
globalStat: null,
);
}
await Future.delayed(const Duration(seconds: 1));
}

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$HomeDownloaderUIState {
List<DownloadTaskInfo> get activeTasks; List<DownloadTaskInfo> get waitingTasks; List<DownloadTaskInfo> get stoppedTasks; DownloadGlobalStat? get globalStat;
List<DownloadTaskInfo> get activeTasks; List<DownloadTaskInfo> get waitingTasks; List<DownloadTaskInfo> get completedTasks; List<DownloadTaskInfo> get errorTasks; DownloadGlobalStat? get globalStat;
/// Create a copy of HomeDownloaderUIState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $HomeDownloaderUIStateCopyWith<HomeDownloaderUIState> get copyWith => _$HomeDown
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is HomeDownloaderUIState&&const DeepCollectionEquality().equals(other.activeTasks, activeTasks)&&const DeepCollectionEquality().equals(other.waitingTasks, waitingTasks)&&const DeepCollectionEquality().equals(other.stoppedTasks, stoppedTasks)&&(identical(other.globalStat, globalStat) || other.globalStat == globalStat));
return identical(this, other) || (other.runtimeType == runtimeType&&other is HomeDownloaderUIState&&const DeepCollectionEquality().equals(other.activeTasks, activeTasks)&&const DeepCollectionEquality().equals(other.waitingTasks, waitingTasks)&&const DeepCollectionEquality().equals(other.completedTasks, completedTasks)&&const DeepCollectionEquality().equals(other.errorTasks, errorTasks)&&(identical(other.globalStat, globalStat) || other.globalStat == globalStat));
}
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(activeTasks),const DeepCollectionEquality().hash(waitingTasks),const DeepCollectionEquality().hash(stoppedTasks),globalStat);
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(activeTasks),const DeepCollectionEquality().hash(waitingTasks),const DeepCollectionEquality().hash(completedTasks),const DeepCollectionEquality().hash(errorTasks),globalStat);
@override
String toString() {
return 'HomeDownloaderUIState(activeTasks: $activeTasks, waitingTasks: $waitingTasks, stoppedTasks: $stoppedTasks, globalStat: $globalStat)';
return 'HomeDownloaderUIState(activeTasks: $activeTasks, waitingTasks: $waitingTasks, completedTasks: $completedTasks, errorTasks: $errorTasks, globalStat: $globalStat)';
}
@@ -45,7 +45,7 @@ abstract mixin class $HomeDownloaderUIStateCopyWith<$Res> {
factory $HomeDownloaderUIStateCopyWith(HomeDownloaderUIState value, $Res Function(HomeDownloaderUIState) _then) = _$HomeDownloaderUIStateCopyWithImpl;
@useResult
$Res call({
List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> stoppedTasks, DownloadGlobalStat? globalStat
List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> completedTasks, List<DownloadTaskInfo> errorTasks, DownloadGlobalStat? globalStat
});
@@ -62,11 +62,12 @@ class _$HomeDownloaderUIStateCopyWithImpl<$Res>
/// Create a copy of HomeDownloaderUIState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? activeTasks = null,Object? waitingTasks = null,Object? stoppedTasks = null,Object? globalStat = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? activeTasks = null,Object? waitingTasks = null,Object? completedTasks = null,Object? errorTasks = null,Object? globalStat = freezed,}) {
return _then(_self.copyWith(
activeTasks: null == activeTasks ? _self.activeTasks : activeTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,waitingTasks: null == waitingTasks ? _self.waitingTasks : waitingTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,stoppedTasks: null == stoppedTasks ? _self.stoppedTasks : stoppedTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,completedTasks: null == completedTasks ? _self.completedTasks : completedTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,errorTasks: null == errorTasks ? _self.errorTasks : errorTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,globalStat: freezed == globalStat ? _self.globalStat : globalStat // ignore: cast_nullable_to_non_nullable
as DownloadGlobalStat?,
));
@@ -153,10 +154,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> stoppedTasks, DownloadGlobalStat? globalStat)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> completedTasks, List<DownloadTaskInfo> errorTasks, DownloadGlobalStat? globalStat)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _HomeDownloaderUIState() when $default != null:
return $default(_that.activeTasks,_that.waitingTasks,_that.stoppedTasks,_that.globalStat);case _:
return $default(_that.activeTasks,_that.waitingTasks,_that.completedTasks,_that.errorTasks,_that.globalStat);case _:
return orElse();
}
@@ -174,10 +175,10 @@ return $default(_that.activeTasks,_that.waitingTasks,_that.stoppedTasks,_that.gl
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> stoppedTasks, DownloadGlobalStat? globalStat) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> completedTasks, List<DownloadTaskInfo> errorTasks, DownloadGlobalStat? globalStat) $default,) {final _that = this;
switch (_that) {
case _HomeDownloaderUIState():
return $default(_that.activeTasks,_that.waitingTasks,_that.stoppedTasks,_that.globalStat);case _:
return $default(_that.activeTasks,_that.waitingTasks,_that.completedTasks,_that.errorTasks,_that.globalStat);case _:
throw StateError('Unexpected subclass');
}
@@ -194,10 +195,10 @@ return $default(_that.activeTasks,_that.waitingTasks,_that.stoppedTasks,_that.gl
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> stoppedTasks, DownloadGlobalStat? globalStat)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> completedTasks, List<DownloadTaskInfo> errorTasks, DownloadGlobalStat? globalStat)? $default,) {final _that = this;
switch (_that) {
case _HomeDownloaderUIState() when $default != null:
return $default(_that.activeTasks,_that.waitingTasks,_that.stoppedTasks,_that.globalStat);case _:
return $default(_that.activeTasks,_that.waitingTasks,_that.completedTasks,_that.errorTasks,_that.globalStat);case _:
return null;
}
@@ -209,7 +210,7 @@ return $default(_that.activeTasks,_that.waitingTasks,_that.stoppedTasks,_that.gl
class _HomeDownloaderUIState implements HomeDownloaderUIState {
_HomeDownloaderUIState({final List<DownloadTaskInfo> activeTasks = const [], final List<DownloadTaskInfo> waitingTasks = const [], final List<DownloadTaskInfo> stoppedTasks = const [], this.globalStat}): _activeTasks = activeTasks,_waitingTasks = waitingTasks,_stoppedTasks = stoppedTasks;
_HomeDownloaderUIState({final List<DownloadTaskInfo> activeTasks = const [], final List<DownloadTaskInfo> waitingTasks = const [], final List<DownloadTaskInfo> completedTasks = const [], final List<DownloadTaskInfo> errorTasks = const [], this.globalStat}): _activeTasks = activeTasks,_waitingTasks = waitingTasks,_completedTasks = completedTasks,_errorTasks = errorTasks;
final List<DownloadTaskInfo> _activeTasks;
@@ -226,11 +227,18 @@ class _HomeDownloaderUIState implements HomeDownloaderUIState {
return EqualUnmodifiableListView(_waitingTasks);
}
final List<DownloadTaskInfo> _stoppedTasks;
@override@JsonKey() List<DownloadTaskInfo> get stoppedTasks {
if (_stoppedTasks is EqualUnmodifiableListView) return _stoppedTasks;
final List<DownloadTaskInfo> _completedTasks;
@override@JsonKey() List<DownloadTaskInfo> get completedTasks {
if (_completedTasks is EqualUnmodifiableListView) return _completedTasks;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_stoppedTasks);
return EqualUnmodifiableListView(_completedTasks);
}
final List<DownloadTaskInfo> _errorTasks;
@override@JsonKey() List<DownloadTaskInfo> get errorTasks {
if (_errorTasks is EqualUnmodifiableListView) return _errorTasks;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_errorTasks);
}
@override final DownloadGlobalStat? globalStat;
@@ -245,16 +253,16 @@ _$HomeDownloaderUIStateCopyWith<_HomeDownloaderUIState> get copyWith => __$HomeD
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _HomeDownloaderUIState&&const DeepCollectionEquality().equals(other._activeTasks, _activeTasks)&&const DeepCollectionEquality().equals(other._waitingTasks, _waitingTasks)&&const DeepCollectionEquality().equals(other._stoppedTasks, _stoppedTasks)&&(identical(other.globalStat, globalStat) || other.globalStat == globalStat));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _HomeDownloaderUIState&&const DeepCollectionEquality().equals(other._activeTasks, _activeTasks)&&const DeepCollectionEquality().equals(other._waitingTasks, _waitingTasks)&&const DeepCollectionEquality().equals(other._completedTasks, _completedTasks)&&const DeepCollectionEquality().equals(other._errorTasks, _errorTasks)&&(identical(other.globalStat, globalStat) || other.globalStat == globalStat));
}
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_activeTasks),const DeepCollectionEquality().hash(_waitingTasks),const DeepCollectionEquality().hash(_stoppedTasks),globalStat);
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_activeTasks),const DeepCollectionEquality().hash(_waitingTasks),const DeepCollectionEquality().hash(_completedTasks),const DeepCollectionEquality().hash(_errorTasks),globalStat);
@override
String toString() {
return 'HomeDownloaderUIState(activeTasks: $activeTasks, waitingTasks: $waitingTasks, stoppedTasks: $stoppedTasks, globalStat: $globalStat)';
return 'HomeDownloaderUIState(activeTasks: $activeTasks, waitingTasks: $waitingTasks, completedTasks: $completedTasks, errorTasks: $errorTasks, globalStat: $globalStat)';
}
@@ -265,7 +273,7 @@ abstract mixin class _$HomeDownloaderUIStateCopyWith<$Res> implements $HomeDownl
factory _$HomeDownloaderUIStateCopyWith(_HomeDownloaderUIState value, $Res Function(_HomeDownloaderUIState) _then) = __$HomeDownloaderUIStateCopyWithImpl;
@override @useResult
$Res call({
List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> stoppedTasks, DownloadGlobalStat? globalStat
List<DownloadTaskInfo> activeTasks, List<DownloadTaskInfo> waitingTasks, List<DownloadTaskInfo> completedTasks, List<DownloadTaskInfo> errorTasks, DownloadGlobalStat? globalStat
});
@@ -282,11 +290,12 @@ class __$HomeDownloaderUIStateCopyWithImpl<$Res>
/// Create a copy of HomeDownloaderUIState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? activeTasks = null,Object? waitingTasks = null,Object? stoppedTasks = null,Object? globalStat = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? activeTasks = null,Object? waitingTasks = null,Object? completedTasks = null,Object? errorTasks = null,Object? globalStat = freezed,}) {
return _then(_HomeDownloaderUIState(
activeTasks: null == activeTasks ? _self._activeTasks : activeTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,waitingTasks: null == waitingTasks ? _self._waitingTasks : waitingTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,stoppedTasks: null == stoppedTasks ? _self._stoppedTasks : stoppedTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,completedTasks: null == completedTasks ? _self._completedTasks : completedTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,errorTasks: null == errorTasks ? _self._errorTasks : errorTasks // ignore: cast_nullable_to_non_nullable
as List<DownloadTaskInfo>,globalStat: freezed == globalStat ? _self.globalStat : globalStat // ignore: cast_nullable_to_non_nullable
as DownloadGlobalStat?,
));

View File

@@ -42,7 +42,7 @@ final class HomeDownloaderUIModelProvider
}
String _$homeDownloaderUIModelHash() =>
r'bf7d095d761fff078de707562cf311c20db664d9';
r'b230746a782b511dd58b0b46def7845c01412762';
abstract class _$HomeDownloaderUIModel
extends $Notifier<HomeDownloaderUIState> {

View File

@@ -257,7 +257,7 @@ class InputMethodDialogUIModel extends _$InputMethodDialogUIModel {
}
// get torrent Data
final data = await RSHttp.get(torrentUrl!);
final taskId = await downloadManager.addTorrent(data.data!, outputFolder: _localTranslateModelDir);
final taskId = await downloadManager.addTorrent(data.data!, outputFolder: "$_localTranslateModelDir/$_localTranslateModelName");
return taskId.toString();
} catch (e) {
dPrint("[InputMethodDialogUIModel] doDownloadTranslateModel error: $e");

View File

@@ -43,7 +43,7 @@ final class InputMethodDialogUIModelProvider
}
String _$inputMethodDialogUIModelHash() =>
r'5c2989faf94d43bb814e5b80e10d68416c8241ec';
r'77bf2b02a7b7ea66e9a06be068b791b3a4295a44';
abstract class _$InputMethodDialogUIModel
extends $Notifier<InputMethodDialogUIState> {