mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
pause and delete all
This commit is contained in:
@@ -121,7 +121,11 @@
|
|||||||
"Proxy": "代理",
|
"Proxy": "代理",
|
||||||
"Appearance": "外观",
|
"Appearance": "外观",
|
||||||
"Language": "语言",
|
"Language": "语言",
|
||||||
"Theme": "主题"
|
"Theme": "主题",
|
||||||
|
"Pause": "暂停",
|
||||||
|
"Resume": "继续",
|
||||||
|
"Paused": "已暂停",
|
||||||
|
"Delete all": "删除全部"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
@@ -245,6 +249,10 @@
|
|||||||
"Proxy": "代理",
|
"Proxy": "代理",
|
||||||
"Appearance": "外觀",
|
"Appearance": "外觀",
|
||||||
"Language": "語言",
|
"Language": "語言",
|
||||||
"Theme": "主題"
|
"Theme": "主題",
|
||||||
|
"Pause": "暫停",
|
||||||
|
"Resume": "繼續",
|
||||||
|
"Paused": "已暫停",
|
||||||
|
"Delete all": "刪除全部"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -163,6 +163,10 @@ class DownloadingTask {
|
|||||||
_stop = false;
|
_stop = false;
|
||||||
_download();
|
_download();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pause() {
|
||||||
|
_stop = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DownloadManager {
|
class DownloadManager {
|
||||||
@@ -276,8 +280,20 @@ class DownloadManager {
|
|||||||
|
|
||||||
int get maxConcurrentTasks => appdata.settings["maxParallels"];
|
int get maxConcurrentTasks => appdata.settings["maxParallels"];
|
||||||
|
|
||||||
|
bool _paused = false;
|
||||||
|
|
||||||
|
bool get paused => _paused;
|
||||||
|
|
||||||
|
void pause() {
|
||||||
|
_paused = true;
|
||||||
|
for(var task in tasks) {
|
||||||
|
task.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
_loop ??= Timer.periodic(const Duration(seconds: 1), (timer) {
|
_loop ??= Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
|
if(_paused) return;
|
||||||
_bytesPerSecond = _currentBytes;
|
_bytesPerSecond = _currentBytes;
|
||||||
_currentBytes = 0;
|
_currentBytes = 0;
|
||||||
uiUpdateCallback?.call();
|
uiUpdateCallback?.call();
|
||||||
@@ -349,4 +365,8 @@ class DownloadManager {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resume() {
|
||||||
|
_paused = false;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -47,7 +47,38 @@ class _DownloadingPageState extends State<DownloadingPage> {
|
|||||||
Widget buildTop() {
|
Widget buildTop() {
|
||||||
int bytesPerSecond = DownloadManager().bytesPerSecond;
|
int bytesPerSecond = DownloadManager().bytesPerSecond;
|
||||||
|
|
||||||
return SliverTitleBar(title: "${"Speed".tl}: ${bytesToText(bytesPerSecond)}/s");
|
bool paused = DownloadManager().paused;
|
||||||
|
|
||||||
|
return SliverTitleBar(
|
||||||
|
title: paused
|
||||||
|
? "Paused".tl
|
||||||
|
:"${"Speed".tl}: ${bytesToText(bytesPerSecond)}/s",
|
||||||
|
action: SplitButton(
|
||||||
|
onInvoked: (){
|
||||||
|
if(!paused) {
|
||||||
|
DownloadManager().pause();
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
DownloadManager().resume();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
flyout: MenuFlyout(
|
||||||
|
items: [
|
||||||
|
MenuFlyoutItem(text: Text("Cancel All".tl), onPressed: (){
|
||||||
|
var tasks = List.from(DownloadManager().tasks);
|
||||||
|
DownloadManager().tasks.clear();
|
||||||
|
for(var task in tasks) {
|
||||||
|
task.cancel();
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Text(paused ? "Resume".tl : "Pause".tl)
|
||||||
|
.toCenter().fixWidth(56).fixHeight(32),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildContent() {
|
Widget buildContent() {
|
||||||
|
Reference in New Issue
Block a user